|
1 | 1 | <!DOCTYPE HTML>
|
2 |
| -<html lang="{{ language }}"> |
| 2 | +<html lang="{{ language }}" class="sidebar-visible no-js"> |
3 | 3 | <head>
|
| 4 | + <!-- Book generated using mdBook --> |
4 | 5 | <meta charset="UTF-8">
|
5 | 6 | <title>{{ title }}</title>
|
6 | 7 | <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
7 | 8 | <meta name="description" content="{{ description }}">
|
8 | 9 | <meta name="viewport" content="width=device-width, initial-scale=1">
|
| 10 | + <meta name="theme-color" content="#ffffff" /> |
9 | 11 |
|
10 | 12 | <base href="{{ path_to_root }}">
|
11 | 13 |
|
|
16 | 18 | <link rel="shortcut icon" href="{{ favicon }}">
|
17 | 19 |
|
18 | 20 | <!-- Font Awesome -->
|
19 |
| - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> |
| 21 | + <link rel="stylesheet" href="_FontAwesome/css/font-awesome.css"> |
20 | 22 |
|
21 | 23 | <link rel="stylesheet" href="highlight.css">
|
22 | 24 | <link rel="stylesheet" href="tomorrow-night.css">
|
23 | 25 | <link rel="stylesheet" href="ayu-highlight.css">
|
24 | 26 |
|
25 |
| - <!-- Custom theme --> |
| 27 | + <!-- Custom theme stylesheets --> |
26 | 28 | {{#each additional_css}}
|
27 | 29 | <link rel="stylesheet" href="{{this}}">
|
28 | 30 | {{/each}}
|
29 | 31 |
|
30 | 32 | {{#if mathjax_support}}
|
31 | 33 | <!-- MathJax -->
|
32 |
| - <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
| 34 | + <script async type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
33 | 35 | {{/if}}
|
34 | 36 |
|
35 |
| - <!-- Fetch Clipboard.js from CDN but have a local fallback --> |
36 |
| - <script src="https://cdn.jsdelivr.net/clipboard.js/1.6.1/clipboard.min.js"></script> |
37 |
| - <script> |
38 |
| - if (typeof Clipboard == 'undefined') { |
39 |
| - document.write(unescape("%3Cscript src='clipboard.min.js'%3E%3C/script%3E")); |
40 |
| - } |
41 |
| - </script> |
42 |
| - |
43 |
| - <!-- Fetch JQuery from CDN but have a local fallback --> |
44 |
| - <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script> |
45 |
| - <script> |
46 |
| - if (typeof jQuery == 'undefined') { |
47 |
| - document.write(unescape("%3Cscript src='jquery.js'%3E%3C/script%3E")); |
48 |
| - } |
49 |
| - </script> |
50 |
| - |
51 |
| - <!-- Fetch store.js from local - TODO add CDN when 2.x.x is available on cdnjs --> |
52 |
| - <script src="store.js"></script> |
53 |
| - |
54 |
| - <!-- Custom JS script --> |
55 |
| - {{#each additional_js}} |
56 |
| - <script type="text/javascript" src="{{this}}"></script> |
57 |
| - {{/each}} |
58 |
| - |
59 | 37 | </head>
|
60 | 38 | <body class="light">
|
| 39 | + <!-- Work around some values being stored in localStorage wrapped in quotes --> |
| 40 | + <script type="text/javascript"> |
| 41 | + try { |
| 42 | + var theme = localStorage.getItem('mdbook-theme'); |
| 43 | + var sidebar = localStorage.getItem('mdbook-sidebar'); |
| 44 | +
|
| 45 | + if (theme.startsWith('"') && theme.endsWith('"')) { |
| 46 | + localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); |
| 47 | + } |
| 48 | +
|
| 49 | + if (sidebar.startsWith('"') && sidebar.endsWith('"')) { |
| 50 | + localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); |
| 51 | + } |
| 52 | + } catch (e) { } |
| 53 | + </script> |
| 54 | + |
61 | 55 | <!-- Set the theme before any content is loaded, prevents flash -->
|
62 | 56 | <script type="text/javascript">
|
63 |
| - var theme = store.get('theme'); |
| 57 | + var theme; |
| 58 | + try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } |
64 | 59 | if (theme === null || theme === undefined) { theme = 'light'; }
|
65 |
| - $('body').removeClass().addClass(theme); |
| 60 | + document.body.className = theme; |
| 61 | + document.querySelector('html').className = theme + ' js'; |
66 | 62 | </script>
|
67 | 63 |
|
68 | 64 | <!-- Hide / unhide sidebar before it is displayed -->
|
69 | 65 | <script type="text/javascript">
|
70 |
| - var sidebar = store.get('sidebar'); |
71 |
| - if (sidebar === "hidden") { $("html").addClass("sidebar-hidden") } |
72 |
| - else if (sidebar === "visible") { $("html").addClass("sidebar-visible") } |
| 66 | + var html = document.querySelector('html'); |
| 67 | + var sidebar = 'hidden'; |
| 68 | + if (document.body.clientWidth >= 1080) { |
| 69 | + try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } |
| 70 | + sidebar = sidebar || 'visible'; |
| 71 | + } |
| 72 | + html.classList.remove('sidebar-visible'); |
| 73 | + html.classList.add("sidebar-" + sidebar); |
73 | 74 | </script>
|
74 | 75 |
|
75 |
| - <div id="sidebar" class="sidebar"> |
| 76 | + <nav id="sidebar" class="sidebar" aria-label="Table of contents"> |
76 | 77 | {{#toc}}{{/toc}}
|
77 |
| - </div> |
| 78 | + </nav> |
78 | 79 |
|
79 | 80 | <div id="page-wrapper" class="page-wrapper">
|
80 | 81 |
|
81 |
| - <div class="page" tabindex="-1"> |
| 82 | + <div class="page"> |
| 83 | + {{> header}} |
82 | 84 | <div id="menu-bar" class="menu-bar">
|
83 |
| - <div class="left-buttons"> |
84 |
| - <i id="sidebar-toggle" class="fa fa-bars"></i> |
85 |
| - <!-- START - Rust Cookbook customization --> |
86 |
| - <i id="edit-button" class="fa fa-edit">Edit</i> |
87 |
| - <!-- END - Rust Cookbook customization --> |
88 |
| - <i id="theme-toggle" class="fa fa-paint-brush"></i> |
| 85 | + <div id="menu-bar-sticky-container"> |
| 86 | + <div class="left-buttons"> |
| 87 | + <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar"> |
| 88 | + <i class="fa fa-bars"></i> |
| 89 | + </button> |
| 90 | + <!-- START - Rust Cookbook customization --> |
| 91 | + <button id="edit-button" class="icon-button" type="button" title="Fork and edit" aria-label="Fork and edit" aria-haspopup="true" aria-expanded="false" aria-controls="edit"> |
| 92 | + <i class="fa fa-edit">Edit</i> |
| 93 | + </button> |
| 94 | + <!-- END - Rust Cookbook customization --> |
| 95 | + <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list"> |
| 96 | + <i class="fa fa-paint-brush"></i> |
| 97 | + </button> |
| 98 | + <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu"> |
| 99 | + <li role="none"><button role="menuitem" class="theme" id="light">Light <span class="default">(default)</span></button></li> |
| 100 | + <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li> |
| 101 | + <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li> |
| 102 | + <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li> |
| 103 | + <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li> |
| 104 | + </ul> |
| 105 | + {{#if search_enabled}} |
| 106 | + <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar"> |
| 107 | + <i class="fa fa-search"></i> |
| 108 | + </button> |
| 109 | + {{/if}} |
| 110 | + </div> |
| 111 | + |
| 112 | + <h1 class="menu-title">{{ book_title }}</h1> |
| 113 | + |
| 114 | + <div class="right-buttons"> |
| 115 | + <a href="print.html" title="Print this book" aria-label="Print this book"> |
| 116 | + <i id="print-button" class="fa fa-print"></i> |
| 117 | + </a> |
| 118 | + </div> |
89 | 119 | </div>
|
| 120 | + </div> |
90 | 121 |
|
91 |
| - <h1 class="menu-title">{{ book_title }}</h1> |
92 |
| - |
93 |
| - <div class="right-buttons"> |
94 |
| - <i id="print-button" class="fa fa-print" title="Print this book"></i> |
| 122 | + {{#if search_enabled}} |
| 123 | + <div id="search-wrapper" class="hidden"> |
| 124 | + <form id="searchbar-outer" class="searchbar-outer"> |
| 125 | + <input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header"> |
| 126 | + </form> |
| 127 | + <div id="searchresults-outer" class="searchresults-outer hidden"> |
| 128 | + <div id="searchresults-header" class="searchresults-header"></div> |
| 129 | + <ul id="searchresults"> |
| 130 | + </ul> |
95 | 131 | </div>
|
96 | 132 | </div>
|
| 133 | + {{/if}} |
| 134 | + |
| 135 | + <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM --> |
| 136 | + <script type="text/javascript"> |
| 137 | + document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible'); |
| 138 | + document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible'); |
| 139 | + Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) { |
| 140 | + link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1); |
| 141 | + }); |
| 142 | +
|
| 143 | + // START - Rust Cookbook customization |
| 144 | + document.getElementById("edit-button").addEventListener("click", function(){ |
| 145 | + var editWindow = window.open("https://github.com/rust-lang-nursery/rust-cookbook/edit/master/src/{{ path }}"); |
| 146 | + }); |
| 147 | + // END - Rust Cookbook customization |
| 148 | + </script> |
97 | 149 |
|
98 | 150 | <div id="content" class="content">
|
99 |
| - {{{ content }}} |
| 151 | + <main> |
| 152 | + {{{ content }}} |
| 153 | + </main> |
| 154 | + |
| 155 | + <nav class="nav-wrapper" aria-label="Page navigation"> |
| 156 | + <!-- Mobile navigation buttons --> |
| 157 | + {{#previous}} |
| 158 | + <a rel="prev" href="{{link}}" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> |
| 159 | + <i class="fa fa-angle-left"></i> |
| 160 | + </a> |
| 161 | + {{/previous}} |
| 162 | + |
| 163 | + {{#next}} |
| 164 | + <a rel="next" href="{{link}}" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> |
| 165 | + <i class="fa fa-angle-right"></i> |
| 166 | + </a> |
| 167 | + {{/next}} |
| 168 | + |
| 169 | + <div style="clear: both"></div> |
| 170 | + </nav> |
100 | 171 | </div>
|
| 172 | + </div> |
101 | 173 |
|
102 |
| - <!-- Mobile navigation buttons --> |
| 174 | + <nav class="nav-wide-wrapper" aria-label="Page navigation"> |
103 | 175 | {{#previous}}
|
104 |
| - <a rel="prev" href="{{link}}" class="mobile-nav-chapters previous"> |
| 176 | + <a href="{{link}}" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left"> |
105 | 177 | <i class="fa fa-angle-left"></i>
|
106 | 178 | </a>
|
107 | 179 | {{/previous}}
|
108 | 180 |
|
109 | 181 | {{#next}}
|
110 |
| - <a rel="next" href="{{link}}" class="mobile-nav-chapters next"> |
| 182 | + <a href="{{link}}" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right"> |
111 | 183 | <i class="fa fa-angle-right"></i>
|
112 | 184 | </a>
|
113 | 185 | {{/next}}
|
114 |
| - |
115 |
| - </div> |
116 |
| - |
117 |
| - {{#previous}} |
118 |
| - <a href="{{link}}" class="nav-chapters previous" title="You can navigate through the chapters using the arrow keys"> |
119 |
| - <i class="fa fa-angle-left"></i> |
120 |
| - </a> |
121 |
| - {{/previous}} |
122 |
| - |
123 |
| - {{#next}} |
124 |
| - <a href="{{link}}" class="nav-chapters next" title="You can navigate through the chapters using the arrow keys"> |
125 |
| - <i class="fa fa-angle-right"></i> |
126 |
| - </a> |
127 |
| - {{/next}} |
| 186 | + </nav> |
128 | 187 |
|
129 | 188 | </div>
|
130 | 189 |
|
131 |
| - |
132 |
| - <!-- Local fallback for Font Awesome --> |
133 |
| - <script> |
134 |
| - if ($(".fa").css("font-family") !== "FontAwesome") { |
135 |
| - $('<link rel="stylesheet" type="text/css" href="_FontAwesome/css/font-awesome.css">').prependTo('head'); |
| 190 | + {{#if livereload}} |
| 191 | + <!-- Livereload script (if served using the cli tool) --> |
| 192 | + <script type="text/javascript"> |
| 193 | + var socket = new WebSocket("{{{livereload}}}"); |
| 194 | + socket.onmessage = function (event) { |
| 195 | + if (event.data === "reload") { |
| 196 | + socket.close(); |
| 197 | + location.reload(true); // force reload from server (not from cache) |
| 198 | + } |
| 199 | + }; |
| 200 | +
|
| 201 | + window.onbeforeunload = function() { |
| 202 | + socket.close(); |
136 | 203 | }
|
137 |
| -
|
138 |
| - // START - Rust Cookbook customization |
139 |
| - $("#edit-button").click(function(){ |
140 |
| - var editWindow = window.open("https://github.com/rust-lang-nursery/rust-cookbook/edit/master/src/{{ path }}"); |
141 |
| - }); |
142 |
| - // END - Rust Cookbook customization |
143 | 204 | </script>
|
144 |
| - |
145 |
| - <!-- Livereload script (if served using the cli tool) --> |
146 |
| - {{{livereload}}} |
| 205 | + {{/if}} |
147 | 206 |
|
148 | 207 | {{#if google_analytics}}
|
149 |
| - <script> |
150 |
| - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
151 |
| - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
152 |
| - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
153 |
| - })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
154 |
| -
|
155 |
| - ga('create', '{{google_analytics}}', 'auto'); |
156 |
| - ga('send', 'pageview'); |
| 208 | + <!-- Google Analytics Tag --> |
| 209 | + <script type="text/javascript"> |
| 210 | + var localAddrs = ["localhost", "127.0.0.1", ""]; |
| 211 | +
|
| 212 | + // make sure we don't activate google analytics if the developer is |
| 213 | + // inspecting the book locally... |
| 214 | + if (localAddrs.indexOf(document.location.hostname) === -1) { |
| 215 | + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
| 216 | + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), |
| 217 | + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) |
| 218 | + })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); |
| 219 | +
|
| 220 | + ga('create', '{{google_analytics}}', 'auto'); |
| 221 | + ga('send', 'pageview'); |
| 222 | + } |
| 223 | + </script> |
| 224 | + {{/if}} |
| 225 | + |
| 226 | + {{#if is_print}} |
| 227 | + <script type="text/javascript"> |
| 228 | + document.addEventListener('DOMContentLoaded', function() { |
| 229 | + window.print(); |
| 230 | + }) |
157 | 231 | </script>
|
158 | 232 | {{/if}}
|
159 | 233 |
|
160 |
| - {{#if playpens_editable}} |
161 |
| - <script src="{{ ace_js }}" type="text/javascript" charset="utf-8"></script> |
162 |
| - <script src="{{ editor_js }}" type="text/javascript" charset="utf-8"></script> |
163 |
| - <script src="{{ mode_rust_js }}" type="text/javascript" charset="utf-8"></script> |
164 |
| - <script src="{{ theme_dawn_js }}" type="text/javascript" charset="utf-8"></script> |
165 |
| - <script src="{{ theme_tomorrow_night_js }}" type="text/javascript" charset="utf-8"></script> |
| 234 | + {{#if playpen_js}} |
| 235 | + <script src="ace.js" type="text/javascript" charset="utf-8"></script> |
| 236 | + <script src="editor.js" type="text/javascript" charset="utf-8"></script> |
| 237 | + <script src="mode-rust.js" type="text/javascript" charset="utf-8"></script> |
| 238 | + <script src="theme-dawn.js" type="text/javascript" charset="utf-8"></script> |
| 239 | + <script src="theme-tomorrow_night.js" type="text/javascript" charset="utf-8"></script> |
| 240 | + {{/if}} |
| 241 | + |
| 242 | + {{#if search_enabled}} |
| 243 | + <script src="searchindex.js" type="text/javascript" charset="utf-8"></script> |
| 244 | + {{/if}} |
| 245 | + {{#if search_js}} |
| 246 | + <script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> |
| 247 | + <script src="mark.min.js" type="text/javascript" charset="utf-8"></script> |
| 248 | + <script src="searcher.js" type="text/javascript" charset="utf-8"></script> |
166 | 249 | {{/if}}
|
167 | 250 |
|
168 |
| - <script src="highlight.js"></script> |
169 |
| - <script src="book.js"></script> |
| 251 | + <script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script> |
| 252 | + <script src="highlight.js" type="text/javascript" charset="utf-8"></script> |
| 253 | + <script src="book.js" type="text/javascript" charset="utf-8"></script> |
| 254 | + |
| 255 | + <!-- Custom JS scripts --> |
| 256 | + {{#each additional_js}} |
| 257 | + <script type="text/javascript" src="{{this}}"></script> |
| 258 | + {{/each}} |
| 259 | + |
170 | 260 | </body>
|
171 | 261 | </html>
|
0 commit comments