mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 06:42:35 +00:00
Update all dependencies to latest version
This commit is contained in:
parent
9c8a563223
commit
5350d62591
3 changed files with 35 additions and 46 deletions
10
Cargo.toml
10
Cargo.toml
|
@ -16,9 +16,9 @@ exclude = [
|
|||
|
||||
[dependencies]
|
||||
clap = "2.2.1"
|
||||
handlebars = "0.16.0"
|
||||
handlebars = "0.20.0"
|
||||
rustc-serialize = "0.3.18"
|
||||
pulldown-cmark = "0.0.7"
|
||||
pulldown-cmark = "0.0.8"
|
||||
|
||||
# Watch feature
|
||||
notify = { version = "2.5.5", optional = true }
|
||||
|
@ -26,9 +26,9 @@ time = { version = "0.1.34", optional = true }
|
|||
crossbeam = { version = "0.2.8", optional = true }
|
||||
|
||||
# Serve feature
|
||||
iron = { version = "0.3", optional = true }
|
||||
staticfile = { version = "0.2", optional = true }
|
||||
ws = { version = "0.4.6", optional = true}
|
||||
iron = { version = "0.4", optional = true }
|
||||
staticfile = { version = "0.3", optional = true }
|
||||
ws = { version = "0.5.1", optional = true}
|
||||
|
||||
|
||||
# Tests
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::error::Error;
|
|||
use std::io::{self, Read, Write};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use handlebars::{Handlebars, JsonRender};
|
||||
use handlebars::Handlebars;
|
||||
use rustc_serialize::json::{Json, ToJson};
|
||||
|
||||
|
||||
|
@ -57,7 +57,8 @@ impl Renderer for HtmlHandlebars {
|
|||
for item in book.iter() {
|
||||
|
||||
match *item {
|
||||
BookItem::Chapter(_, ref ch) | BookItem::Affix(ref ch) => {
|
||||
BookItem::Chapter(_, ref ch) |
|
||||
BookItem::Affix(ref ch) => {
|
||||
if ch.path != PathBuf::new() {
|
||||
|
||||
let path = book.get_src().join(&ch.path);
|
||||
|
@ -105,7 +106,8 @@ impl Renderer for HtmlHandlebars {
|
|||
|
||||
debug!("[*]: Create file {:?}", &book.get_dest().join(&ch.path).with_extension("html"));
|
||||
// Write to file
|
||||
let mut file = try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html")));
|
||||
let mut file =
|
||||
try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html")));
|
||||
output!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html"));
|
||||
|
||||
try!(file.write_all(&rendered.into_bytes()));
|
||||
|
@ -117,14 +119,14 @@ impl Renderer for HtmlHandlebars {
|
|||
let mut index_file = try!(File::create(book.get_dest().join("index.html")));
|
||||
let mut content = String::new();
|
||||
let _source = try!(File::open(book.get_dest().join(&ch.path.with_extension("html"))))
|
||||
.read_to_string(&mut content);
|
||||
.read_to_string(&mut content);
|
||||
|
||||
// This could cause a problem when someone displays code containing <base href=...>
|
||||
// on the front page, however this case should be very very rare...
|
||||
content = content.lines()
|
||||
.filter(|line| !line.contains("<base href="))
|
||||
.collect::<Vec<&str>>()
|
||||
.join("\n");
|
||||
.filter(|line| !line.contains("<base href="))
|
||||
.collect::<Vec<&str>>()
|
||||
.join("\n");
|
||||
|
||||
try!(index_file.write_all(content.as_bytes()));
|
||||
|
||||
|
@ -218,54 +220,49 @@ impl Renderer for HtmlHandlebars {
|
|||
|
||||
// Font Awesome local fallback
|
||||
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
|
||||
.join("_FontAwesome/css/font-awesome.css")) {
|
||||
.join("_FontAwesome/css/font-awesome.css")) {
|
||||
f
|
||||
} else {
|
||||
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create font-awesome.css")));
|
||||
};
|
||||
try!(font_awesome.write_all(theme::FONT_AWESOME));
|
||||
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
|
||||
.join("_FontAwesome/fonts/fontawesome-webfon\
|
||||
t.eot")) {
|
||||
.join("_FontAwesome/fonts/fontawesome-webfont.eot")) {
|
||||
f
|
||||
} else {
|
||||
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.eot")));
|
||||
};
|
||||
try!(font_awesome.write_all(theme::FONT_AWESOME_EOT));
|
||||
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
|
||||
.join("_FontAwesome/fonts/fontawesome-webfon\
|
||||
t.svg")) {
|
||||
.join("_FontAwesome/fonts/fontawesome-webfont.svg")) {
|
||||
f
|
||||
} else {
|
||||
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.svg")));
|
||||
};
|
||||
try!(font_awesome.write_all(theme::FONT_AWESOME_SVG));
|
||||
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
|
||||
.join("_FontAwesome/fonts/fontawesome-webfon\
|
||||
t.ttf")) {
|
||||
.join("_FontAwesome/fonts/fontawesome-webfont.ttf")) {
|
||||
f
|
||||
} else {
|
||||
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.ttf")));
|
||||
};
|
||||
try!(font_awesome.write_all(theme::FONT_AWESOME_TTF));
|
||||
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
|
||||
.join("_FontAwesome/fonts/fontawesome-webfon\
|
||||
t.woff")) {
|
||||
.join("_FontAwesome/fonts/fontawesome-webfont.woff")) {
|
||||
f
|
||||
} else {
|
||||
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.woff")));
|
||||
};
|
||||
try!(font_awesome.write_all(theme::FONT_AWESOME_WOFF));
|
||||
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
|
||||
.join("_FontAwesome/fonts/fontawesome-webfon\
|
||||
t.woff2")) {
|
||||
.join("_FontAwesome/fonts/fontawesome-webfont.woff2")) {
|
||||
f
|
||||
} else {
|
||||
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.woff2")));
|
||||
};
|
||||
try!(font_awesome.write_all(theme::FONT_AWESOME_WOFF2));
|
||||
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
|
||||
.join("_FontAwesome/fonts/FontAwesome.ttf")) {
|
||||
.join("_FontAwesome/fonts/FontAwesome.ttf")) {
|
||||
f
|
||||
} else {
|
||||
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create FontAwesome.ttf")));
|
||||
|
|
|
@ -16,15 +16,15 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
|
|||
let chapters = c.navigate(rc.get_path(), "chapters");
|
||||
|
||||
let current = c.navigate(rc.get_path(), "path")
|
||||
.to_string()
|
||||
.replace("\"", "");
|
||||
.to_string()
|
||||
.replace("\"", "");
|
||||
|
||||
|
||||
debug!("[*]: Decode chapters from JSON");
|
||||
// Decode json format
|
||||
let decoded: Vec<BTreeMap<String, String>> = match json::decode(&chapters.to_string()) {
|
||||
Ok(data) => data,
|
||||
Err(_) => return Err(RenderError { desc: "Could not decode the JSON data".to_owned() }),
|
||||
Err(_) => return Err(RenderError::new("Could not decode the JSON data")),
|
||||
};
|
||||
let mut previous: Option<BTreeMap<String, String>> = None;
|
||||
|
||||
|
@ -52,7 +52,7 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
|
|||
},
|
||||
None => {
|
||||
debug!("[*]: No title found for chapter");
|
||||
return Err(RenderError { desc: "No title found for chapter in JSON data".to_owned() });
|
||||
return Err(RenderError::new("No title found for chapter in JSON data"));
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -68,16 +68,10 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
|
|||
Some(p) => {
|
||||
previous_chapter.insert("link".to_owned(), p.replace("\\", "/").to_json());
|
||||
},
|
||||
None => {
|
||||
return Err(RenderError {
|
||||
desc: "Link could not be converted to str".to_owned(),
|
||||
})
|
||||
},
|
||||
None => return Err(RenderError::new("Link could not be converted to str")),
|
||||
}
|
||||
},
|
||||
None => {
|
||||
return Err(RenderError { desc: "No path found for chapter in JSON data".to_owned() })
|
||||
},
|
||||
None => return Err(RenderError::new("No path found for chapter in JSON data")),
|
||||
}
|
||||
|
||||
debug!("[*]: Inject in context");
|
||||
|
@ -90,7 +84,7 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
|
|||
Some(t) => {
|
||||
try!(t.render(&updated_context, r, rc));
|
||||
},
|
||||
None => return Err(RenderError { desc: "Error with the handlebars template".to_owned() }),
|
||||
None => return Err(RenderError::new("Error with the handlebars template")),
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -122,14 +116,14 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
|
|||
let chapters = c.navigate(rc.get_path(), "chapters");
|
||||
|
||||
let current = c.navigate(rc.get_path(), "path")
|
||||
.to_string()
|
||||
.replace("\"", "");
|
||||
.to_string()
|
||||
.replace("\"", "");
|
||||
|
||||
debug!("[*]: Decode chapters from JSON");
|
||||
// Decode json format
|
||||
let decoded: Vec<BTreeMap<String, String>> = match json::decode(&chapters.to_string()) {
|
||||
Ok(data) => data,
|
||||
Err(_) => return Err(RenderError { desc: "Could not decode the JSON data".to_owned() }),
|
||||
Err(_) => return Err(RenderError::new("Could not decode the JSON data")),
|
||||
};
|
||||
let mut previous: Option<BTreeMap<String, String>> = None;
|
||||
|
||||
|
@ -145,7 +139,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
|
|||
|
||||
let previous_path = match previous.get("path") {
|
||||
Some(p) => p,
|
||||
None => return Err(RenderError { desc: "No path found for chapter in JSON data".to_owned() }),
|
||||
None => return Err(RenderError::new("No path found for chapter in JSON data")),
|
||||
};
|
||||
|
||||
if previous_path == ¤t {
|
||||
|
@ -160,9 +154,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
|
|||
debug!("[*]: Inserting title: {}", n);
|
||||
next_chapter.insert("title".to_owned(), n.to_json());
|
||||
},
|
||||
None => {
|
||||
return Err(RenderError { desc: "No title found for chapter in JSON data".to_owned() })
|
||||
},
|
||||
None => return Err(RenderError::new("No title found for chapter in JSON data")),
|
||||
}
|
||||
|
||||
|
||||
|
@ -174,7 +166,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
|
|||
// Hack for windows who tends to use `\` as separator instead of `/`
|
||||
next_chapter.insert("link".to_owned(), l.replace("\\", "/").to_json());
|
||||
},
|
||||
None => return Err(RenderError { desc: "Link could not converted to str".to_owned() }),
|
||||
None => return Err(RenderError::new("Link could not converted to str")),
|
||||
}
|
||||
|
||||
debug!("[*]: Inject in context");
|
||||
|
@ -188,7 +180,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
|
|||
Some(t) => {
|
||||
try!(t.render(&updated_context, r, rc));
|
||||
},
|
||||
None => return Err(RenderError { desc: "Error with the handlebars template".to_owned() }),
|
||||
None => return Err(RenderError::new("Error with the handlebars template")),
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue