reverse breads order, new bread added

This commit is contained in:
2019-02-01 22:37:47 +01:00
parent 3b7b8cf13f
commit 03a34e0e09
7 changed files with 41 additions and 3 deletions
+9 -3
View File
@@ -114,7 +114,7 @@ fn main() {
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();
let mut thumbs = Vec::<String>::new();
let mut channel : Channel = ChannelBuilder::default()
.title("Piggo's Bread Gallery")
@@ -126,6 +126,9 @@ fn main() {
let mut channel_items = Vec::<Item>::new();
let mut hashes = hash_dict::HashDict::load(cwd.join(".hashes.txt")).unwrap();
// TODO separate thumbs by year and generate per-year pages
// TODO limit RSS to last N breads
for bread in &breads {
let date = bread.date.format("%Y/%m/%d").to_string();
@@ -174,7 +177,7 @@ fn main() {
.replace("{img_alt}", &img_alt)
.replace("{title}", &date);
thumbs.push_str(&thumb);
thumbs.push(thumb);
}
// Add to RSS
@@ -220,8 +223,11 @@ fn main() {
hashes.save();
{
// make thumbs go from the newest to the oldest
thumbs.reverse();
println!("Building the gallery page");
let main = main_tpl.replace("{breads}", &thumbs.trim())
let main = main_tpl.replace("{breads}", &thumbs.join("").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();