Update all dependencies to latest version

This commit is contained in:
Mathieu David 2016-08-01 14:06:08 +02:00
parent 9c8a563223
commit 5350d62591
3 changed files with 35 additions and 46 deletions

View File

@ -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

View File

@ -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()));
@ -225,40 +227,35 @@ impl Renderer for HtmlHandlebars {
};
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")));

View File

@ -24,7 +24,7 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
// 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")),
}
}
@ -129,7 +123,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
// 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 == &current {
@ -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;