]>
git.proxmox.com Git - rustc.git/blob - src/vendor/mdbook/src/theme/mod.rs
6 pub static INDEX
: &'
static [u8] = include_bytes
!("index.hbs");
7 pub static CSS
: &'
static [u8] = include_bytes
!("book.css");
8 pub static FAVICON
: &'
static [u8] = include_bytes
!("favicon.png");
9 pub static JS
: &'
static [u8] = include_bytes
!("book.js");
10 pub static HIGHLIGHT_JS
: &'
static [u8] = include_bytes
!("highlight.js");
11 pub static TOMORROW_NIGHT_CSS
: &'
static [u8] = include_bytes
!("tomorrow-night.css");
12 pub static HIGHLIGHT_CSS
: &'
static [u8] = include_bytes
!("highlight.css");
13 pub static JQUERY
: &'
static [u8] = include_bytes
!("jquery-2.1.4.min.js");
14 pub static FONT_AWESOME
: &'
static [u8] = include_bytes
!("_FontAwesome/css/font-awesome.min.css");
15 pub static FONT_AWESOME_EOT
: &'
static [u8] = include_bytes
!("_FontAwesome/fonts/fontawesome-webfont.eot");
16 pub static FONT_AWESOME_SVG
: &'
static [u8] = include_bytes
!("_FontAwesome/fonts/fontawesome-webfont.svg");
17 pub static FONT_AWESOME_TTF
: &'
static [u8] = include_bytes
!("_FontAwesome/fonts/fontawesome-webfont.ttf");
18 pub static FONT_AWESOME_WOFF
: &'
static [u8] = include_bytes
!("_FontAwesome/fonts/fontawesome-webfont.woff");
19 pub static FONT_AWESOME_WOFF2
: &'
static [u8] = include_bytes
!("_FontAwesome/fonts/fontawesome-webfont.woff2");
20 pub static FONT_AWESOME_OTF
: &'
static [u8] = include_bytes
!("_FontAwesome/fonts/FontAwesome.otf");
22 /// The `Theme` struct should be used instead of the static variables because the `new()` method
23 /// will look if the user has a theme directory in his source folder and use the users theme instead
26 /// You should exceptionnaly use the static variables only if you need the default theme even if the
27 /// user has specified another theme.
33 pub highlight_css
: Vec
<u8>,
34 pub tomorrow_night_css
: Vec
<u8>,
35 pub highlight_js
: Vec
<u8>,
40 pub fn new(src
: &Path
) -> Self {
43 let mut theme
= Theme
{
44 index
: INDEX
.to_owned(),
46 favicon
: FAVICON
.to_owned(),
48 highlight_css
: HIGHLIGHT_CSS
.to_owned(),
49 tomorrow_night_css
: TOMORROW_NIGHT_CSS
.to_owned(),
50 highlight_js
: HIGHLIGHT_JS
.to_owned(),
51 jquery
: JQUERY
.to_owned(),
54 // Check if the given path exists
55 if !src
.exists() || !src
.is_dir() {
59 // Check for individual files if they exist
62 if let Ok(mut f
) = File
::open(&src
.join("index.hbs")) {
63 theme
.index
.clear(); // Reset the value, because read_to_string appends...
64 let _
= f
.read_to_end(&mut theme
.index
);
68 if let Ok(mut f
) = File
::open(&src
.join("book.js")) {
70 let _
= f
.read_to_end(&mut theme
.js
);
74 if let Ok(mut f
) = File
::open(&src
.join("book.css")) {
76 let _
= f
.read_to_end(&mut theme
.css
);
80 if let Ok(mut f
) = File
::open(&src
.join("favicon.png")) {
81 theme
.favicon
.clear();
82 let _
= f
.read_to_end(&mut theme
.favicon
);
86 if let Ok(mut f
) = File
::open(&src
.join("highlight.js")) {
87 theme
.highlight_js
.clear();
88 let _
= f
.read_to_end(&mut theme
.highlight_js
);
92 if let Ok(mut f
) = File
::open(&src
.join("highlight.css")) {
93 theme
.highlight_css
.clear();
94 let _
= f
.read_to_end(&mut theme
.highlight_css
);
98 if let Ok(mut f
) = File
::open(&src
.join("tomorrow-night.css")) {
99 theme
.tomorrow_night_css
.clear();
100 let _
= f
.read_to_end(&mut theme
.tomorrow_night_css
);