blog

git clone https://git.ce9e.org/blog.git

commit
59b3048e030650e0b7d6964cd2e24f210047f147
parent
1f42da613fda39bf117bfea821cbbe7ed5ccb8c5
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-12-15 13:00
include content back into feed

Diffstat

M .gitignore 1 +
M Makefile 10 ++++++++--
D _templates/feed.xml 18 ------------------
A feed.sh 29 +++++++++++++++++++++++++++++

4 files changed, 38 insertions, 20 deletions


diff --git a/.gitignore b/.gitignore

@@ -1 +1,2 @@
    1     1 build/
   -1     2 _content/**/index.html

diff --git a/Makefile b/Makefile

@@ -1,6 +1,7 @@
    1     1 .POSIX:
    2     2 PAGES := $(shell find _content -name 'index.md' | sed 's/^_content/build/;s/md$$/html/')
    3     3 PAGES_MD := $(shell find _content -name 'index.md' | sed 's/^_content/build/')
   -1     4 PAGES_FEED := $(shell find _content -name 'index.md' | sed 's/md$$/html/')
    4     5 STATIC := $(shell find static -type f | sed 's/^/build\//')
    5     6 IMG := $(shell find _content -regex '.*\.\(png\|gif\|jpg\)$$' | sed 's/^_content/build/')
    6     7 PANDOC_ARGS = -f markdown-smart --wrap=none
@@ -24,6 +25,10 @@ build/index.md: _content/posts/*/index.md posts.sh
   24    25 	@mkdir -p $$(dirname $@)
   25    26 	./posts.sh > $@
   26    27 
   -1    28 _content/%.html: _content/%.md
   -1    29 	pandoc $(PANDOC_ARGS) $< -o $@
   -1    30 	@sed -i 's/<tr class="header">/<tr>/g' $@
   -1    31 
   27    32 build/%.png: _content/%.png
   28    33 	ln $< $@
   29    34 
@@ -33,8 +38,8 @@ build/%.jpg: _content/%.jpg
   33    38 build/%.gif: _content/%.gif
   34    39 	ln $< $@
   35    40 
   36    -1 build/feed.xml: build/index.md _templates/feed.xml
   37    -1 	pandoc $(PANDOC_ARGS) --template _templates/feed.xml -t html $< -o $@
   -1    41 build/feed.xml: feed.sh $(PAGES_FEED)
   -1    42 	./feed.sh > $@
   38    43 
   39    44 build/static/%: static/%
   40    45 	@mkdir -p $$(dirname $@)
@@ -46,3 +51,4 @@ build/static/style.css: style/*.scss style/components/*.scss
   46    51 .PHONY: clean
   47    52 clean:
   48    53 	rm -rf build
   -1    54 	rm -f $(PAGES_FEED)

diff --git a/_templates/feed.xml b/_templates/feed.xml

@@ -1,18 +0,0 @@
    1    -1 <?xml version="1.0" encoding="utf-8"?>
    2    -1 <feed xmlns="http://www.w3.org/2005/Atom">
    3    -1 	<author>
    4    -1 		<name>Tobias Bengfort</name>
    5    -1 	</author>
    6    -1 	<title>Ξ</title>
    7    -1 	<id>https://blog.ce9e.org/</id>
    8    -1 	<link href="https://blog.ce9e.org/" rel="self" />
    9    -1 
   10    -1 ${for(posts)}
   11    -1 	<entry>
   12    -1 		<title>${it.title}</title>
   13    -1 		<link href="https://blog.ce9e.org${it.url}"/>
   14    -1 		<id>https://blog.ce9e.org${it.url}</id>
   15    -1 		<updated>${it.date}T00:00:00Z</updated>
   16    -1 	</entry>
   17    -1 ${endfor}
   18    -1 </feed>

diff --git a/feed.sh b/feed.sh

@@ -0,0 +1,29 @@
   -1     1 #!/bin/sh
   -1     2 
   -1     3 base_url='https://blog.ce9e.org/'
   -1     4 
   -1     5 escape() {
   -1     6 	sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g'
   -1     7 }
   -1     8 
   -1     9 echo '<?xml version="1.0" encoding="utf-8"?>'
   -1    10 echo '<feed xmlns="http://www.w3.org/2005/Atom">'
   -1    11 echo '	<author><name>Tobias Bengfort</name></author>'
   -1    12 echo '	<title>Ξ</title>'
   -1    13 echo "	<id>$base_url</id>"
   -1    14 echo '	<link href="https://blog.ce9e.org/" rel="self" />'
   -1    15 
   -1    16 ls _content/posts | tac | while read l; do
   -1    17 	yml="_content/posts/$l/index.md"
   -1    18 	html="_content/posts/$l/index.html"
   -1    19 	url="${base_url}posts/$l/"
   -1    20 	echo '	<entry>'
   -1    21 	echo "		<title>$(grep '^title:' "$yml" | head -n 1 | sed 's/title: //' | escape)</title>"
   -1    22 	echo "		<link href=\"$url\">"
   -1    23 	echo "		<id>$url</id>"
   -1    24 	echo "		<updated>$(grep '^date:' "$yml" | head -n 1 | sed 's/date: //' | escape)T00:00:00Z</updated>"
   -1    25 	echo "		<content type=\"html\">$(cat "$html" | escape)</content>"
   -1    26 	echo '	</entry>'
   -1    27 done
   -1    28 
   -1    29 echo '</feed>'