Skip to content

Commit 5350d62

Browse files
committed
Update all dependencies to latest version
1 parent 9c8a563 commit 5350d62

File tree

3 files changed

+35
-46
lines changed

3 files changed

+35
-46
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ exclude = [
1616

1717
[dependencies]
1818
clap = "2.2.1"
19-
handlebars = "0.16.0"
19+
handlebars = "0.20.0"
2020
rustc-serialize = "0.3.18"
21-
pulldown-cmark = "0.0.7"
21+
pulldown-cmark = "0.0.8"
2222

2323
# Watch feature
2424
notify = { version = "2.5.5", optional = true }
2525
time = { version = "0.1.34", optional = true }
2626
crossbeam = { version = "0.2.8", optional = true }
2727

2828
# Serve feature
29-
iron = { version = "0.3", optional = true }
30-
staticfile = { version = "0.2", optional = true }
31-
ws = { version = "0.4.6", optional = true}
29+
iron = { version = "0.4", optional = true }
30+
staticfile = { version = "0.3", optional = true }
31+
ws = { version = "0.5.1", optional = true}
3232

3333

3434
# Tests

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::error::Error;
1010
use std::io::{self, Read, Write};
1111
use std::collections::BTreeMap;
1212

13-
use handlebars::{Handlebars, JsonRender};
13+
use handlebars::Handlebars;
1414
use rustc_serialize::json::{Json, ToJson};
1515

1616

@@ -57,7 +57,8 @@ impl Renderer for HtmlHandlebars {
5757
for item in book.iter() {
5858

5959
match *item {
60-
BookItem::Chapter(_, ref ch) | BookItem::Affix(ref ch) => {
60+
BookItem::Chapter(_, ref ch) |
61+
BookItem::Affix(ref ch) => {
6162
if ch.path != PathBuf::new() {
6263

6364
let path = book.get_src().join(&ch.path);
@@ -105,7 +106,8 @@ impl Renderer for HtmlHandlebars {
105106

106107
debug!("[*]: Create file {:?}", &book.get_dest().join(&ch.path).with_extension("html"));
107108
// Write to file
108-
let mut file = try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html")));
109+
let mut file =
110+
try!(utils::fs::create_file(&book.get_dest().join(&ch.path).with_extension("html")));
109111
output!("[*] Creating {:?} ✓", &book.get_dest().join(&ch.path).with_extension("html"));
110112

111113
try!(file.write_all(&rendered.into_bytes()));
@@ -117,14 +119,14 @@ impl Renderer for HtmlHandlebars {
117119
let mut index_file = try!(File::create(book.get_dest().join("index.html")));
118120
let mut content = String::new();
119121
let _source = try!(File::open(book.get_dest().join(&ch.path.with_extension("html"))))
120-
.read_to_string(&mut content);
122+
.read_to_string(&mut content);
121123

122124
// This could cause a problem when someone displays code containing <base href=...>
123125
// on the front page, however this case should be very very rare...
124126
content = content.lines()
125-
.filter(|line| !line.contains("<base href="))
126-
.collect::<Vec<&str>>()
127-
.join("\n");
127+
.filter(|line| !line.contains("<base href="))
128+
.collect::<Vec<&str>>()
129+
.join("\n");
128130

129131
try!(index_file.write_all(content.as_bytes()));
130132

@@ -218,54 +220,49 @@ impl Renderer for HtmlHandlebars {
218220

219221
// Font Awesome local fallback
220222
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
221-
.join("_FontAwesome/css/font-awesome.css")) {
223+
.join("_FontAwesome/css/font-awesome.css")) {
222224
f
223225
} else {
224226
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create font-awesome.css")));
225227
};
226228
try!(font_awesome.write_all(theme::FONT_AWESOME));
227229
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
228-
.join("_FontAwesome/fonts/fontawesome-webfon\
229-
t.eot")) {
230+
.join("_FontAwesome/fonts/fontawesome-webfont.eot")) {
230231
f
231232
} else {
232233
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.eot")));
233234
};
234235
try!(font_awesome.write_all(theme::FONT_AWESOME_EOT));
235236
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
236-
.join("_FontAwesome/fonts/fontawesome-webfon\
237-
t.svg")) {
237+
.join("_FontAwesome/fonts/fontawesome-webfont.svg")) {
238238
f
239239
} else {
240240
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.svg")));
241241
};
242242
try!(font_awesome.write_all(theme::FONT_AWESOME_SVG));
243243
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
244-
.join("_FontAwesome/fonts/fontawesome-webfon\
245-
t.ttf")) {
244+
.join("_FontAwesome/fonts/fontawesome-webfont.ttf")) {
246245
f
247246
} else {
248247
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.ttf")));
249248
};
250249
try!(font_awesome.write_all(theme::FONT_AWESOME_TTF));
251250
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
252-
.join("_FontAwesome/fonts/fontawesome-webfon\
253-
t.woff")) {
251+
.join("_FontAwesome/fonts/fontawesome-webfont.woff")) {
254252
f
255253
} else {
256254
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.woff")));
257255
};
258256
try!(font_awesome.write_all(theme::FONT_AWESOME_WOFF));
259257
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
260-
.join("_FontAwesome/fonts/fontawesome-webfon\
261-
t.woff2")) {
258+
.join("_FontAwesome/fonts/fontawesome-webfont.woff2")) {
262259
f
263260
} else {
264261
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create fontawesome-webfont.woff2")));
265262
};
266263
try!(font_awesome.write_all(theme::FONT_AWESOME_WOFF2));
267264
let mut font_awesome = if let Ok(f) = utils::fs::create_file(&book.get_dest()
268-
.join("_FontAwesome/fonts/FontAwesome.ttf")) {
265+
.join("_FontAwesome/fonts/FontAwesome.ttf")) {
269266
f
270267
} else {
271268
return Err(Box::new(io::Error::new(io::ErrorKind::Other, "Could not create FontAwesome.ttf")));

src/renderer/html_handlebars/helpers/navigation.rs

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
1616
let chapters = c.navigate(rc.get_path(), "chapters");
1717

1818
let current = c.navigate(rc.get_path(), "path")
19-
.to_string()
20-
.replace("\"", "");
19+
.to_string()
20+
.replace("\"", "");
2121

2222

2323
debug!("[*]: Decode chapters from JSON");
2424
// Decode json format
2525
let decoded: Vec<BTreeMap<String, String>> = match json::decode(&chapters.to_string()) {
2626
Ok(data) => data,
27-
Err(_) => return Err(RenderError { desc: "Could not decode the JSON data".to_owned() }),
27+
Err(_) => return Err(RenderError::new("Could not decode the JSON data")),
2828
};
2929
let mut previous: Option<BTreeMap<String, String>> = None;
3030

@@ -52,7 +52,7 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
5252
},
5353
None => {
5454
debug!("[*]: No title found for chapter");
55-
return Err(RenderError { desc: "No title found for chapter in JSON data".to_owned() });
55+
return Err(RenderError::new("No title found for chapter in JSON data"));
5656
},
5757
};
5858

@@ -68,16 +68,10 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
6868
Some(p) => {
6969
previous_chapter.insert("link".to_owned(), p.replace("\\", "/").to_json());
7070
},
71-
None => {
72-
return Err(RenderError {
73-
desc: "Link could not be converted to str".to_owned(),
74-
})
75-
},
71+
None => return Err(RenderError::new("Link could not be converted to str")),
7672
}
7773
},
78-
None => {
79-
return Err(RenderError { desc: "No path found for chapter in JSON data".to_owned() })
80-
},
74+
None => return Err(RenderError::new("No path found for chapter in JSON data")),
8175
}
8276

8377
debug!("[*]: Inject in context");
@@ -90,7 +84,7 @@ pub fn previous(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext
9084
Some(t) => {
9185
try!(t.render(&updated_context, r, rc));
9286
},
93-
None => return Err(RenderError { desc: "Error with the handlebars template".to_owned() }),
87+
None => return Err(RenderError::new("Error with the handlebars template")),
9488
}
9589

9690
}
@@ -122,14 +116,14 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
122116
let chapters = c.navigate(rc.get_path(), "chapters");
123117

124118
let current = c.navigate(rc.get_path(), "path")
125-
.to_string()
126-
.replace("\"", "");
119+
.to_string()
120+
.replace("\"", "");
127121

128122
debug!("[*]: Decode chapters from JSON");
129123
// Decode json format
130124
let decoded: Vec<BTreeMap<String, String>> = match json::decode(&chapters.to_string()) {
131125
Ok(data) => data,
132-
Err(_) => return Err(RenderError { desc: "Could not decode the JSON data".to_owned() }),
126+
Err(_) => return Err(RenderError::new("Could not decode the JSON data")),
133127
};
134128
let mut previous: Option<BTreeMap<String, String>> = None;
135129

@@ -145,7 +139,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
145139

146140
let previous_path = match previous.get("path") {
147141
Some(p) => p,
148-
None => return Err(RenderError { desc: "No path found for chapter in JSON data".to_owned() }),
142+
None => return Err(RenderError::new("No path found for chapter in JSON data")),
149143
};
150144

151145
if previous_path == &current {
@@ -160,9 +154,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
160154
debug!("[*]: Inserting title: {}", n);
161155
next_chapter.insert("title".to_owned(), n.to_json());
162156
},
163-
None => {
164-
return Err(RenderError { desc: "No title found for chapter in JSON data".to_owned() })
165-
},
157+
None => return Err(RenderError::new("No title found for chapter in JSON data")),
166158
}
167159

168160

@@ -174,7 +166,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
174166
// Hack for windows who tends to use `\` as separator instead of `/`
175167
next_chapter.insert("link".to_owned(), l.replace("\\", "/").to_json());
176168
},
177-
None => return Err(RenderError { desc: "Link could not converted to str".to_owned() }),
169+
None => return Err(RenderError::new("Link could not converted to str")),
178170
}
179171

180172
debug!("[*]: Inject in context");
@@ -188,7 +180,7 @@ pub fn next(c: &Context, _h: &Helper, r: &Handlebars, rc: &mut RenderContext) ->
188180
Some(t) => {
189181
try!(t.render(&updated_context, r, rc));
190182
},
191-
None => return Err(RenderError { desc: "Error with the handlebars template".to_owned() }),
183+
None => return Err(RenderError::new("Error with the handlebars template")),
192184
}
193185

194186
break;

0 commit comments

Comments
 (0)