From 7d1d36ac8d033404956c2e7289855ea0cd1466a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?=
Date: Sat, 26 Jan 2019 10:37:36 +0100
Subject: [PATCH] prettier identation in html, added a comment
---
src/main.rs | 12 ++++++----
web/data/2018-09-30/{node.txt => note.txt} | 0
web/feed.xml | 3 ++-
web/templates/_head.html | 20 +++++++++++++++++
web/templates/_thumb.html | 8 +++----
web/templates/detail.html | 26 +++++++++-------------
web/templates/index.html | 26 +++++++++-------------
7 files changed, 55 insertions(+), 40 deletions(-)
rename web/data/2018-09-30/{node.txt => note.txt} (100%)
create mode 100644 web/templates/_head.html
diff --git a/src/main.rs b/src/main.rs
index 981dea6..095089f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -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!("
", src=&utf8_percent_encode(img.to_str().unwrap(), DEFAULT_ENCODE_SET).to_string()))
+ pics.push_str(&format!("
\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();
diff --git a/web/data/2018-09-30/node.txt b/web/data/2018-09-30/note.txt
similarity index 100%
rename from web/data/2018-09-30/node.txt
rename to web/data/2018-09-30/note.txt
diff --git a/web/feed.xml b/web/feed.xml
index c6fdef5..453ce9c 100644
--- a/web/feed.xml
+++ b/web/feed.xml
@@ -29,7 +29,8 @@
2018/09/30
https://www.ondrovo.com/bread/2018-09-30.html
- There's no note about this bread.
Open the link for more...
]]>
+ nice crust, but it had huge holes in it. idk why
+
Open the link for more...
]]>
https://www.ondrovo.com/bread/2018-09-30.html
Sun, 30 Sep 2018 12:00:00 +0000
diff --git a/web/templates/_head.html b/web/templates/_head.html
new file mode 100644
index 0000000..f0914ec
--- /dev/null
+++ b/web/templates/_head.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+ {title}
diff --git a/web/templates/_thumb.html b/web/templates/_thumb.html
index 8f8c6f6..9a1b5bb 100644
--- a/web/templates/_thumb.html
+++ b/web/templates/_thumb.html
@@ -1,4 +1,4 @@
-
-
-
-
+
+
+
+
diff --git a/web/templates/detail.html b/web/templates/detail.html
index 882d4b9..5fc1a7d 100644
--- a/web/templates/detail.html
+++ b/web/templates/detail.html
@@ -1,25 +1,21 @@
-
- Breads
-
-
-
-
-
+{head}
- {title}
+ {title}
-
- {note}
+
+
+ {note}
+
-
- {images}
-
-
+
+ {images}
+
+
- Back to gallery
+ Back to gallery
diff --git a/web/templates/index.html b/web/templates/index.html
index 67dc63b..1af6223 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -1,21 +1,15 @@
-
-
- Breads
-
+
+{head}
+
+
+ Piggo's Bread Gallery
-
-
-
-
-
- Piggo's Bread Gallery
+ Like and subscribe
- Like and subscribe
-
-
- {breads}
-
-
+
+ {breads}
+
+