Merge branch 'devel'
This commit is contained in:
42
Jenkinsfile
vendored
42
Jenkinsfile
vendored
@ -1,42 +0,0 @@
|
||||
pipeline {
|
||||
agent { docker { image 'httpd' } }
|
||||
stages {
|
||||
stage('build') {
|
||||
steps {
|
||||
sh 'echo "building"'
|
||||
sh 'id'
|
||||
sh "cd scripts ; bash -x ./build-website.sh"
|
||||
sh "su - root -c apachectl restart"
|
||||
}
|
||||
}
|
||||
stage('test') {
|
||||
steps {
|
||||
sh 'echo "testing"'
|
||||
input "Testing complete. Proceed to deployment?"
|
||||
}
|
||||
}
|
||||
stage('deploy') {
|
||||
steps {
|
||||
sh 'echo "deploying"'
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
echo 'This will always run'
|
||||
}
|
||||
success {
|
||||
echo 'This will run only if successful'
|
||||
}
|
||||
failure {
|
||||
echo 'This will run only if failed'
|
||||
}
|
||||
unstable {
|
||||
echo 'This will run only if the run was marked as unstable'
|
||||
}
|
||||
changed {
|
||||
echo 'This will run only if the state of the Pipeline has changed'
|
||||
echo 'For example, if the Pipeline was previously failing but is now successful'
|
||||
}
|
||||
}
|
||||
}
|
87
blog/.data.json
Normal file
87
blog/.data.json
Normal file
@ -0,0 +1,87 @@
|
||||
{"data":[
|
||||
{
|
||||
"title":"The First Entry",
|
||||
"published_date":"Thu, 20 Jun 2019 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-000"
|
||||
},
|
||||
{
|
||||
"title":"The Migration",
|
||||
"published_date":"Wed, 07 Aug 2019 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-001"
|
||||
},
|
||||
{
|
||||
"title":"Configuring Dynamic DNS Records",
|
||||
"published_date":"Thu, 29 Aug 2019 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-002"
|
||||
},
|
||||
{
|
||||
"title":"? Matched Expression Does Not Match in Perl",
|
||||
"published_date":"Wed, 18 Sep 2019 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-003"
|
||||
},
|
||||
{
|
||||
"title":"The SBC Change",
|
||||
"published_date":"Mon, 02 Mar 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-004"
|
||||
},
|
||||
{
|
||||
"title":"A Hit of Kubernetes",
|
||||
"published_date":"Thu, 21 May 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-005"
|
||||
},
|
||||
{
|
||||
"title":"Optimizing Web Pages and File Sizes",
|
||||
"published_date":"Fri, 22 May 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-006"
|
||||
},
|
||||
{
|
||||
"title":"Some Website Design and CSS",
|
||||
"published_date":"Mon, 08 Jun 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-007"
|
||||
},
|
||||
{
|
||||
"title":"Git and Bash The Site",
|
||||
"published_date":"Thu, 02 Jul 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-008"
|
||||
},
|
||||
{
|
||||
"title":"A Birth In The Family",
|
||||
"published_date":"Sun, 26 Jul 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-009"
|
||||
},
|
||||
{
|
||||
"title":"Programming Anxiety",
|
||||
"published_date":"Thu, 13 Aug 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-010"
|
||||
},
|
||||
{
|
||||
"title":"LXC and Friends",
|
||||
"published_date":"Thu, 20 Aug 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-011"
|
||||
},
|
||||
{
|
||||
"title":"Migrating Everything to Proxmox - Part 1",
|
||||
"published_date":"Mon, 30 Nov 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-012"
|
||||
},
|
||||
{
|
||||
"title":"A Brief Goodbye to CentOS",
|
||||
"published_date":"Wed, 09 Dec 2020 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-013"
|
||||
},
|
||||
{
|
||||
"title":"A Walk Along The Side",
|
||||
"published_date":"Tue, 27 Jul 2021 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-014"
|
||||
},
|
||||
{
|
||||
"title":"A Taste of Progress",
|
||||
"published_date":"Sat, 23 Oct 2021 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-015"
|
||||
},
|
||||
{
|
||||
"title":"Fighting With The Past",
|
||||
"published_date":"Sat, 29 Mar 2022 00:00:00 +0800",
|
||||
"guid":"https://www.clementchiew.me/blog/blog-016"
|
||||
}
|
||||
]}
|
10
blog/.rss.item.template
Normal file
10
blog/.rss.item.template
Normal file
@ -0,0 +1,10 @@
|
||||
<item>
|
||||
<title>TITLE</title>
|
||||
<link>https://www.clementchiew.me/blog/blog-CURRENTINT</link>
|
||||
<author>clementchiew95@disroot.org (Clement Chiew)</author>
|
||||
<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" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<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.rssboard.org/rss-specification</docs>
|
||||
<generator>Some random bash scripts</generator>
|
||||
<managingEditor>clementchiew95@disroot.org (Clement Chiew)</managingEditor>
|
||||
<webMaster>clementchiew95@disroot.org (Clement Chiew)</webMaster>
|
||||
$itemlist
|
||||
</channel>
|
||||
</rss>
|
@ -4,6 +4,7 @@
|
||||
</header>
|
||||
|
||||
<ul>
|
||||
<li><a href="blog-016">2022-03-29 Fighting With The Past</a></li>
|
||||
<li><a href="blog-015">2021-10-23 A Taste of Progress</a></li>
|
||||
<li><a href="blog-014">2021-07-27 A Walk Along The Side</a></li>
|
||||
<li><a href="blog-013">2020-12-09 A Brief Goodbye to CentOS</a></li>
|
||||
|
17
blog/content-016
Normal file
17
blog/content-016
Normal file
@ -0,0 +1,17 @@
|
||||
<header>
|
||||
<h1>Fighting With The Past</h1>
|
||||
</header>
|
||||
|
||||
<p>I am an avid user of RSS and I love my RSS app to death. It brings me a steady stream of news and information every day from the sources that I personally curate; a stream uncorrupted by the ad-funded Internet we have now. It is my breath of fresh air every morning before I suit up with adblockers and venture into the cancer-ridden wasteland of ads and content filler. The premise was simple: no-BS news fully in text with some images sprinkled in. Every article does not waste your time or attention. If need be, click the link at the bottom to read the full article. So a few months ago, an idea lit up in my mind and I thought "Gee, wouldn't it be neat if my website was readable via RSS?" and I got to work. </p>
|
||||
|
||||
<h2>Browsing RSS Specs</h2>
|
||||
<p>As with most endeavours, everything seemed simple on the surface. Browsing through the <a href="https://www.rssboard.org/rss-specification">RSS specifications</a>, everything looked fine and dandy. A RSS feed is just an itemized list of your latest posts alongside some metadata about your site. Just generate a new XML file after every new post and serve it, and you're set for the day, right? Oh, how wrong I was.</p>
|
||||
|
||||
<h2>Static Pages And XML</h2>
|
||||
<p>To put it simply, my posts are handwritten in HTML and are not dynamically generated with some CMS. This means that I have to find a way to convert HTML to a XML-kosher format somehow. Thus the hunt begun. In the end, I found <a href="https://www.html-tidy.org/">Tidy</a>, a tool that can clean up my messy HTML documents to XHTML. XHTML is XML-friendly, but it wasn't the end-all. I only needed the body, not the metadata. This was easily achievable with xmllint and XPATH. With the body prepped and ready, the tricky part is that while syntactically-comformant, HTML tags do not work. I wrapped the body as a CDATA section and went by my way.</p>
|
||||
|
||||
<h2>I Will Not Regret This, Will I?</h2>
|
||||
<p>The last piece of the puzzle was the metadata for the posts. I went with a JSON file as a temporary databases for the posts, but this is a solution that is bound to bite me back in the future, but who cares about future me right? It works. The duct tape will do for now.</p>
|
||||
|
||||
<h2>Conclusion</h2>
|
||||
<p>These 3 paragraphs took me weeks to read up about XML and RSS and thinking about the solution. While it works, this is less than ideal. I will be wrangling 3 data formats with a Bash script that is becoming increasingly unwieldy. Reading up XML has also enlightened, if not misguided, me that I need write with XML documents moving forward. If not redesigned, this issue is a ticking bomb waiting to blow up in my face. Time to think really hard. Thanks for reading.</p>
|
5
blog/quote-016
Normal file
5
blog/quote-016
Normal file
@ -0,0 +1,5 @@
|
||||
<blockquote>
|
||||
No man ever steps in the same river twice, for it's not the same river and he's not the same man.
|
||||
<br>
|
||||
- Heraclitus
|
||||
</blockquote>
|
@ -22,7 +22,7 @@ name="viewport" content="width=device-width, initial-scale=1"><title>Clement Chi
|
||||
</p>I have a strong passion for technology and computers. I push myself to complete tasks as required and learn the mechanics of the tools I use. As such, I love learning new things and picking up novel skills. I am also a strong supporter of FLOSS software.</p>
|
||||
|
||||
<h2>Current Skillset</h2>
|
||||
<p>I'm current a professional services engineer working at Napier Technologies. I experiment and develop my skills on the Linux infrastructure. I currently self-host this website, Gitea, and others. Do look up my blog to see what am I currently working on or view my CV to get more infomation.</p>
|
||||
<p>I'm current a cloud engineer working at Cloud Mile. I experiment and develop my skills on the Linux infrastructure. I currently self-host this website, Gitea, and others. Do look up my blog to see what am I currently working on or view my CV to get more infomation.</p>
|
||||
|
||||
<h2>What Do I Like (Besides Technology?)</h2>
|
||||
<p>I play video games, watch movies/anime, and cook. I love having a warm cup of coffee before starting work. My top 3 favourite movies are Up, Interstellar, and Avengers: Endgame. But really, I spend most of my time grinding away at the lab.</p>
|
||||
|
@ -3,46 +3,91 @@
|
||||
# just gonna assume you're executing in the scripts folder
|
||||
|
||||
# build the blog files
|
||||
cd ../blog
|
||||
CONTENTNUM=$(($(ls content-* | wc -l)-1))
|
||||
for ((i=-1;i<$CONTENTNUM;i++))
|
||||
cd ../blog || exit
|
||||
CONTENTNUM=$(($( find . -type f -name "content-*" | wc -l)-1))
|
||||
for ((i=-1;i<CONTENTNUM;i++))
|
||||
do
|
||||
# separate files by respective static pages
|
||||
padint="$(printf %03d $i)"
|
||||
padint="$(printf %03d "$i")"
|
||||
contentname="content-$padint"
|
||||
quotename="quote-$padint"
|
||||
tailname="tail-$padint"
|
||||
blogname="blog-$padint"
|
||||
|
||||
# interactive tail
|
||||
if (( $i >= 0 )) ;then
|
||||
if (( i >= 0 )) ;then
|
||||
|
||||
# prepare tail template
|
||||
cp filetail "$tailname"
|
||||
|
||||
# increment int if the page exists
|
||||
padintprev="$(printf %03d $(($i - 1)) )"
|
||||
if (( $(($i+1)) == $CONTENTNUM )) ;then
|
||||
padintprev="$(printf %03d $((i - 1)) )"
|
||||
if (( $((i+1)) == CONTENTNUM )) ;then
|
||||
padintnext="$(printf %03d -1 )"
|
||||
else
|
||||
padintnext="$(printf %03d $(($i + 1)) )"
|
||||
padintnext="$(printf %03d $((i + 1)) )"
|
||||
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 |
|
||||
sed "s/PUBDATE/$(date -R)/" ) \
|
||||
<(
|
||||
for ((i=1;i<10;i++))
|
||||
do
|
||||
padint=$( printf %03d $(( CONTENTNUM -i )) )
|
||||
export padint
|
||||
cat \
|
||||
<(
|
||||
head -n $(( itemlinereplace -1 )) .rss.item.template |
|
||||
title=$(jq -r '.data | .['"$padint"'].title' .data.json ) \
|
||||
perl -pe 's/TITLE/$ENV{title}/; s/CURRENTINT/$ENV{padint}/'
|
||||
) \
|
||||
<(
|
||||
printf '<![CDATA['"%s"']]>' \
|
||||
"$(
|
||||
cat content-$padint quote-$padint |
|
||||
tidy -q -asxhtml |
|
||||
sed '2 s/xmlns=".*"//g' |
|
||||
xmllint --noblanks --xpath '//body' -
|
||||
)"
|
||||
) \
|
||||
<(
|
||||
tail -n +$(( itemlinereplace +1 )) .rss.item.template |
|
||||
pubdate=$(jq -r '.data | .['"$padint"'].published_date' .data.json ) \
|
||||
guid=$(jq -r '.data | .['"$padint"'].guid' .data.json ) \
|
||||
perl -pe 's/PUBDATE/$ENV{pubdate}/; s/GUID/$ENV{guid}/'
|
||||
)
|
||||
done
|
||||
) \
|
||||
<(tail -n +$(( linereplace +1 )) .rss.template) \
|
||||
> rss.xml
|
||||
|
||||
# clean up non prod files, lock down permissions, and self-destruct
|
||||
cd ../blog
|
||||
cd ../blog || exit
|
||||
\rm filehead filetail content* quote* .blog.* tail*
|
||||
cd ../
|
||||
cd ../ || exit
|
||||
\rm -rf .git scripts .index.html.* README.md Jenkinsfile
|
||||
find . -type f | xargs chmod 600
|
||||
find . -type d | xargs chmod 700
|
||||
find . -type f -exec chmod 600 {} \;
|
||||
find . -type d -exec chmod 700 {} \;
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user