diff --git a/blog/.data.json b/blog/.data.json
new file mode 100644
index 0000000..b48673b
--- /dev/null
+++ b/blog/.data.json
@@ -0,0 +1,87 @@
+{"data":[
+ {
+ "title":"",
+ "published_date":"",
+ "guid":""
+ },
+ {
+ "title":"The First Entry",
+ "published_date":"Thu, 20 Jun 2019 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"The Migration",
+ "published_date":"Wed, 07 Aug 2019 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"Configuring Dynamic DNS Records",
+ "published_date":"Thu, 29 Aug 2019 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"? Matched Expression Does Not Match in Perl",
+ "published_date":"Wed, 18 Sep 2019 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"The SBC Change",
+ "published_date":"Mon, 02 Mar 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"A Hit of Kubernetes",
+ "published_date":"Thu, 21 May 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"Optimizing Web Pages and File Sizes",
+ "published_date":"Fri, 22 May 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"Some Website Design and CSS",
+ "published_date":"Mon, 08 Jun 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"Git and Bash The Site",
+ "published_date":"Thu, 02 Jul 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"A Birth In The Family",
+ "published_date":"Sun, 26 Jul 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"Programming Anxiety",
+ "published_date":"Thu, 13 Aug 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"LXC and Friends",
+ "published_date":"Thu, 20 Aug 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"Migrating Everything to Proxmox - Part 1",
+ "published_date":"Mon, 30 Nov 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"A Brief Goodbye to CentOS",
+ "published_date":"Wed, 09 Dec 2020 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"A Walk Along The Side",
+ "published_date":"Tue, 27 Jul 2021 00:00:00 +0800",
+ "guid":""
+ },
+ {
+ "title":"A Taste of Progress",
+ "published_date":"Sat, 23 Oct 2021 00:00:00 +0800",
+ "guid":""
+ }
+]}
diff --git a/blog/.rss.item.template b/blog/.rss.item.template
new file mode 100644
index 0000000..5d53253
--- /dev/null
+++ b/blog/.rss.item.template
@@ -0,0 +1,13 @@
+-
+TITLE
+
+https://www.clementchiew.me/blog/blog-CURRENTINT
+
+
+$item
+
+PUBDATE
+
+GUID
+
+
diff --git a/blog/.rss.template b/blog/.rss.template
new file mode 100644
index 0000000..18f92c7
--- /dev/null
+++ b/blog/.rss.template
@@ -0,0 +1,15 @@
+
+
+ My Little Spot
+ https://www.clementchiew.me.
+
+ en-us
+ $pubdate
+ $pubdate
+ https://www.clement.chiew/blog/rss
+ Some random bash scripts
+ clementchiew@disroot.org
+ clementchiew@disroot.org
+ $itemlist
+
+
diff --git a/scripts/build-website.sh b/scripts/build-website.sh
index a2f47cc..37fa62d 100755
--- a/scripts/build-website.sh
+++ b/scripts/build-website.sh
@@ -29,16 +29,51 @@ do
fi
# replace placeholders
- sed -i "s/PREVPADINT/$padintprev/g" "$tailname"
- sed -i "s/NEXTPADINT/$padintnext/g" "$tailname"
+ sed " s/PREVPADINT/$padintprev/g;
+ s/NEXTPADINT/$padintnext/g" filetail > "$tailname"
fi
- # cat together
+ # cat together for blog page
if [[ -f $contentname ]] ;then
cat filehead "$contentname" "$tailname" "$quotename" > "$blogname"
fi
done
+# compile items for rss
+cd ../blog || exit
+
+# get replace point in templates
+linereplace=$(grep -n '$itemlist' .rss.template | cut -f1 -d:)
+itemlinereplace=$(grep -n '$item' .rss.item.template | cut -f1 -d:)
+
+# build rss feed
+cat \
+<(head -n $(( linereplace -1 )) .rss.template) \
+<(
+ for ((i=1;i<10;i++))
+ do
+ itemnum=$(( CONTENTNUM - i ))
+ padint=$(printf %03d $itemnum)
+ title=$(jq '.data | .['"$padint"'].title' .data.json )
+ pubdate=$(jq '.data | .['"$padint"'].published_date' .data.json )
+ guid=$(jq '.data | .['"$padint"'].guid' .data.json )
+ cat \
+ <(head -n $(( itemlinereplace -1 )) .rss.item.template |
+ sed "s/TITLE/$title/;
+ s/CURRENTINT/$padint/"
+ ) \
+ <(cat content-$padint quote-$padint |
+ tidy -q -asxml |
+ xq -cx '.html.body' ) \
+ <(tail -n +$(( itemlinereplace +1 )) .rss.item.template |
+ sed "s/PUBDATE/$pubdate/;
+ s/GUID/$guid/"
+ )
+ done
+) \
+<(tail -n +$(( linereplace +1 )) .rss.template) \
+> rss.xml
+
# clean up non prod files, lock down permissions, and self-destruct
cd ../blog || exit
\rm filehead filetail content* quote* .blog.* tail*
@@ -46,3 +81,6 @@ cd ../ || exit
\rm -rf .git scripts .index.html.* README.md Jenkinsfile
find . -type f -exec chmod 600 {} \;
find . -type d -exec chmod 700 {} \;
+
+
+