WIP gopher and gemini
parent
c40f060791
commit
9353b63496
92
make.sh
92
make.sh
|
@ -2,70 +2,70 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# global
|
||||||
pd=/usr/bin/pandoc
|
pd=/usr/bin/pandoc
|
||||||
g=/bin/grep
|
g=/bin/grep
|
||||||
|
tr=/usr/bin/tr
|
||||||
|
sed=/bin/sed
|
||||||
postDir=/home/vilmibm/blog/posts
|
postDir=/home/vilmibm/blog/posts
|
||||||
|
|
||||||
# TODO generalize into one loop
|
htmlDir=/home/vilmibm/public_html/blog
|
||||||
|
htmlIndexTmpl=/home/vilmibm/blog/index.tmpl.html
|
||||||
|
htmlIndex=/home/vilmibm/public_html/blog/index.html
|
||||||
|
|
||||||
function makeHTML() {
|
gopherPath=/home/vilmibm/public_gopher/blog
|
||||||
htmlDir=/home/vilmibm/public_html/blog
|
geminiPath=/home/vilmibm/public_gemini/blog
|
||||||
htmlIndexTmpl=/home/vilmibm/blog/index.tmpl.html
|
|
||||||
htmlIndex=/home/vilmibm/public_html/blog/index.html
|
|
||||||
|
|
||||||
|
cd $postDir > /dev/null
|
||||||
|
|
||||||
if [ -e "${htmlIndex}" ]
|
# backup HTML index
|
||||||
then
|
if [ -e "${htmlIndex}" ]
|
||||||
|
then
|
||||||
cp $htmlIndex "${htmlIndex}.bak"
|
cp $htmlIndex "${htmlIndex}.bak"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cp $htmlIndexTmpl $htmlIndex
|
cp $htmlIndexTmpl $htmlIndex
|
||||||
|
|
||||||
cd $postDir > /dev/null
|
# Remove old gopher posts
|
||||||
for p in $(ls *.md)
|
rm ${gopherPath}/*
|
||||||
do
|
|
||||||
pubdate=$($g "pubdate:" $p | sed 's/pubdate://')
|
# Initialize blog gophermap
|
||||||
title=$($g "title:" $p | sed 's/title://')
|
gopherIndex="${gopherPath}/gophermap"
|
||||||
slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\])
|
echo "!the phlog of vilmibm as it were" > $gopherIndex
|
||||||
|
echo >> $gopherIndex
|
||||||
|
|
||||||
|
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" ]
|
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
|
||||||
|
# HTML
|
||||||
echo "<h2 class=\"title\">${title}</h2>" >> $htmlIndex
|
echo "<h2 class=\"title\">${title}</h2>" >> $htmlIndex
|
||||||
echo "<a class=\"pubdate\" name=\"${slug}\" href=\"https://tilde.town/~vilmibm/blog#${slug}\">${pubdate}</a>" >> $htmlIndex
|
echo "<a class=\"pubdate\" name=\"${slug}\" href=\"https://tilde.town/~vilmibm/blog#${slug}\">${pubdate}</a>" >> $htmlIndex
|
||||||
echo "<div class=\"post\">" >> $htmlIndex
|
echo "<div class=\"post\">" >> $htmlIndex
|
||||||
$g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" |$pd -fmarkdown -thtml >> $htmlIndex
|
$g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" |$pd -fmarkdown -thtml >> $htmlIndex
|
||||||
echo "</div>" >> $htmlIndex
|
echo "</div>" >> $htmlIndex
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
|
# Gopher
|
||||||
|
echo "0${title} ${slug}.txt" >> $gopherIndex
|
||||||
|
gopherPostPath="${gopherPath}/${slug}.txt"
|
||||||
|
echo "# ${title}" > $gopherPostPath
|
||||||
|
echo >> $gopherPostPath
|
||||||
|
echo "_published ${pubdate}_" >> $gopherPostPath
|
||||||
|
$g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" >> $gopherPostPath
|
||||||
|
|
||||||
|
# TODO index for gemini
|
||||||
|
|
||||||
|
# Gemini
|
||||||
|
geminiPostPath="${geminiPath}/${slug}.gmi"
|
||||||
|
echo "# ${title}" > $geminiPostPath
|
||||||
|
echo >> $geminiPostPath
|
||||||
|
echo "_published ${pubdate}_" >> $geminiPostPath
|
||||||
|
$g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" >> $geminiPostPath
|
||||||
|
fi
|
||||||
echo "</body></html>" >> $htmlIndex
|
echo "</body></html>" >> $htmlIndex
|
||||||
}
|
done
|
||||||
|
|
||||||
function makeGopher() {
|
|
||||||
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() {
|
|
||||||
# # TODO
|
|
||||||
#}
|
|
||||||
|
|
||||||
makeHTML
|
|
||||||
makeGopher
|
|
||||||
|
|
Loading…
Reference in New Issue