"
}'
}
fn gensidebar {
@{
cd $sitedir
menu .
}
}
fn sortedBlogPostList {
# the /./ is added so we can sort -t. and order only the file name
ls $*^'/./' | grep '[0-9]+.*\.md$'| sort -r -t. +1
}
# Body
fn genbody {
if ( test -f $body.md )
markdown.pl < $body.md
if not if ( test -f $body.tpl )
template.awk $body.tpl | rc
if not if(~ $body */index && ~ $#blogDirs 0) {
echo '
' `{basename `{basename -d $body}}'
'
echo '
'
ls -F `{ basename -d $body } | sed $dirfilter' s,^'$sitedir'/(.*),
'
}
if not if(~ $#blogDirs 0)
template.awk inc/404.tpl | rc
# Technically wrong. Will spit out blog entries after 404 for /blog/foo, for instance.
if(! ~ $#blogDirs 0) {
if ( ! ~ $blogTitle '' )
echo '
'$"blogTitle'
'
for ( f in `{ sortedBlogPostList $blogDirs } ) {
title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
du=`{ls -l $f}
echo '##' $title '*('By $du(4) Last mod: $du(7 8 9) ')*'
cat $f
echo
} | markdown.pl
}
}
. etc/initrc
if (! ~ $args '') {
title=$args($#args)
title=`{echo $title | sed 's/_/ /g' }
body=$uri
}
fpath=$sitedir
for ( i in '' $args ) {
fpath = $fpath/$i
if ( test -f $fpath/_config )
. $fpath/_config
}
template=$sitedir/$template.tpl
if (! ~ $#sidebar 0)
sidebar=tpl/_inc/$sidebar.tpl
body=$sitedir/$body
rssuri=$uri
if (test -d $body) {
body=$body/index
rssuri=$rssuri/
}
rssuri=`{cleanname `{basename -d $uri}^/index.rss}
rssuri=$baseuri$rssuri
if(! ~ $#blogDirs 0)
extraHeaders=$"extraHeaders ^ \
'
'
echo hesd: $extraHeaders
# RSS
fn statpost {
f = $1
uri = `{echo $f | sed 's,^'$basedir',,'}
title=`{basename $f | sed 's/^[0-9\-]*_(.*)\.md$/\1/; s/_/ /g' }
stat=`{stat -c '%Y %U' $f}
date=`{/bin/date -Rd @$stat(1)}
uri=$baseuri^`{cleanname `{echo -n $uri | sed 's/\.(md|tpl)//g'}}
by=$stat(2)
ifs=() {
summary=`{awk -v max'='1024 '{
nc += 1 + length;
if(nc > max) {
print substr($0, 1, nc - max) "..."
exit
}
print
}' $f | sed 's/\]\]>/Fucking goddamn XML garbage/g'}
}
}
fn template {
template.awk | rc |
awk '{
buf = buf $0"\n"
if(length(buf) > 8192) {
printf "%s", buf
buf = ""
}
}
END{ printf "%s", buf }'
}
if(! ~ $REQUEST_URI */index.rss) {
cat $headers $template | template
exit
}
uri = `{echo $uri | sed 's/indexrss$//'}
uri=$baseuri$"uri
# Should be in a separate file.
cat <<'!' | template
Content-Type: text/xml; charset=utf-8
%($siteTitle%)
%($uri%)
%($blogDesc%)en-usTom Duff's rc, and Kris Maglione's clever hackeryUriel Mangado <uriel99@gmail.com>
%{
for(f in `{sortedBlogPostList $blogDirs}) {
statpost $f
%} %($title%)%($by%)@noreply.cat-v.org
%($uri%)
%($uri%)%($date%)%($summary%)]]>
% }
!