|
|
@ -20,12 +20,15 @@ blog(){ |
|
|
|
makeIntro(){ |
|
|
|
makeIntro(){ |
|
|
|
local file="$1" |
|
|
|
local file="$1" |
|
|
|
local output="tmp/intros/$file" |
|
|
|
local output="tmp/intros/$file" |
|
|
|
|
|
|
|
local rssoutput="tmp/rss/$file" |
|
|
|
# We delete tmp each time the build script runs, so if the file exists, we have already generated one this time |
|
|
|
# We delete tmp each time the build script runs, so if the file exists, we have already generated one this time |
|
|
|
[ -f "$output" ] && return 1 |
|
|
|
[ -f "$output" ] && return 1 |
|
|
|
mkdir -p "${output%/*}" |
|
|
|
mkdir -p "${output%/*}" |
|
|
|
|
|
|
|
mkdir -p "${rssoutput%/*}" |
|
|
|
local info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')" |
|
|
|
local info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')" |
|
|
|
local slug=$(getBlogSlug "$file") |
|
|
|
local slug=$(getBlogSlug "$file") |
|
|
|
local date="$(echo "$info" | yq -r .date)" |
|
|
|
local date="$(echo "$info" | yq -r .date)" |
|
|
|
|
|
|
|
local rfc822="$(date --utc -d "$date" "+%a, %d %b %Y %H:%M:%S") UT" |
|
|
|
local tags="$(echo "$info" | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | awk '{print "<li>" $0 "</li>"}' )" |
|
|
|
local tags="$(echo "$info" | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | awk '{print "<li>" $0 "</li>"}' )" |
|
|
|
local title="$(echo "$info" | yq -r .title)" |
|
|
|
local title="$(echo "$info" | yq -r .title)" |
|
|
|
local description="$(echo "$info" | yq -r .description)" |
|
|
|
local description="$(echo "$info" | yq -r .description)" |
|
|
@ -39,11 +42,23 @@ makeIntro(){ |
|
|
|
<p>$description</p> |
|
|
|
<p>$description</p> |
|
|
|
<p><a href='$slug'>Read More</a></p> |
|
|
|
<p><a href='$slug'>Read More</a></p> |
|
|
|
</article>" > "$output" |
|
|
|
</article>" > "$output" |
|
|
|
|
|
|
|
echo "<item> |
|
|
|
|
|
|
|
<title> |
|
|
|
|
|
|
|
<![CDATA[$title]]></title> |
|
|
|
|
|
|
|
<link>https://jonathanh.co.uk/$slug</link> |
|
|
|
|
|
|
|
<guid isPermaLink=\"true\">https://jonathanh.co.uk/$slug</guid> |
|
|
|
|
|
|
|
<pubDate>$rfc822</pubDate> |
|
|
|
|
|
|
|
<description><![CDATA[$description]]></description> |
|
|
|
|
|
|
|
</item>" > "$rssoutput" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getIntro(){ |
|
|
|
getIntro(){ |
|
|
|
local file="$1" |
|
|
|
local file="$1" |
|
|
|
local output="tmp/intros/$file" |
|
|
|
local output="tmp/intros/$file" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$2" = "rss" ]; then |
|
|
|
|
|
|
|
local output="tmp/rss/$file" |
|
|
|
|
|
|
|
fi |
|
|
|
makeIntro "$file" |
|
|
|
makeIntro "$file" |
|
|
|
cat "$output" |
|
|
|
cat "$output" |
|
|
|
} |
|
|
|
} |
|
|
@ -137,6 +152,31 @@ card(){ |
|
|
|
content/card.curl > public_html/card |
|
|
|
content/card.curl > public_html/card |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rss(){ |
|
|
|
|
|
|
|
echo "Generating RSS Feed" |
|
|
|
|
|
|
|
lastUpdate="$(date --utc "+%a, %d %b %Y %H:%M:%S") UT" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# First loop makes all the intros needed and stores them in tmp/intros |
|
|
|
|
|
|
|
find content/blog/ -type f -name '*.md' | grep -v 'xxx' | sort -r | head -n 20 | while read file; do |
|
|
|
|
|
|
|
makeIntro "$file" & |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
wait |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
echo "<?xml version='1.0' encoding='UTF-8' ?> |
|
|
|
|
|
|
|
<rss xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:content=\"http://purl.org/rss/1.0/modules/content/\" xmlns:atom=\"http://www.w3.org/2005/Atom\" version=\"2.0\"> |
|
|
|
|
|
|
|
<channel> |
|
|
|
|
|
|
|
<title><![CDATA[Jonathan Hodgson]]></title> |
|
|
|
|
|
|
|
<description><![CDATA[Jonathan Hodgson's Blog]]></description> |
|
|
|
|
|
|
|
<link>https://jonathanh.co.uk</link> |
|
|
|
|
|
|
|
<lastBuildDate>$lastUpdate</lastBuildDate>" |
|
|
|
|
|
|
|
find content/blog/ -type f -name '*.md' | grep -v 'xxx' | sort -r | head -n 20 | while read file; do |
|
|
|
|
|
|
|
grep -Eq '^draft: true' "$file" || getIntro "$file" rss |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
echo "</channel></rss>"; |
|
|
|
|
|
|
|
) > public_html/feed.rss |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
clean(){ |
|
|
|
clean(){ |
|
|
|
rm -rf tmp > /dev/null 2> /dev/null |
|
|
|
rm -rf tmp > /dev/null 2> /dev/null |
|
|
@ -156,5 +196,6 @@ case "$1" in |
|
|
|
blog) blog ;; |
|
|
|
blog) blog ;; |
|
|
|
tags) tags ;; |
|
|
|
tags) tags ;; |
|
|
|
card) card ;; |
|
|
|
card) card ;; |
|
|
|
all) tags && blog && index && card ;; |
|
|
|
rss) rss ;; |
|
|
|
|
|
|
|
all) tags && blog && index && rss && card ;; |
|
|
|
esac |
|
|
|
esac |
|
|
|