'
}
# Don't change var name or trailing ';', some dirs change the filter!
dirfilter = '/\/[._]/d; s,^\./,,; s,\.md$,,; s,\.html,,;'
# Sidebar
fn menu {
lsArgs = ( '-F' )
# XXX will not work properly for $#blogDirs > 1 and matching is hackish
if ( (! ~ $#inBlog 0) || ! ~ $#blogDirs 0 && (~ $blogDirs^/ *$1 *$1/) ) { # Work in progress XXX
lsArgs = ($lsArgs -r)
}
ls $lsArgs $1 | sed $dirfilter | awk -F/ '
BEGIN { print "
"
}'
}
fn gensidebar {
@{
cd $sitedir
menu .
}
}
fn sortedBlogPostList {
# the /./ is added so we can sort -t. and order only the file name
if (! ~ $#* 0)
ls $*^'/./' | grep '[0-9]+.*\.md$'| sort -r -t. +1
}
fn blogTitle {
title=`{basename $1 | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
permlink= `{echo $1 | sed 's,^/[a-z/]*www/,/,; s,^sites/[^/]*/*/,/,; s/\.md$//' }
du=`{ls -l $1}
echo '##' $"title^' *('By $du(4) Last mod: $du(7 8 9) ')*'
}
# Body
fn genbody {
if ( test -f $body.md ) {
if ( ! ~ $#inBlog 0 )
blogTitle $body.md | $formatter
$formatter < $body.md
}
if not if ( test -f $body.tpl )
template.awk $body.tpl | rc $rcargs
if not if ( test -f $body.txt ) {
echo '
'
}
if not if ( test -f $body.html )
cat $body.html | /bin/sed '0,/<[Bb][Oo][Dd][Yy][^>]*>/d; /<\/[Bb][Oo][Dd][Yy]>/,$d'
if not if (~ $body *.html && test -f $body )
cat $body | /bin/sed -i '0,/]*>/d;/<\/body>/,$d'
if not if ( ~ $body */[bB]log/index */[bB]log//index && ~ $#blogDirs 0 )
blogDirs = `{basename -d $body}
if not if ( test -f pub/^$reqpath^.tpl )
template.awk pub/^$reqpath^.tpl | rc $rcargs
if not if(~ $body */index && ~ $#blogDirs 0) {
echo '
'
}
if not if(~ $#blogDirs 0) {
#echo 'Status: 404 Not Found\n\n' # should go before starting to print body
template.awk inc/404.tpl | rc $rcargs
}
if(! ~ $#blogDirs 0) {
if ( ! ~ $blogTitle '' )
echo '