63 lines
1.9 KiB
Bash
63 lines
1.9 KiB
Bash
#!/usr/bin/env sh
|
|
|
|
source ./config
|
|
|
|
# Create the $OUTPUT directory if it does not exist yet
|
|
mkdir -p $OUTPUT
|
|
|
|
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 pages
|
|
for i in $PAGES; do pandoc --css=/style.css --ascii --metadata lang="$HTML_LANG" $TOC_TOGGLE $SYNTAX_TOGGLE --wrap=none -A templates/_footer.html -B templates/_header.html -s $i -o ${i%.*}.html; done;
|
|
|
|
rsync -r --exclude='*.md' $CONTENT_DIR $OUTPUT;
|
|
find $CONTENT_DIR -name '*.html' -delete
|
|
|
|
# Copy XSLT, stylesheet, and media files
|
|
rsync -r ./assets/ $OUTPUT;
|
|
|
|
# Remove the default blog index to avoid pulling into the XML feed
|
|
rm $OUTPUT$BLOG_DIR/index.html
|
|
|
|
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>
|
|
<?xml-stylesheet href=\"style.xsl\" type=\"text/xsl\"?>
|
|
<rss version=\"2.0\">
|
|
<channel>
|
|
<title>$TITLE</title>
|
|
<link>$DOMAIN</link>
|
|
<description>$DESCRIPTION</description>
|
|
<copyright>$COPYRIGHT</copyright>
|
|
<ttl>$TTL</ttl>";
|
|
|
|
for file in $OUTPUT$BLOG_DIR*; do
|
|
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>.*//')
|
|
CAT_DATE=$(date -d "$(sed -n 's|^<p class="date">\([^<]*\)</p>$|\1|p' $file)" +"%Y/%m/%d/%u")
|
|
POST_DATE=$(date -d "$(sed -n 's|^<p class="date">\([^<]*\)</p>$|\1|p' $file)" +"%a, %d %b %Y")
|
|
echo "<item>
|
|
<pubDate>$POST_DATE $TIME</pubDate>
|
|
<category>$CAT_DATE</category>
|
|
<title>$POST_TITLE</title>
|
|
<link>$DOMAIN/$BLOG_DIR$(basename ${file})</link>
|
|
<description><![CDATA[$POST_CONTENT]]></description>
|
|
<author>$AUTHOR</author>
|
|
<guid>$DOMAIN/$BLOG_DIR$(basename ${file})</guid>
|
|
</item>";
|
|
done
|
|
|
|
echo " </channel>
|
|
</rss>";
|