From 0303629bfd9a542d63de3b74f13fdd54ae3a2d03 Mon Sep 17 00:00:00 2001 From: Matthijs van Otterdijk Date: Sat, 29 Aug 2020 16:54:36 +0100 Subject: [PATCH] Use local web resources instead of remote ones Bug: https://github.com/azerupi/mdBook/issues/271 Comment: Use https://github.com/infinity0/mdBook/tree/debian to help you rebase the patch on top of a newer version. . Make sure the paths here match the ones in debian/rust-doc.links Comment: Use https://github.com/infinity0/mdBook/tree/debian to help you rebase the patch on top of a newer version. . Make sure the paths here match the ones in debian/rust-doc.links Gbp-Pq: Name d-0003-mdbook-strip-embedded-libs.patch --- src/tools/linkchecker/main.rs | 5 + vendor/mdbook/src/book/init.rs | 6 -- .../renderer/html_handlebars/hbs_renderer.rs | 76 +-------------- .../src/renderer/html_handlebars/search.rs | 2 - vendor/mdbook/src/theme/index.hbs | 97 +------------------ vendor/mdbook/src/theme/mod.rs | 27 ------ vendor/mdbook/src/theme/searcher/mod.rs | 2 - 7 files changed, 11 insertions(+), 204 deletions(-) diff --git a/src/tools/linkchecker/main.rs b/src/tools/linkchecker/main.rs index 74601f9e4c..b8976490cf 100644 --- a/src/tools/linkchecker/main.rs +++ b/src/tools/linkchecker/main.rs @@ -161,6 +161,11 @@ fn check(cache: &mut Cache, root: &Path, file: &Path, errors: &mut bool) -> Opti { return; } + // Ignore parent URLs, so that the package installation process can + // provide a symbolic link later + if url.starts_with("../") { + return; + } let mut parts = url.splitn(2, "#"); let url = parts.next().unwrap(); let fragment = parts.next(); diff --git a/vendor/mdbook/src/book/init.rs b/vendor/mdbook/src/book/init.rs index 7ae00b65a2..0419f7f9eb 100644 --- a/vendor/mdbook/src/book/init.rs +++ b/vendor/mdbook/src/book/init.rs @@ -151,12 +151,6 @@ impl BookBuilder { let mut js = File::create(themedir.join("book.js"))?; js.write_all(theme::JS)?; - let mut highlight_css = File::create(themedir.join("highlight.css"))?; - highlight_css.write_all(theme::HIGHLIGHT_CSS)?; - - let mut highlight_js = File::create(themedir.join("highlight.js"))?; - highlight_js.write_all(theme::HIGHLIGHT_JS)?; - Ok(()) } diff --git a/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs index 4bf89e9538..b6a34ead25 100644 --- a/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs +++ b/vendor/mdbook/src/renderer/html_handlebars/hbs_renderer.rs @@ -3,7 +3,7 @@ use crate::config::{Config, HtmlConfig, Playground, RustEdition}; use crate::errors::*; use crate::renderer::html_handlebars::helpers; use crate::renderer::{RenderContext, Renderer}; -use crate::theme::{self, playground_editor, Theme}; +use crate::theme::{self, Theme}; use crate::utils; use std::borrow::Cow; @@ -177,7 +177,7 @@ impl HtmlHandlebars { &self, destination: &Path, theme: &Theme, - html_config: &HtmlConfig, + _html_config: &HtmlConfig, ) -> Result<()> { use crate::utils::fs::write_file; @@ -194,80 +194,8 @@ impl HtmlHandlebars { write_file(destination, "css/variables.css", &theme.variables_css)?; write_file(destination, "favicon.png", &theme.favicon_png)?; write_file(destination, "favicon.svg", &theme.favicon_svg)?; - write_file(destination, "highlight.css", &theme.highlight_css)?; write_file(destination, "tomorrow-night.css", &theme.tomorrow_night_css)?; write_file(destination, "ayu-highlight.css", &theme.ayu_highlight_css)?; - write_file(destination, "highlight.js", &theme.highlight_js)?; - write_file(destination, "clipboard.min.js", &theme.clipboard_js)?; - write_file( - destination, - "FontAwesome/css/font-awesome.css", - theme::FONT_AWESOME, - )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.eot", - theme::FONT_AWESOME_EOT, - )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.svg", - theme::FONT_AWESOME_SVG, - )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.ttf", - theme::FONT_AWESOME_TTF, - )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.woff", - theme::FONT_AWESOME_WOFF, - )?; - write_file( - destination, - "FontAwesome/fonts/fontawesome-webfont.woff2", - theme::FONT_AWESOME_WOFF2, - )?; - write_file( - destination, - "FontAwesome/fonts/FontAwesome.ttf", - theme::FONT_AWESOME_TTF, - )?; - if html_config.copy_fonts { - write_file(destination, "fonts/fonts.css", theme::fonts::CSS)?; - for (file_name, contents) in theme::fonts::LICENSES.iter() { - write_file(destination, file_name, contents)?; - } - for (file_name, contents) in theme::fonts::OPEN_SANS.iter() { - write_file(destination, file_name, contents)?; - } - write_file( - destination, - theme::fonts::SOURCE_CODE_PRO.0, - theme::fonts::SOURCE_CODE_PRO.1, - )?; - } - - let playground_config = &html_config.playground; - - // Ace is a very large dependency, so only load it when requested - if playground_config.editable && playground_config.copy_js { - // Load the editor - write_file(destination, "editor.js", playground_editor::JS)?; - write_file(destination, "ace.js", playground_editor::ACE_JS)?; - write_file(destination, "mode-rust.js", playground_editor::MODE_RUST_JS)?; - write_file( - destination, - "theme-dawn.js", - playground_editor::THEME_DAWN_JS, - )?; - write_file( - destination, - "theme-tomorrow_night.js", - playground_editor::THEME_TOMORROW_NIGHT_JS, - )?; - } Ok(()) } diff --git a/vendor/mdbook/src/renderer/html_handlebars/search.rs b/vendor/mdbook/src/renderer/html_handlebars/search.rs index 597bd9408c..6cb9741e16 100644 --- a/vendor/mdbook/src/renderer/html_handlebars/search.rs +++ b/vendor/mdbook/src/renderer/html_handlebars/search.rs @@ -34,8 +34,6 @@ pub fn create_files(search_config: &Search, destination: &Path, book: &Book) -> format!("Object.assign(window.search, {});", index).as_bytes(), )?; utils::fs::write_file(destination, "searcher.js", searcher::JS)?; - utils::fs::write_file(destination, "mark.min.js", searcher::MARK_JS)?; - utils::fs::write_file(destination, "elasticlunr.min.js", searcher::ELASTICLUNR_JS)?; debug!("Copying search files ✓"); } diff --git a/vendor/mdbook/src/theme/index.hbs b/vendor/mdbook/src/theme/index.hbs index f9d3c5aa35..14e2dcd1bf 100644 --- a/vendor/mdbook/src/theme/index.hbs +++ b/vendor/mdbook/src/theme/index.hbs @@ -28,13 +28,10 @@ - - {{#if copy_fonts}} - - {{/if}} + - + @@ -45,7 +42,7 @@ {{#if mathjax_support}} - + {{/if}} @@ -55,46 +52,6 @@ var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "{{ preferred_dark_theme }}" : "{{ default_theme }}"; - - - - - - - - -