Test RSS Support
This commit is contained in:
87
blog/.data.json
Normal file
87
blog/.data.json
Normal file
@ -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":""
|
||||
}
|
||||
]}
|
13
blog/.rss.item.template
Normal file
13
blog/.rss.item.template
Normal file
@ -0,0 +1,13 @@
|
||||
<item>
|
||||
<title>TITLE</title>
|
||||
<link>
|
||||
https://www.clementchiew.me/blog/blog-CURRENTINT
|
||||
</link>
|
||||
<description>
|
||||
$item
|
||||
</description>
|
||||
<pubDate>PUBDATE</pubDate>
|
||||
<guid>
|
||||
GUID
|
||||
</guid>
|
||||
</item>
|
15
blog/.rss.template
Normal file
15
blog/.rss.template
Normal file
@ -0,0 +1,15 @@
|
||||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>My Little Spot</title>
|
||||
<link>https://www.clementchiew.me.</link>
|
||||
<description> </description>
|
||||
<language>en-us</language>
|
||||
<pubDate>$pubdate</pubDate>
|
||||
<lastBuildDate>$pubdate</lastBuildDate>
|
||||
<docs>https://www.clement.chiew/blog/rss</docs>
|
||||
<generator>Some random bash scripts</generator>
|
||||
<managingEditor>clementchiew@disroot.org</managingEditor>
|
||||
<webMaster>clementchiew@disroot.org</webMaster>
|
||||
$itemlist
|
||||
</channel>
|
||||
</rss>
|
@ -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 {} \;
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user