Moved to Makefile based build system

Got rid of janky build.sh script. Now uses a bunch of janky scripts and
a make file - because that is bound to be easier to maintain.
This commit is contained in:
Jonathan Hodgson 2022-06-13 11:02:02 +01:00
parent 39791363fa
commit 56f95cb9aa
13 changed files with 289 additions and 234 deletions

15
bin/generateRSS Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
lastUpdate="$(date --utc "+%a, %d %b %Y %H:%M:%S") UT"
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>"
for i in "$@"; do
cat "$i"
done
echo "</channel></rss>"

35
bin/gmiIndex Executable file
View file

@ -0,0 +1,35 @@
#!/usr/bin/env bash
case "$1" in
tag)
title="Archive: $(echo "$ALLTAGS" | tr ' _' '\n ' | grep -i "$(echo "$2" | tr '_' ' ')")"
template="$(echo "" | pandoc --template=templates/blog.html \
-f markdown -t html5 -M archive -M title:"$title" 2> /dev/null )"
shift
;;
index)
echo "# Jonathan Hodgson"
echo ""
echo "## Blogs"
echo ""
;;
esac
shift
for i in "$@"; do
case "$i" in
tmp/intros/*)
cat "$i"
echo ""
;;
esac
done
echo "## Other Links"
echo "=> /help-me-out/ Help Me Out"
echo "=> /other-stuff-you-might-like/ Other Stuff You Might Like"

19
bin/gmiIntro Executable file
View file

@ -0,0 +1,19 @@
#!/usr/bin/env bash
file="$1"
getBlogSlug(){
echo "$1" | sed 's/^content\//\//' | sed 's/.md$/\//' | sed -E 's/[0-9]+-//'
}
info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')"
slug=$(getBlogSlug "$file")
date="$(echo "$info" | yq -r .date)"
title="$(echo "$info" | yq -r .title)"
description="$(echo "$info" | yq -r .description)"
echo "=> $slug $title"
echo -e "\t$date"
echo "$description"

27
bin/htmlIndex Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env bash
case "$1" in
tag)
title="Archive: $(echo "$ALLTAGS" | tr ' _' '\n ' | grep -i "$(echo "$2" | tr '_' ' ')")"
template="$(echo "" | pandoc --template=templates/blog.html \
-f markdown -t html5 -M archive -M title:"$title" 2> /dev/null )"
shift
;;
index)
template="$(echo "" | pandoc --template=templates/blog.html \
-f markdown -t html5 -M frontpage 2> /dev/null )"
;;
esac
shift
echo "$template" | sed -n '1,/#CONTENT#/p' | head -n -1
for i in "$@"; do
case "$i" in
tmp/intros/*) cat "$i" ;;
esac
done
echo "$template" | sed -n '/#CONTENT#/,$p' | sed '1d'

25
bin/htmlIntro Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env bash
file="$1"
getBlogSlug(){
echo "$1" | sed 's/^content\//\//' | sed 's/.md$/\//' | sed -E 's/[0-9]+-//'
}
info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')"
slug=$(getBlogSlug "$file")
date="$(echo "$info" | yq -r .date)"
title="$(echo "$info" | yq -r .title)"
description="$(echo "$info" | yq -r .description)"
echo "<article>
<h2><a href='$slug'>$title</a></h2>
<div class="article-details">
<div class="date">
$date
</div>
</div>
<p>$description</p>
<p><a href='$slug'>Read More</a></p>
</article>"

11
bin/htmlTagList Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env bash
echo "<ul class='taglist'>"
for line in "$@"; do
link="/tag/$(echo "$line" | tr 'A-Z' 'a-z')/"
name="$(echo "$line" | tr '_' ' ')"
echo "<li><a href='$link'>$name</a></li>"
done
echo "</ul>"

23
bin/listBlogs Executable file
View file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
tag="$(echo "$1" | tr ' ' '_' | tr 'A-Z' 'a-z')"
if [ "$tag" == "all" ]; then
find content/blog/ -type f -name '*.md' -not -name 'xxx-*' | sort -r -u |
cut -d '-' -f 2- | cut -d '.' -f 1
else
find content/blog/ -type f -name '*.md' -not -name 'xxx-*' | sort -r -u |
while read file; do
tags="$(sed -n '/---/,/---/p' "$file" |
sed -n '1,/---/p' | sed '/^---$/d' |
sed '/^$/,$d' |
yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' |
tr 'A-Z' 'a-z' | tr ' ' '_'
)"
if echo "$tags" | grep -q "$tag"; then
echo "$file" | cut -d '-' -f 2- | cut -d '.' -f 1
fi
done
fi

7
bin/listTags Executable file
View file

@ -0,0 +1,7 @@
#!/usr/bin/env bash
find content/blog/ -type f -name '*.md' -not -name 'xxx-*' | while read file; do
sed -n '/---/,/---/p' "$file" | sed -n '1,/---/p' | sed '/^---$/d' | sed '/^$/,$d' | yq -r 'if ( .tags | type ) == "array" then .tags else [ .tags ] end | join("\n")' | while read tag; do
echo "$tag" | tr ' ' '_'
done
done | sort -u

24
bin/rssIntro Executable file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
file="$1"
getBlogSlug(){
echo "$1" | sed 's/^content\//\//' | sed 's/.md$/\//' | sed -E 's/[0-9]+-//'
}
info="$(sed -n '/---/,/---/p' "$file" | sed '/^$/,$d' | sed -n '1,/---/p' | sed '/^---$/d')"
slug=$(getBlogSlug "$file")
date="$(echo "$info" | yq -r .date)"
rfc822="$(date --utc -d "$date" "+%a, %d %b %Y %H:%M:%S") UT"
title="$(echo "$info" | yq -r .title)"
description="$(echo "$info" | yq -r .description)"
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>"