aboutsummaryrefslogtreecommitdiff
path: root/script.sh
blob: f129bfefe868c07851dfa31b8210d17ea2fc0417 (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
#!/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/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g')</pre>]]>
  </description>
  <author>$AUTHOR</author>
  <guid>$DOMAIN/$file</guid>
  </item>";
done

echo "  </channel>
</rss>";