prettier identation in html, added a comment

This commit is contained in:
2019-01-26 10:37:36 +01:00
parent e0de01dc05
commit 7d1d36ac8d
7 changed files with 55 additions and 40 deletions
+8 -4
View File
@@ -102,8 +102,10 @@ fn main() {
let mut main_tpl = String::new();
let mut thumb_tpl = String::new();
let mut detail_tpl = String::new();
let mut head_tpl = String::new();
File::open(tpl_path.join("index.html")).unwrap().read_to_string(&mut main_tpl).unwrap();
File::open(tpl_path.join("_thumb.html")).unwrap().read_to_string(&mut thumb_tpl).unwrap();
File::open(tpl_path.join("_head.html")).unwrap().read_to_string(&mut head_tpl).unwrap();
File::open(tpl_path.join("detail.html")).unwrap().read_to_string(&mut detail_tpl).unwrap();
let mut thumbs = String::new();
@@ -173,22 +175,24 @@ fn main() {
// generate the detail page
{
let detail = detail_tpl
.replace("{head}", &head_tpl.replace("{title}", &format!("Bread from {}", date)).trim())
.replace("{title}", &date)
.replace("{note}", note);
.replace("{note}", note.trim());
let mut pics = String::new();
for img in &bread.images {
pics.push_str(&format!("<a href=\"{src}\"><img src=\"{src}\"></a>", src=&utf8_percent_encode(img.to_str().unwrap(), DEFAULT_ENCODE_SET).to_string()))
pics.push_str(&format!(" <a href=\"{src}\"><img src=\"{src}\"></a>\n", src=&utf8_percent_encode(img.to_str().unwrap(), DEFAULT_ENCODE_SET).to_string()))
}
let detail = detail.replace("{images}", &pics);
let detail = detail.replace("{images}", &pics.trim());
let mut f = OpenOptions::new().write(true).truncate(true).create(true).open(web_path.join(detail_file)).unwrap();
f.write(detail.as_bytes()).unwrap();
}
}
let main = main_tpl.replace("{breads}", &thumbs);
let main = main_tpl.replace("{breads}", &thumbs.trim())
.replace("{head}", &head_tpl.replace("{title}", "Piggo's breads").trim());
{
let mut f = OpenOptions::new().write(true).truncate(true).create(true).open(web_path.join("index.html")).unwrap();