rss feed!

This commit is contained in:
xfnw 2020-10-11 20:47:18 -04:00
parent cb72566665
commit 6731d28548
3 changed files with 38 additions and 3 deletions

1
.gitignore vendored
View file

@ -2,3 +2,4 @@ src
src/ src/
src/* src/*
*.html *.html
*.rss

View file

@ -23,5 +23,11 @@
<!-- COMIC --> <!-- COMIC -->
<br><br>
<center>
<a href="feed.rss">RSS feed</a>
</center>
</body> </body>
</html> </html>

34
xfwc
View file

@ -1,5 +1,18 @@
#!/bin/bash #!/bin/bash
ABSURL="https://xfnw.ttm.sh/xfwc"
cat <<EOF > feed.rss
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>xfwc</title>
<link>$ABSURL/</link>
<description>xfwc</description>
EOF
BOOPTMP=$(mktemp) BOOPTMP=$(mktemp)
TOTAL=$(ls src | wc -w) TOTAL=$(ls src | wc -w)
@ -8,12 +21,20 @@ rm index.html
ln -s $TOTAL.html index.html ln -s $TOTAL.html index.html
for fn in $(ls src); do NUM=$TOTAL
NUM=$(echo "${fn%???}" | sed 's/[^0-9]*//g') for fn in $(ls -t src); do
NEWF=$NUM.html NEWF=$NUM.html
TITLE=$(echo ${fn%????} | sed 's/_/ /g; s/[0-9]*//g' | sed -e 's/[]$.*[\^]/\\&/g') TITLE=$(echo ${fn%????} | sed 's/_/ /g' | sed -e 's/[]$.*[\^]/\\&/g')
echo "rendering $NEWF..." echo "rendering $NEWF..."
cat <<EOF >> feed.rss
<item>
<title>$TITLE</title>
<link>$ABSURL/$NEWF</link>
<description>image #$NUM</description>
</item>
EOF
echo "<img class='comic' alt='$TITLE' title='$TITLE' src='src/$fn'/>" > $BOOPTMP echo "<img class='comic' alt='$TITLE' title='$TITLE' src='src/$fn'/>" > $BOOPTMP
cp template/page.html $NEWF cp template/page.html $NEWF
@ -33,6 +54,13 @@ sed -i "s/LAST/"$TOTAL"/" $NEWF
sed -i 's/PRE/#/; s/NEXT/#/' $NEWF sed -i 's/PRE/#/; s/NEXT/#/' $NEWF
NUM=$(( NUM - 1 ))
done done
cat <<EOF >> feed.rss
</channel>
</rss>
EOF