]> git.lizzy.rs Git - rust.git/blob - src/doc/not_found.md
Add the library search box on the 404 page
[rust.git] / src / doc / not_found.md
1 % Not Found
2
3 <!-- Completely hide the TOC and the section numbers -->
4 <style type="text/css">
5 #TOC { display: none; }
6 .header-section-number { display: none; }
7 li {list-style-type: none; }
8 .search-input {
9     width: calc(100% - 200px);
10 }
11 .search-but {
12     cursor: pointer;
13 }
14 .search-but, .search-input {
15     padding: 4px;
16     border: 1px solid #ccc;
17     border-radius: 3px;
18     outline: none;
19     font-size: 0.7em;
20     background-color: #fff;
21 }
22 .search-but:hover, .search-input:focus {
23     border-color: #55a9ff;
24 }
25 </style>
26
27 Looks like you've taken a wrong turn.
28
29 Some things that might be helpful to you though:
30
31 # Search
32
33 <div>
34   <form action="std/index.html" method="get">
35     <input id="std-search" class="search-input" type="search" name="search"
36            placeholder="Search through the standard library"/>
37     <button class="search-but">Search Standard Library</button>
38   </form>
39 </div>
40
41 <div>
42   <form action="https://duckduckgo.com/">
43     <input id="site-search" class="search-input" type="search" name="q"></input>
44     <input type="submit" value="Search DuckDuckGo" class="search-but">
45   </form>
46 </div>
47
48 # Reference
49
50  * [The Rust official site](https://www.rust-lang.org)
51  * [The Rust reference](https://doc.rust-lang.org/reference/index.html)
52
53 # Docs
54
55 [The standard library](https://doc.rust-lang.org/std/)
56
57 <script>
58 function get_url_fragments() {
59     var last = document.URL.split("/").pop();
60     var tokens = last.split(".");
61     var op = [];
62     for (var i=0; i < tokens.length; i++) {
63         var t = tokens[i];
64         if (t == 'html' || t.indexOf("#") != -1) {
65             // no html or anchors
66         } else {
67             op.push(t);
68         }
69     }
70     return op;
71 }
72
73 function populate_site_search() {
74     var op = get_url_fragments();
75
76     var search = document.getElementById('site-search');
77     search.value = op.join(' ') + " site:doc.rust-lang.org";
78 }
79
80 function populate_rust_search() {
81     var op = get_url_fragments();
82     document.getElementById('std-search').value = op.join(' ');
83 }
84 populate_site_search();
85 populate_rust_search();
86 </script>