]>
Commit | Line | Data |
---|---|---|
983a9a39 XL |
1 | Description: Use local web resources instead of remote ones |
2 | Author: Matthijs van Otterdijk <matthijs@wirevirt.net> | |
315de376 | 3 | Author: Ximin Luo <infinity0@debian.org> |
983a9a39 | 4 | Bug: https://github.com/azerupi/mdBook/issues/271 |
f9f51dbf XL |
5 | Comment: |
6 | Use https://github.com/infinity0/mdBook/tree/debian to help you rebase the | |
7 | patch on top of a newer version. | |
45d026fb XL |
8 | . |
9 | Make sure the paths here match the ones in debian/rust-doc.links | |
983a9a39 XL |
10 | --- |
11 | This patch header follows DEP-3: http://dep.debian.net/deps/dep3/ | |
47372d83 XL |
12 | --- a/src/tools/linkchecker/main.rs |
13 | +++ b/src/tools/linkchecker/main.rs | |
14 | @@ -321,6 +321,15 @@ | |
15 | println!("`#{}` pointing to `{}`", fragment, pretty_path.display()); | |
16 | }; | |
17 | } | |
18 | + } else if fs::symlink_metadata(&path).is_ok() { | |
19 | + let target = fs::read_link(&path).unwrap(); | |
20 | + if target.starts_with("/usr/share") { | |
21 | + // broken symlink to /usr/share, ok for our Debian build | |
22 | + return; | |
23 | + } | |
24 | + *errors = true; | |
25 | + print!("{}:{}: broken link - ", path.display(), i + 1); | |
26 | + println!("{}", path.display()); | |
27 | } else { | |
28 | let pretty_path = path.strip_prefix(root).unwrap_or(&path); | |
29 | if !is_exception(file, pretty_path.to_str().unwrap()) { | |
30 | --- a/vendor/mdbook/src/theme/index.hbs | |
31 | +++ b/vendor/mdbook/src/theme/index.hbs | |
32 | @@ -34,10 +34,7 @@ | |
1141a89a | 33 | {{/if}} |
91546fe7 | 34 | |
b6515096 XL |
35 | <!-- Fonts --> |
36 | - <link rel="stylesheet" href="{{ path_to_root }}FontAwesome/css/font-awesome.css"> | |
4a099bab XL |
37 | - {{#if copy_fonts}} |
38 | - <link rel="stylesheet" href="{{ path_to_root }}fonts/fonts.css"> | |
39 | - {{/if}} | |
47372d83 | 40 | + <link rel="stylesheet" href="{{ path_to_root }}css/font-awesome.min.css"> |
91546fe7 | 41 | |
b6515096 | 42 | <!-- Highlight.js Stylesheets --> |
47372d83 XL |
43 | <link rel="stylesheet" href="{{ path_to_root }}highlight.css"> |
44 | @@ -51,7 +48,7 @@ | |
91546fe7 | 45 | |
f9f51dbf | 46 | {{#if mathjax_support}} |
91546fe7 | 47 | <!-- MathJax --> |
08170615 | 48 | - <script async type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
47372d83 | 49 | + <script async type="text/javascript" src="MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> |
f9f51dbf | 50 | {{/if}} |
91546fe7 | 51 | </head> |
46f4175b | 52 | <body> |
47372d83 | 53 | @@ -61,46 +58,6 @@ |
46f4175b | 54 | var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}"; |
b6515096 XL |
55 | </script> |
56 | ||
11ae32e0 XL |
57 | - <!-- Work around some values being stored in localStorage wrapped in quotes --> |
58 | - <script type="text/javascript"> | |
59 | - try { | |
60 | - var theme = localStorage.getItem('mdbook-theme'); | |
61 | - var sidebar = localStorage.getItem('mdbook-sidebar'); | |
62 | - | |
63 | - if (theme.startsWith('"') && theme.endsWith('"')) { | |
64 | - localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1)); | |
65 | - } | |
08170615 | 66 | - |
11ae32e0 XL |
67 | - if (sidebar.startsWith('"') && sidebar.endsWith('"')) { |
68 | - localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1)); | |
69 | - } | |
70 | - } catch (e) { } | |
71 | - </script> | |
b6515096 | 72 | - |
f9f51dbf XL |
73 | - <!-- Set the theme before any content is loaded, prevents flash --> |
74 | - <script type="text/javascript"> | |
11ae32e0 | 75 | - var theme; |
e860a474 | 76 | - try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } |
b6515096 | 77 | - if (theme === null || theme === undefined) { theme = default_theme; } |
46f4175b XL |
78 | - var html = document.querySelector('html'); |
79 | - html.classList.remove('no-js') | |
80 | - html.classList.remove('{{ default_theme }}') | |
81 | - html.classList.add(theme); | |
82 | - html.classList.add('js'); | |
f9f51dbf XL |
83 | - </script> |
84 | - | |
85 | - <!-- Hide / unhide sidebar before it is displayed --> | |
86 | - <script type="text/javascript"> | |
08170615 | 87 | - var html = document.querySelector('html'); |
11ae32e0 XL |
88 | - var sidebar = 'hidden'; |
89 | - if (document.body.clientWidth >= 1080) { | |
90 | - try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { } | |
91 | - sidebar = sidebar || 'visible'; | |
92 | - } | |
08170615 XL |
93 | - html.classList.remove('sidebar-visible'); |
94 | - html.classList.add("sidebar-" + sidebar); | |
f9f51dbf | 95 | - </script> |
b6515096 | 96 | - |
11ae32e0 | 97 | <nav id="sidebar" class="sidebar" aria-label="Table of contents"> |
dc505b00 | 98 | <div class="sidebar-scrollbox"> |
e860a474 | 99 | {{#toc}}{{/toc}} |
47372d83 | 100 | @@ -230,52 +187,6 @@ |
11ae32e0 XL |
101 | </script> |
102 | {{/if}} | |
91546fe7 | 103 | |
f9f51dbf | 104 | - {{#if google_analytics}} |
11ae32e0 | 105 | - <!-- Google Analytics Tag --> |
08170615 | 106 | - <script type="text/javascript"> |
11ae32e0 | 107 | - var localAddrs = ["localhost", "127.0.0.1", ""]; |
b6515096 | 108 | - |
11ae32e0 XL |
109 | - // make sure we don't activate google analytics if the developer is |
110 | - // inspecting the book locally... | |
111 | - if (localAddrs.indexOf(document.location.hostname) === -1) { | |
112 | - (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ | |
113 | - (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), | |
114 | - m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) | |
115 | - })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); | |
f9f51dbf | 116 | - |
11ae32e0 XL |
117 | - ga('create', '{{google_analytics}}', 'auto'); |
118 | - ga('send', 'pageview'); | |
119 | - } | |
f9f51dbf | 120 | - </script> |
f9f51dbf | 121 | - {{/if}} |
b6515096 | 122 | - |
4a099bab | 123 | - {{#if playground_line_numbers}} |
46f4175b | 124 | - <script type="text/javascript"> |
4a099bab | 125 | - window.playground_line_numbers = true; |
46f4175b XL |
126 | - </script> |
127 | - {{/if}} | |
4a099bab XL |
128 | - |
129 | - {{#if playground_copyable}} | |
46f4175b | 130 | - <script type="text/javascript"> |
4a099bab | 131 | - window.playground_copyable = true; |
46f4175b XL |
132 | - </script> |
133 | - {{/if}} | |
134 | - | |
4a099bab | 135 | - {{#if playground_js}} |
b6515096 XL |
136 | - <script src="{{ path_to_root }}ace.js" type="text/javascript" charset="utf-8"></script> |
137 | - <script src="{{ path_to_root }}editor.js" type="text/javascript" charset="utf-8"></script> | |
138 | - <script src="{{ path_to_root }}mode-rust.js" type="text/javascript" charset="utf-8"></script> | |
139 | - <script src="{{ path_to_root }}theme-dawn.js" type="text/javascript" charset="utf-8"></script> | |
140 | - <script src="{{ path_to_root }}theme-tomorrow_night.js" type="text/javascript" charset="utf-8"></script> | |
08170615 XL |
141 | - {{/if}} |
142 | - | |
08170615 | 143 | - {{#if search_js}} |
b6515096 XL |
144 | - <script src="{{ path_to_root }}elasticlunr.min.js" type="text/javascript" charset="utf-8"></script> |
145 | - <script src="{{ path_to_root }}mark.min.js" type="text/javascript" charset="utf-8"></script> | |
146 | - <script src="{{ path_to_root }}searcher.js" type="text/javascript" charset="utf-8"></script> | |
08170615 | 147 | - {{/if}} |
b6515096 XL |
148 | - |
149 | - <script src="{{ path_to_root }}clipboard.min.js" type="text/javascript" charset="utf-8"></script> | |
47372d83 | 150 | <script src="{{ path_to_root }}highlight.js" type="text/javascript" charset="utf-8"></script> |
b6515096 | 151 | <script src="{{ path_to_root }}book.js" type="text/javascript" charset="utf-8"></script> |
08170615 | 152 | |
47372d83 XL |
153 | --- a/vendor/mdbook/src/book/init.rs |
154 | +++ b/vendor/mdbook/src/book/init.rs | |
155 | @@ -151,12 +151,6 @@ | |
4a099bab XL |
156 | let mut js = File::create(themedir.join("book.js"))?; |
157 | js.write_all(theme::JS)?; | |
158 | ||
159 | - let mut highlight_css = File::create(themedir.join("highlight.css"))?; | |
160 | - highlight_css.write_all(theme::HIGHLIGHT_CSS)?; | |
161 | - | |
162 | - let mut highlight_js = File::create(themedir.join("highlight.js"))?; | |
163 | - highlight_js.write_all(theme::HIGHLIGHT_JS)?; | |
164 | - | |
165 | Ok(()) | |
166 | } | |
167 | ||
47372d83 XL |
168 | --- a/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs |
169 | +++ b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs | |
170 | @@ -3,7 +3,7 @@ | |
4a099bab XL |
171 | use crate::errors::*; |
172 | use crate::renderer::html_handlebars::helpers; | |
173 | use crate::renderer::{RenderContext, Renderer}; | |
174 | -use crate::theme::{self, playground_editor, Theme}; | |
175 | +use crate::theme::{self, Theme}; | |
176 | use crate::utils; | |
177 | ||
178 | use std::borrow::Cow; | |
47372d83 XL |
179 | @@ -11,6 +11,7 @@ |
180 | use std::collections::HashMap; | |
181 | use std::fs::{self, File}; | |
182 | use std::path::{Path, PathBuf}; | |
183 | +use std::os::unix::fs::symlink; | |
184 | ||
185 | use crate::utils::fs::get_404_output_file; | |
186 | use handlebars::Handlebars; | |
187 | @@ -204,80 +205,13 @@ | |
3aade234 XL |
188 | if let Some(contents) = &theme.favicon_svg { |
189 | write_file(destination, "favicon.svg", &contents)?; | |
190 | } | |
4a099bab XL |
191 | - write_file(destination, "highlight.css", &theme.highlight_css)?; |
192 | write_file(destination, "tomorrow-night.css", &theme.tomorrow_night_css)?; | |
193 | write_file(destination, "ayu-highlight.css", &theme.ayu_highlight_css)?; | |
194 | - write_file(destination, "highlight.js", &theme.highlight_js)?; | |
195 | - write_file(destination, "clipboard.min.js", &theme.clipboard_js)?; | |
196 | - write_file( | |
197 | - destination, | |
198 | - "FontAwesome/css/font-awesome.css", | |
199 | - theme::FONT_AWESOME, | |
200 | - )?; | |
201 | - write_file( | |
202 | - destination, | |
203 | - "FontAwesome/fonts/fontawesome-webfont.eot", | |
204 | - theme::FONT_AWESOME_EOT, | |
205 | - )?; | |
206 | - write_file( | |
207 | - destination, | |
208 | - "FontAwesome/fonts/fontawesome-webfont.svg", | |
209 | - theme::FONT_AWESOME_SVG, | |
210 | - )?; | |
211 | - write_file( | |
212 | - destination, | |
213 | - "FontAwesome/fonts/fontawesome-webfont.ttf", | |
214 | - theme::FONT_AWESOME_TTF, | |
215 | - )?; | |
216 | - write_file( | |
217 | - destination, | |
218 | - "FontAwesome/fonts/fontawesome-webfont.woff", | |
219 | - theme::FONT_AWESOME_WOFF, | |
220 | - )?; | |
221 | - write_file( | |
222 | - destination, | |
223 | - "FontAwesome/fonts/fontawesome-webfont.woff2", | |
224 | - theme::FONT_AWESOME_WOFF2, | |
225 | - )?; | |
226 | - write_file( | |
227 | - destination, | |
228 | - "FontAwesome/fonts/FontAwesome.ttf", | |
229 | - theme::FONT_AWESOME_TTF, | |
230 | - )?; | |
231 | - if html_config.copy_fonts { | |
232 | - write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?; | |
233 | - for (file_name, contents) in theme::fonts::LICENSES.iter() { | |
234 | - write_file(destination, file_name, contents)?; | |
235 | - } | |
236 | - for (file_name, contents) in theme::fonts::OPEN_SANS.iter() { | |
237 | - write_file(destination, file_name, contents)?; | |
238 | - } | |
239 | - write_file( | |
240 | - destination, | |
241 | - theme::fonts::SOURCE_CODE_PRO.0, | |
242 | - theme::fonts::SOURCE_CODE_PRO.1, | |
243 | - )?; | |
244 | - } | |
245 | - | |
246 | - let playground_config = &html_config.playground; | |
247 | - | |
248 | - // Ace is a very large dependency, so only load it when requested | |
249 | - if playground_config.editable && playground_config.copy_js { | |
250 | - // Load the editor | |
251 | - write_file(destination, "editor.js", playground_editor::JS)?; | |
252 | - write_file(destination, "ace.js", playground_editor::ACE_JS)?; | |
253 | - write_file(destination, "mode-rust.js", playground_editor::MODE_RUST_JS)?; | |
254 | - write_file( | |
255 | - destination, | |
256 | - "theme-dawn.js", | |
257 | - playground_editor::THEME_DAWN_JS, | |
258 | - )?; | |
259 | - write_file( | |
260 | - destination, | |
261 | - "theme-tomorrow_night.js", | |
262 | - playground_editor::THEME_TOMORROW_NIGHT_JS, | |
263 | - )?; | |
264 | - } | |
47372d83 XL |
265 | + symlink("/usr/share/fonts-font-awesome/css/font-awesome.min.css", destination.join("css/font-awesome.min.css"))?; |
266 | + symlink("/usr/share/fonts-font-awesome/fonts", destination.join("fonts"))?; | |
267 | + symlink("/usr/share/javascript/highlight.js/styles/atelier-dune-light.css", destination.join("highlight.css"))?; | |
268 | + symlink("/usr/share/javascript/highlight.js/highlight.js", destination.join("highlight.js"))?; | |
269 | + symlink("/usr/share/javascript/mathjax/MathJax.js", destination.join("MathJax.js"))?; | |
4a099bab XL |
270 | |
271 | Ok(()) | |
272 | } | |
47372d83 XL |
273 | --- a/vendor/mdbook/src/renderer/html_handlebars/search.rs |
274 | +++ b/vendor/mdbook/src/renderer/html_handlebars/search.rs | |
275 | @@ -34,8 +34,6 @@ | |
4a099bab XL |
276 | format!("Object.assign(window.search, {});", index).as_bytes(), |
277 | )?; | |
278 | utils::fs::write_file(destination, "searcher.js", searcher::JS)?; | |
279 | - utils::fs::write_file(destination, "mark.min.js", searcher::MARK_JS)?; | |
280 | - utils::fs::write_file(destination, "elasticlunr.min.js", searcher::ELASTICLUNR_JS)?; | |
281 | debug!("Copying search files ✓"); | |
282 | } | |
283 | ||
47372d83 XL |
284 | --- a/vendor/mdbook/src/theme/mod.rs |
285 | +++ b/vendor/mdbook/src/theme/mod.rs | |
4a099bab | 286 | @@ -1,9 +1,5 @@ |
08170615 XL |
287 | #![allow(missing_docs)] |
288 | ||
4a099bab XL |
289 | -pub mod playground_editor; |
290 | - | |
291 | -pub mod fonts; | |
f9f51dbf | 292 | - |
08170615 XL |
293 | #[cfg(feature = "search")] |
294 | pub mod searcher; | |
295 | ||
47372d83 | 296 | @@ -24,19 +20,8 @@ |
4a099bab XL |
297 | pub static FAVICON_PNG: &[u8] = include_bytes!("favicon.png"); |
298 | pub static FAVICON_SVG: &[u8] = include_bytes!("favicon.svg"); | |
e860a474 XL |
299 | pub static JS: &[u8] = include_bytes!("book.js"); |
300 | -pub static HIGHLIGHT_JS: &[u8] = include_bytes!("highlight.js"); | |
301 | pub static TOMORROW_NIGHT_CSS: &[u8] = include_bytes!("tomorrow-night.css"); | |
302 | -pub static HIGHLIGHT_CSS: &[u8] = include_bytes!("highlight.css"); | |
303 | pub static AYU_HIGHLIGHT_CSS: &[u8] = include_bytes!("ayu-highlight.css"); | |
304 | -pub static CLIPBOARD_JS: &[u8] = include_bytes!("clipboard.min.js"); | |
305 | -pub static FONT_AWESOME: &[u8] = include_bytes!("FontAwesome/css/font-awesome.min.css"); | |
306 | -pub static FONT_AWESOME_EOT: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.eot"); | |
307 | -pub static FONT_AWESOME_SVG: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.svg"); | |
308 | -pub static FONT_AWESOME_TTF: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.ttf"); | |
309 | -pub static FONT_AWESOME_WOFF: &[u8] = include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff"); | |
310 | -pub static FONT_AWESOME_WOFF2: &[u8] = | |
b6515096 | 311 | - include_bytes!("FontAwesome/fonts/fontawesome-webfont.woff2"); |
e860a474 | 312 | -pub static FONT_AWESOME_OTF: &[u8] = include_bytes!("FontAwesome/fonts/FontAwesome.otf"); |
f9f51dbf XL |
313 | |
314 | /// The `Theme` struct should be used instead of the static variables because | |
b6515096 | 315 | /// the `new()` method will look if the user has a theme directory in their |
47372d83 | 316 | @@ -57,11 +42,8 @@ |
3aade234 XL |
317 | pub favicon_png: Option<Vec<u8>>, |
318 | pub favicon_svg: Option<Vec<u8>>, | |
f9f51dbf XL |
319 | pub js: Vec<u8>, |
320 | - pub highlight_css: Vec<u8>, | |
321 | pub tomorrow_night_css: Vec<u8>, | |
322 | pub ayu_highlight_css: Vec<u8>, | |
323 | - pub highlight_js: Vec<u8>, | |
324 | - pub clipboard_js: Vec<u8>, | |
f9f51dbf XL |
325 | } |
326 | ||
327 | impl Theme { | |
47372d83 | 328 | @@ -91,9 +73,6 @@ |
3aade234 XL |
329 | theme_dir.join("css/variables.css"), |
330 | &mut theme.variables_css, | |
b6515096 | 331 | ), |
f9f51dbf XL |
332 | - (theme_dir.join("highlight.js"), &mut theme.highlight_js), |
333 | - (theme_dir.join("clipboard.min.js"), &mut theme.clipboard_js), | |
f9f51dbf | 334 | - (theme_dir.join("highlight.css"), &mut theme.highlight_css), |
b6515096 XL |
335 | ( |
336 | theme_dir.join("tomorrow-night.css"), | |
337 | &mut theme.tomorrow_night_css, | |
47372d83 | 338 | @@ -156,11 +135,8 @@ |
3aade234 XL |
339 | favicon_png: Some(FAVICON_PNG.to_owned()), |
340 | favicon_svg: Some(FAVICON_SVG.to_owned()), | |
f9f51dbf XL |
341 | js: JS.to_owned(), |
342 | - highlight_css: HIGHLIGHT_CSS.to_owned(), | |
343 | tomorrow_night_css: TOMORROW_NIGHT_CSS.to_owned(), | |
344 | ayu_highlight_css: AYU_HIGHLIGHT_CSS.to_owned(), | |
345 | - highlight_js: HIGHLIGHT_JS.to_owned(), | |
346 | - clipboard_js: CLIPBOARD_JS.to_owned(), | |
f9f51dbf XL |
347 | } |
348 | } | |
349 | } | |
47372d83 | 350 | @@ -243,11 +219,8 @@ |
3aade234 XL |
351 | favicon_png: Some(Vec::new()), |
352 | favicon_svg: Some(Vec::new()), | |
d5fa6b7e XL |
353 | js: Vec::new(), |
354 | - highlight_css: Vec::new(), | |
f9f51dbf XL |
355 | tomorrow_night_css: Vec::new(), |
356 | ayu_highlight_css: Vec::new(), | |
d5fa6b7e | 357 | - highlight_js: Vec::new(), |
f9f51dbf | 358 | - clipboard_js: Vec::new(), |
f9f51dbf XL |
359 | }; |
360 | ||
361 | assert_eq!(got, empty); | |
47372d83 XL |
362 | --- a/vendor/mdbook/src/theme/searcher/mod.rs |
363 | +++ b/vendor/mdbook/src/theme/searcher/mod.rs | |
08170615 XL |
364 | @@ -2,5 +2,3 @@ |
365 | //! the "search" cargo feature is disabled. | |
366 | ||
e860a474 XL |
367 | pub static JS: &[u8] = include_bytes!("searcher.js"); |
368 | -pub static MARK_JS: &[u8] = include_bytes!("mark.min.js"); | |
369 | -pub static ELASTICLUNR_JS: &[u8] = include_bytes!("elasticlunr.min.js"); |