aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2022-08-29 23:07:47 +0200
committermetamuffin <metamuffin@disroot.org>2022-08-29 23:07:47 +0200
commit3830096c748bd26c8c2aeb906e8e63960f240567 (patch)
tree85438ccb821e8c96a2967a32242bd0d9d9607f7f
parent3eb1adfeb8dd477479404a1269c8682e3b4edf12 (diff)
downloadmetamuffin-blog-3830096c748bd26c8c2aeb906e8e63960f240567.tar
metamuffin-blog-3830096c748bd26c8c2aeb906e8e63960f240567.tar.bz2
metamuffin-blog-3830096c748bd26c8c2aeb906e8e63960f240567.tar.zst
improve atom
-rw-r--r--code/makefile12
-rw-r--r--code/src/atom.rs3
-rw-r--r--code/src/main.rs2
3 files changed, 9 insertions, 8 deletions
diff --git a/code/makefile b/code/makefile
index fa1464d..df39830 100644
--- a/code/makefile
+++ b/code/makefile
@@ -1,20 +1,20 @@
TOOL := ../code/target/debug/blog-tool
+TOOLC := $(TOOL) --root=articles
SRC_ARTICLES := $(shell find articles -type f)
OUT_ARTICLES := $(SRC_ARTICLES:articles/%.md=out/%.html)
-all: $(OUT_ARTICLES) out/index.html
+all: $(OUT_ARTICLES) out/index.html out/feed.atom
out/style.css: style.css
cp $< $@
-
out/index.html: $(TOOL) $(SRC_ARTICLES)
- $(TOOL) render-index ./articles > $@
-
+ $(TOOLC) render-index > $@
+out/feed.atom: $(TOOL) $(SRC_ARTICLES)
+ $(TOOLC) generate-atom > $@
out/%.html: articles/%.md $(TOOL) out/style.css
- mkdir -p out
- $(TOOL) render-article $< > $@
+ $(TOOLC) render-article $< > $@
$(TOOL): $(shell find ../code/src -type f)
sh -c 'cd ../code; cargo build'
diff --git a/code/src/atom.rs b/code/src/atom.rs
index 4c6a771..ce6aa6e 100644
--- a/code/src/atom.rs
+++ b/code/src/atom.rs
@@ -1,4 +1,4 @@
-use crate::{get_articles, Args, ArticleMeta, BLOG_BASE};
+use crate::{get_articles, markdown::escape, Args, ArticleMeta, BLOG_BASE};
use std::process::{Command, Stdio};
pub fn generate_atom(args: &Args) -> String {
@@ -11,6 +11,7 @@ pub fn generate_atom(args: &Args) -> String {
filename,
..
}| {
+ let title = escape(title);
let datetime = iso8601::DateTime {
date: date.clone(),
time: iso8601::Time {
diff --git a/code/src/main.rs b/code/src/main.rs
index ed0a62a..693c120 100644
--- a/code/src/main.rs
+++ b/code/src/main.rs
@@ -84,7 +84,7 @@ fn article_metadata(path: PathBuf) -> ArticleMeta {
let mut buf = String::new();
f.read_line(&mut buf).unwrap(); // assume the 1st line has the title
ArticleMeta {
- title: String::from(&buf[2..]),
+ title: String::from(buf[2..].trim()),
filename: path.file_name().unwrap().to_str().unwrap().to_string(),
date: iso8601::date(&path.file_name().unwrap().to_str().unwrap()[0..10]).unwrap(),
path,