From 85f2c8d0d69ac0195bf6a20e396077dee0e9aefa Mon Sep 17 00:00:00 2001 From: Bradley Taunt Date: Fri, 19 Jan 2024 13:19:41 -0500 Subject: Initial commit for new cgit platform --- pblog.sh | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 pblog.sh (limited to 'pblog.sh') diff --git a/pblog.sh b/pblog.sh new file mode 100644 index 0000000..26d163c --- /dev/null +++ b/pblog.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +source _config.sh + +################################################################################### +# !WARNING! +# You probably don't need to tweak anything below this line. Edit at your own risk! +################################################################################### + +# 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 posts +for i in $POSTS; do pandoc --css=../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; + +rsync $POSTS_DIR*.html $OUTPUT$WEB_HTML; +rm $POSTS_DIR*.html + +# 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 _footer.html -B _header.html -s $i -o ${i%.*}.html; done; + +rsync $PAGES_DIR*.html $OUTPUT; +rm $PAGES_DIR*.html + +# Copy XSLT, stylesheet, and media files +rsync rss.xsl $OUTPUT; +rsync style.css $OUTPUT; +rsync -r media $OUTPUT; + +# Remove the default blog index to avoid pulling into the XML feed +rm $OUTPUT$WEB_HTML/index.html + +echo " + + + + $TITLE + $DOMAIN + $DESCRIPTION + $COPYRIGHT + $TTL"; + +for file in $OUTPUT$WEB_HTML*; do + +POST_DATE=$(sed -n 's|^

\([^<]*\)

$|\1|p' $file) +POST_TITLE=$(sed -n 's|^

\([^<]*\)

$|\1|p' $file) +POST_CONTENT=$(sed -n '/
/,/<\/article>/p' $file | sed -e '1s/.*
//' -e '$s/<\/article>.*//') + +if [[ $OS = "BSD" ]] +then + CAT_DATE=$(gdate -d "$(sed -n 's|^

\([^<]*\)

$|\1|p' $file)" +"%Y/%m/%d/%u") + POST_DATE=$(gdate -d "$(sed -n 's|^

\([^<]*\)

$|\1|p' $file)" +"%a, %d %b %Y") +else + CAT_DATE=$(date -d "$(sed -n 's|^

\([^<]*\)

$|\1|p' $file)" +"%Y/%m/%d/%u") + POST_DATE=$(date -d "$(sed -n 's|^

\([^<]*\)

$|\1|p' $file)" +"%a, %d %b %Y") +fi + +echo " + $POST_DATE $TIME + $CAT_DATE + $POST_TITLE + $DOMAIN/$WEB_HTML$(basename ${file}) + + $AUTHOR + $DOMAIN/$WEB_HTML$(basename ${file}) + "; +done + +echo " +"; -- cgit v1.2.3-54-g00ecf