add gopher
parent
cc5666142a
commit
c40f060791
30
make.sh
30
make.sh
|
@ -4,7 +4,9 @@ set -e
|
|||
|
||||
pd=/usr/bin/pandoc
|
||||
g=/bin/grep
|
||||
postDir=/home/vilmibm/blog
|
||||
postDir=/home/vilmibm/blog/posts
|
||||
|
||||
# TODO generalize into one loop
|
||||
|
||||
function makeHTML() {
|
||||
htmlDir=/home/vilmibm/public_html/blog
|
||||
|
@ -25,7 +27,7 @@ function makeHTML() {
|
|||
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" ]
|
||||
if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ]
|
||||
then
|
||||
echo "warning: missing at least one of: pubdate, slug, title in ${p}"
|
||||
else
|
||||
|
@ -40,12 +42,30 @@ function makeHTML() {
|
|||
echo "</body></html>" >> $htmlIndex
|
||||
}
|
||||
|
||||
#function makeGopher() {
|
||||
# # TODO
|
||||
#}
|
||||
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