diff options
author | Bradley Taunt <bt@btxx.org> | 2024-02-02 12:39:46 -0500 |
---|---|---|
committer | Bradley Taunt <bt@btxx.org> | 2024-02-02 12:39:46 -0500 |
commit | a27fa0c2e26eb2e30e220fd68cd5ee910474b602 (patch) | |
tree | 25e9d3ba8bbfcdf785f3c5a3e11764de24bacb3a /script.sh |
Diffstat (limited to 'script.sh')
-rwxr-xr-x | script.sh | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/script.sh b/script.sh new file mode 100755 index 0000000..f129bfe --- /dev/null +++ b/script.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +# Configuration +DOMAIN="https://shinobi.btxx.org" +TITLE="Shinobi" +DESCRIPTION="A text-based, RSS focused blogging system" +COPYRIGHT="2022 Bradley Taunt" +# RW_DIR="_posts/" +POST_DIR="posts/" +TTL="60" +AUTHOR="bt@btxx.org(Bradley Taunt)" +TIME=$(date +"%T %Z") + +# Advanced Setting: Automatically wrap plain text files at 72 character limit +# Detailed documentation: https://git.btxx.org/shinobi +# +# for i in $(find $RW_DIR -type f); do cp $i $POST_DIR ; done +# for i in $(find $POST_DIR -type f); do fold -s -w 72 $i > $i.temp; mv $i.temp $i ; done + +echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?> +<?xml-stylesheet href=\"rss.xsl\" type=\"text/xsl\"?> +<rss version=\"2.0\"> + <channel> + <title>$TITLE</title> + <link>$DOMAIN</link> + <description>$DESCRIPTION</description> + <copyright>$COPYRIGHT</copyright> + <ttl>$TTL</ttl>"; + +for file in $POST_DIR*; do + +echo "<item> + <pubDate>$(head -n 1 $file) $TIME</pubDate> + <category>$(date -d "$(head -n 1 $file)" +"%Y/%m/%d/%u")</category> + <title>$(head -n 2 $file | tail -n 1)</title> + <link>$DOMAIN/$file</link> + <description> + <![CDATA[ +<pre style='border: 0; white-space: pre-wrap; word-break: break-word;'>$(tail -n +4 $file | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g')</pre>]]> + </description> + <author>$AUTHOR</author> + <guid>$DOMAIN/$file</guid> + </item>"; +done + +echo " </channel> +</rss>"; |