2022-07-29 14:27:37 +00:00
#!/bin/sh
source _config.sh
###################################################################################
# !WARNING!
# You probably don't need to tweak anything below this line. Edit at your own risk!
###################################################################################
2022-07-30 16:07:09 +00:00
# Create the $OUTPUT directory if it does not exist yet
mkdir -p $OUTPUT
2022-07-29 14:27:37 +00:00
if [ [ $TOC = true ] ]
then
TOC_TOGGLE = "--toc" ;
else
TOC_TOGGLE = "" ;
fi
if [ [ $SYNTAX = true ] ]
then
SYNTAX_TOGGLE = "" ;
else
SYNTAX_TOGGLE = "--no-highlight" ;
fi
# Create the web browser-focused HTML versions for all posts
2022-09-17 16:32:34 +00:00
for i in $POSTS ; do pandoc --css= /blog/style.css --ascii --metadata lang = " $HTML_LANG " $TOC_TOGGLE $SYNTAX_TOGGLE --wrap= none -A _footer.html -B _header.html -s $i -o ${ i %.* } .html; done ;
2022-07-29 14:27:37 +00:00
rsync $POSTS_DIR *.html $OUTPUT $WEB_HTML ;
rm $POSTS_DIR *.html
echo " <?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
<?xml-stylesheet href = \" rss.xsl\" type = \" text/xsl\" ?>
2022-09-09 12:04:18 +00:00
<rss version = \" 2.0\" xmlns:atom= \" http://www.w3.org/2005/Atom\" >
2022-07-29 14:27:37 +00:00
<channel>
<title>$TITLE </title>
<link>$DOMAIN </link>
<description>$DESCRIPTION </description>
<copyright>$COPYRIGHT </copyright>
2022-09-09 12:04:18 +00:00
<ttl>$TTL </ttl>
<atom:link href = \" https://vern.cc/blog/feed.xml\" rel = \" self\" type = \" application/rss+xml\" />" ;
2022-07-29 14:27:37 +00:00
2022-09-09 12:32:54 +00:00
for file in $OUTPUT $WEB_HTML *.html; do
2022-07-29 14:27:37 +00:00
POST_DATE = $( sed -n 's|^<p class="date">\([^<]*\)</p>$|\1|p' $file )
POST_TITLE = $( sed -n 's|^<h1 class="title">\([^<]*\)</h1>$|\1|p' $file )
POST_CONTENT = $( sed -n '/<article>/,/<\/article>/p' $file | sed -e '1s/.*<article>//' -e '$s/<\/article>.*//' )
if [ [ $OS = "BSD" ] ]
then
CAT_DATE = $( gdate -d " $( sed -n 's|^<p class="date">\([^<]*\)</p>$|\1|p' $file ) " +"%Y/%m/%d/%u" )
POST_DATE = $( gdate -d " $( sed -n 's|^<p class="date">\([^<]*\)</p>$|\1|p' $file ) " +"%a, %d %b %Y" )
else
2022-09-09 14:03:56 +00:00
CAT_DATE = $( date -u -d " $( sed -n 's|^<p class="date">\([^<]*\)</p>$|\1|p' $file ) " +"%Y/%m/%d/%u" )
POST_DATE = $( date -u -d " $( sed -n 's|^<p class="date">\([^<]*\)</p>$|\1|p' $file ) " +"%a, %d %b %Y" )
2022-07-29 14:27:37 +00:00
fi
2022-09-11 12:43:35 +00:00
AUTHOR = " $( cat $file | htmlq .author --text) "
2022-07-29 14:27:37 +00:00
echo " <item>
<pubDate>$POST_DATE $TIME </pubDate>
<category>$CAT_DATE </category>
<title>$POST_TITLE </title>
<link>$DOMAIN /$WEB_HTML $( basename ${ file } ) </link>
<description><![ CDATA[ $POST_CONTENT ] ] ></description>
<author>$AUTHOR </author>
<guid>$DOMAIN /$WEB_HTML $( basename ${ file } ) </guid>
</item>" ;
done
echo " </channel>
</rss>" ;
2022-09-09 12:27:07 +00:00
# Copy XSLT, stylesheet files
rsync rss.xsl $OUTPUT /blog;
rsync style.css $OUTPUT /blog;