1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
14 use externalfiles::ExternalHtml;
20 pub external_html: ExternalHtml,
22 pub playground_url: String,
28 pub root_path: &'a str,
29 pub description: &'a str,
33 pub fn render<T: fmt::Show, S: fmt::Show>(
34 dst: &mut io::Writer, layout: &Layout, page: &Page, sidebar: &S, t: &T)
41 <meta charset="utf-8">
42 <meta name="viewport" content="width=device-width, initial-scale=1.0">
43 <meta name="generator" content="rustdoc">
44 <meta name="description" content="{description}">
45 <meta name="keywords" content="{keywords}">
47 <title>{title}</title>
49 <link rel="stylesheet" type="text/css" href="{root_path}main.css">
54 <body class="rustdoc">
57 This old browser is unsupported and will most likely display funky
64 <section class="sidebar">
70 <form class="search-form js-only">
71 <div class="search-container">
72 <input class="search-input" name="search"
74 placeholder="Click or press 'S' to search, '?' for more options..."
80 <section id='main' class="content {ty}">{content}</section>
81 <section id='search' class="content hidden"></section>
83 <section class="footer"></section>
85 <div id="help" class="hidden">
86 <div class="shortcuts">
87 <h1>Keyboard shortcuts</h1>
90 <dd>Show this help dialog</dd>
92 <dd>Focus the search field</dd>
94 <dd>Move up in search results</dd>
96 <dd>Move down in search results</dd>
98 <dd>Go to active search result</dd>
102 <h1>Search tricks</h1>
104 Prefix searches with a type followed by a colon (e.g.
105 <code>fn:</code>) to restrict the search to a given type.
108 Accepted types are: <code>fn</code>, <code>mod</code>,
109 <code>struct</code>, <code>enum</code>,
110 <code>trait</code>, <code>typedef</code> (or
119 window.rootPath = "{root_path}";
120 window.currentCrate = "{krate}";
121 window.playgroundUrl = "{play_url}";
123 <script src="{root_path}jquery.js"></script>
124 <script src="{root_path}main.js"></script>
126 <script async src="{root_path}search-index.js"></script>
130 root_path = page.root_path,
132 logo = if layout.logo.len() == 0 {
135 format!("<a href='{}{}/index.html'>\
136 <img src='{}' alt='' width='100'></a>",
137 page.root_path, layout.krate,
141 description = page.description,
142 keywords = page.keywords,
143 favicon = if layout.favicon.len() == 0 {
146 format!(r#"<link rel="shortcut icon" href="{}">"#, layout.favicon)
148 in_header = layout.external_html.in_header,
149 before_content = layout.external_html.before_content,
150 after_content = layout.external_html.after_content,
152 krate = layout.krate,
153 play_url = layout.playground_url,
154 play_js = if layout.playground_url.len() == 0 {
157 format!(r#"<script src="{}playpen.js"></script>"#, page.root_path)
162 pub fn redirect(dst: &mut io::Writer, url: &str) -> io::IoResult<()> {
163 // <script> triggers a redirect before refresh, so this is fine.
168 <meta http-equiv="refresh" content="0;URL={url}">
171 <p>Redirecting to <a href="{url}">{url}</a>...</p>
172 <script>location.replace("{url}" + location.search + location.hash);</script>