Local fallback for jquery #46
This commit is contained in:
parent
754773f857
commit
95dfff008c
|
@ -0,0 +1 @@
|
||||||
|
# Contributors
|
|
@ -156,6 +156,10 @@ impl Renderer for HtmlHandlebars {
|
||||||
let mut css_file = try!(File::create(book.get_dest().join("book.css")));
|
let mut css_file = try!(File::create(book.get_dest().join("book.css")));
|
||||||
try!(css_file.write_all(&theme.css));
|
try!(css_file.write_all(&theme.css));
|
||||||
|
|
||||||
|
// JQuery
|
||||||
|
let mut jquery = try!(File::create(book.get_dest().join("jquery.js")));
|
||||||
|
try!(jquery.write_all(&theme.jquery));
|
||||||
|
|
||||||
// syntax highlighting
|
// syntax highlighting
|
||||||
let mut highlight_css = try!(File::create(book.get_dest().join("highlight.css")));
|
let mut highlight_css = try!(File::create(book.get_dest().join("highlight.css")));
|
||||||
try!(highlight_css.write_all(&theme.highlight_css));
|
try!(highlight_css.write_all(&theme.highlight_css));
|
||||||
|
|
|
@ -71,7 +71,14 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Fetch JQuery from CDN but have a local fallback -->
|
||||||
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
|
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
|
||||||
|
<script>
|
||||||
|
if (typeof jQuery == 'undefined') {
|
||||||
|
document.write(unescape("%3Cscript src='jquery.js'%3E%3C/script%3E"));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
<script src="highlight.js"></script>
|
<script src="highlight.js"></script>
|
||||||
<script src="book.js"></script>
|
<script src="book.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -9,6 +9,7 @@ pub static CSS: &'static [u8] = include_bytes!("book.css");
|
||||||
pub static JS: &'static [u8] = include_bytes!("book.js");
|
pub static JS: &'static [u8] = include_bytes!("book.js");
|
||||||
pub static HIGHLIGHT_JS: &'static [u8] = include_bytes!("highlight.js");
|
pub static HIGHLIGHT_JS: &'static [u8] = include_bytes!("highlight.js");
|
||||||
pub static HIGHLIGHT_CSS: &'static [u8] = include_bytes!("highlight.css");
|
pub static HIGHLIGHT_CSS: &'static [u8] = include_bytes!("highlight.css");
|
||||||
|
pub static JQUERY: &'static [u8] = include_bytes!("jquery-2.1.4.min.js");
|
||||||
|
|
||||||
/// The `Theme` struct should be used instead of the static variables because the `new()` method
|
/// The `Theme` struct should be used instead of the static variables because the `new()` method
|
||||||
/// will look if the user has a theme directory in his source folder and use the users theme instead
|
/// will look if the user has a theme directory in his source folder and use the users theme instead
|
||||||
|
@ -22,6 +23,7 @@ pub struct Theme {
|
||||||
pub js: Vec<u8>,
|
pub js: Vec<u8>,
|
||||||
pub highlight_css: Vec<u8>,
|
pub highlight_css: Vec<u8>,
|
||||||
pub highlight_js: Vec<u8>,
|
pub highlight_js: Vec<u8>,
|
||||||
|
pub jquery: Vec<u8>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Theme {
|
impl Theme {
|
||||||
|
@ -34,6 +36,7 @@ impl Theme {
|
||||||
js: JS.to_owned(),
|
js: JS.to_owned(),
|
||||||
highlight_css: HIGHLIGHT_CSS.to_owned(),
|
highlight_css: HIGHLIGHT_CSS.to_owned(),
|
||||||
highlight_js: HIGHLIGHT_JS.to_owned(),
|
highlight_js: HIGHLIGHT_JS.to_owned(),
|
||||||
|
jquery: JQUERY.to_owned(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Check if the given path exists
|
// Check if the given path exists
|
||||||
|
|
Loading…
Reference in New Issue