add gopher

trunk
vilmibm 2022-05-20 07:10:18 +00:00
parent cc5666142a
commit c40f060791
3 changed files with 25 additions and 5 deletions

30
make.sh
View File

@ -4,7 +4,9 @@ set -e
pd=/usr/bin/pandoc pd=/usr/bin/pandoc
g=/bin/grep g=/bin/grep
postDir=/home/vilmibm/blog postDir=/home/vilmibm/blog/posts
# TODO generalize into one loop
function makeHTML() { function makeHTML() {
htmlDir=/home/vilmibm/public_html/blog htmlDir=/home/vilmibm/public_html/blog
@ -25,7 +27,7 @@ function makeHTML() {
pubdate=$($g "pubdate:" $p | sed 's/pubdate://') pubdate=$($g "pubdate:" $p | sed 's/pubdate://')
title=$($g "title:" $p | sed 's/title://') title=$($g "title:" $p | sed 's/title://')
slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\]) slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\])
if [ -z "$pubdate" ] || [ -z "$title" ] if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ]
then then
echo "warning: missing at least one of: pubdate, slug, title in ${p}" echo "warning: missing at least one of: pubdate, slug, title in ${p}"
else else
@ -40,12 +42,30 @@ function makeHTML() {
echo "</body></html>" >> $htmlIndex echo "</body></html>" >> $htmlIndex
} }
#function makeGopher() { function makeGopher() {
# # TODO gopherPath=/home/vilmibm/public_gopher/blog
#} cd $postDir > /dev/null
for p in $(ls *.md)
do
pubdate=$($g "pubdate:" $p | sed 's/pubdate://')
title=$($g "title:" $p | sed 's/title://')
slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\])
if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ]
then
echo "warning: missing at least one of: pubdate, slug, title in ${p}"
else
postPath="${gopherPath}/${slug}.md"
echo "# ${title}" > postPath
$g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" >> $postPath
fi
done
}
# #
#function makeGemini() { #function makeGemini() {
# # TODO # # TODO
#} #}
makeHTML makeHTML
makeGopher