blob: 4e117b3379a38848006a6ab82ae77f1995c1c935 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#!/bin/sh
recursivebuild() {
local destdir=$(echo $1 | sed 's|^src|http|')
mkdir -p "$destdir"
for file in $(ls $1); do
if [ -d "$1/$file" ]; then
mkdir -p "$destdir/$file"
recursivebuild "$1/$file"
else
extension=$(echo "$file" | sed 's/.*\.//')
if [ "$extension" = "md" ]; then
sed "s/TITLE/$(grep '^\# ' < "$1/$file" \
| sed 's/^\# //')/" < top.html \
> "$destdir/index.html"
lowdown "$1/$file" >> "$destdir/index.html"
cat bottom.html >> "$destdir/index.html"
elif [ "$extension" = "html" ]; then
cat top.html "$1/$file" bottom.html \
| sed "s/TITLE/$(grep '<!--TITLE: ' <\
"$1/$file" \
| sed 's/^<!--TITLE: //' \
| sed 's/-->$//')/" \
> "$destdir/index.html"
else
cp "$1/$file" "$destdir/$file"
fi
fi
done
}
makeblog() {
bf=src/blog/blog.md
ff=src/blog/feed.xml
printf "# Blog\n\n[RSS Feed](feed.xml)\n\n" > $bf
cp feed-top.xml $ff
for i in $(ls src/blog | sort -r); do
if [ -d src/blog/$i ]; then
f="src/blog/$i/*.md"
d=$(grep -E '^[0-9]{4}-[0-9]{2}-[0-9]{2}$' $f)
t=$(head -n 1 $f | sed 's/# //')
echo "* $d [$t]($i)" >> $bf
echo "<item>" >> $ff
echo "<title>$t</title>" >> $ff
echo "<link>https://sebastiano.tronto.net/blog/$i</link>" >> $ff
echo "<description>$t</description>" >> $ff
echo "<pubDate>$d</pubDate>" >> $ff
echo "</item>" >> $ff
echo "" >> $ff
fi
done
echo "" >> $ff
echo "</channel>" >> $ff
echo "</rss>" >> $ff
}
makeblog
recursivebuild src
|