From 1664a85b1e6a62262ac4c49269e17d1949495de5 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 20 Apr 2022 19:14:37 +0300 Subject: feat: add RSS feed generation --- .gitignore | 1 + Makefile | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 07c47a0..55d21d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.html +*.xml blog/preview.md diff --git a/Makefile b/Makefile index 3d48ace..575cb6e 100644 --- a/Makefile +++ b/Makefile @@ -5,8 +5,10 @@ MARKDOWN=gfm+emoji STYLESHEET=/style.css HEAD=head.html HEADER=header.html +RSS_FEED=blog/index.xml OPENRING_FOOTER=footer.html -PANDOC_ARGS=-s --from=$(MARKDOWN) --to=html -c $(STYLESHEET) -B $(HEADER) -H $(HEAD) -M lang="en" --shift-heading-level-by=1 --highlight-style=gruvbox.theme +PANDOC_ARGS= --from=$(MARKDOWN) --to=html +PANDOC_HTML_ARGS=-s $(PANDOC_ARGS) -c $(STYLESHEET) -B $(HEADER) -H $(HEAD) -M lang="en" --shift-heading-level-by=1 --highlight-style=gruvbox.theme LINK_SEDSTRING=s/.md)/.html)/g; EMOJI_SEDSTRING=$(shell ./compile_emoji_sedstring.sh) @@ -18,26 +20,46 @@ OPENRING_ARGS=$(shell ./compile_openring_args.sh) SOURCES=$(wildcard *.md blog/*.md articles/*.md) HTML=$(patsubst %.md, %.html, $(SOURCES)) +XML=$(patsubst %.md, %.xml, $(filter-out blog/preview.md, $(filter-out blog/index.md, $(wildcard blog/*.md)))) -all: $(HTML) +all: $(HTML) $(RSS_FEED) %.html: %.md $(OPENRING_FOOTER) @echo $@ @DESCRIPTION=$$(sed '2,/^$$/!d' $< | tr '\n' ' '); \ PAGETITLE=$$(sed '/^#/q' $< | sed 's/:[a-z]*://; s/#* //'); \ sed "$(LINK_SEDSTRING) $(EMOJI_SEDSTRING)" $< \ - | pandoc $(PANDOC_ARGS) -M pagetitle="$$PAGETITLE | $(TITLE)" -A $(OPENRING_FOOTER) -M description="$$DESCRIPTION" > $@ + | pandoc $(PANDOC_HTML_ARGS) -M pagetitle="$$PAGETITLE | $(TITLE)" -A $(OPENRING_FOOTER) -M description="$$DESCRIPTION" > $@ + +%.xml: %.md + @echo $@ + @echo '' > $@ + @echo " https://eug-vs.xyz/$*.html" >> $@ + @echo " $*" >> $@ + @echo " $$(sed '/^#/q' $< | sed 's/:[a-z]*://; s/#* //')" >> $@ + @echo " > $@ + @sed "$(LINK_SEDSTRING) $(EMOJI_SEDSTRING)" $< | pandoc $(PANDOC_ARGS) $< >> $@ + @echo " ]]>" >> $@ + @echo '' >> $@ + +$(RSS_FEED): $(XML) + @echo $@ + @echo '' > $@ + @echo "Eugene's Spacehttps://eug-vs.xyzEugene's blog" >> $@ + @cat $$(echo $^ | tr " " "\n" | sort -r | tr "\n" " ") >> $@ + @echo '' >> $@ index.html: index.md blog/preview.md @echo $@ @DESCRIPTION=$$(sed '2,/^$$/!d' $< | tr '\n' ' '); \ sed "/Recent blog posts/r blog/preview.md" $< \ | sed "$(LINK_SEDSTRING) $(EMOJI_SEDSTRING)" \ - | pandoc $(PANDOC_ARGS) -M pagetitle="$(TITLE)" -M description="$$DESCRIPTION"> $@ + | pandoc $(PANDOC_HTML_ARGS) -M pagetitle="$(TITLE)" -M description="$$DESCRIPTION"> $@ $(OPENRING_FOOTER): openring-template.html - openring $(OPENRING_ARGS) < $< > $@ + @echo $@ + @openring $(OPENRING_ARGS) < $< > $@ blog/preview.md: blog/index.md @echo $@ @@ -46,9 +68,9 @@ blog/preview.md: blog/index.md open: $(HTML) xdg-open index.html -deploy: $(HTML) +deploy: all $(MAKE) unlocalize - rsync -rtvzP --exclude=".git" --exclude="*.md" . $(RSYNC_DESTINATION) + rsync -rtvzP --include="$(RSS_FEED)" --exclude=".git" --exclude="*.md" --exclude="*.xml" . $(RSYNC_DESTINATION) localize: $(HTML) @for file in $^; do sed -i "$(UNLOCALIZE_SEDSTRING) $(LOCALIZE_SEDSTRING)" $$file; done @@ -57,5 +79,5 @@ unlocalize: $(HTML) @for file in $^; do sed -i "$(UNLOCALIZE_SEDSTRING)" $$file; done clean: - rm -f $(HTML) $(OPENRING_FOOTER) blog/preview.md + rm -f $(HTML) $(XML) $(OPENRING_FOOTER) $(RSS_FEED) blog/preview.md -- cgit v1.2.3