2008-12-28 03:51:03 -07:00
|
|
|
fn blagh_init {
|
2008-12-28 15:43:15 -07:00
|
|
|
if(~ $#blaghDirs 0 && ~ $local_path */[bB]log/index*)
|
2008-12-28 03:51:03 -07:00
|
|
|
blaghDirs=( . )
|
|
|
|
|
|
|
|
# Should not match sub-dirs!
|
|
|
|
if(! ~ $#blaghDirs 0) {
|
|
|
|
# && test -d / `{echo '-a -d '^$req_path^$blaghDirs}
|
2008-12-28 15:43:15 -07:00
|
|
|
blagh_uri=`{echo $req_path|sed 's/index(\.(atom|rss))?$//'}
|
2008-12-28 13:37:03 -07:00
|
|
|
blagh_url=$base_uri^$blagh_root_path
|
|
|
|
blagh_root=$sitedir^$blagh_uri
|
2008-12-28 15:43:15 -07:00
|
|
|
dprint $blagh_root
|
2008-12-28 03:51:03 -07:00
|
|
|
|
2008-12-28 13:37:03 -07:00
|
|
|
if(~ $req_path */[0-9][0-9][0-9][0-9]/ */[0-9][0-9][0-9][0-9]/[0-9][0-9]/ */[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/)
|
2008-12-28 03:51:03 -07:00
|
|
|
status='Use default handler'
|
|
|
|
|
2008-12-28 13:37:03 -07:00
|
|
|
if not if(~ $req_path */index */) {
|
2008-12-28 03:51:03 -07:00
|
|
|
app_body_handler='blagh_body'
|
2008-12-28 13:37:03 -07:00
|
|
|
u=$blagh_uri'index'
|
2008-12-28 03:51:03 -07:00
|
|
|
extraHeaders=$"extraHeaders ^ \
|
2008-12-28 13:37:03 -07:00
|
|
|
'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" />
|
|
|
|
<link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.atom" />'
|
2008-12-28 03:51:03 -07:00
|
|
|
|
|
|
|
}
|
2008-12-28 13:37:03 -07:00
|
|
|
if not {
|
|
|
|
response_format=raw
|
|
|
|
if(~ $req_path */index.atom)
|
|
|
|
master_template=_apps/blagh/atom.tpl
|
|
|
|
if not if(~ $req_path */index.rss)
|
|
|
|
master_template=_apps/blagh/rss20.tpl
|
|
|
|
if not
|
|
|
|
dprint XXXX $req_path
|
|
|
|
}
|
2008-12-24 04:19:06 -07:00
|
|
|
|
2008-12-28 15:43:15 -07:00
|
|
|
status=()
|
2008-12-28 03:51:03 -07:00
|
|
|
}
|
2008-12-24 04:19:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn blagh_body {
|
2008-12-28 13:37:03 -07:00
|
|
|
for(p in `{get_post_list $blagh_root^$blaghDirs}) {
|
|
|
|
l=`{echo -n $p|sed 's!'$sitedir^$req_path'!!'}
|
|
|
|
sed '1s!.*![&]('$l')!' < $p/index.md | $formatter
|
|
|
|
}
|
2008-12-24 04:19:06 -07:00
|
|
|
}
|
|
|
|
|
2008-12-28 13:37:03 -07:00
|
|
|
fn get_post_list {
|
|
|
|
d=$*^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/
|
|
|
|
ls -F $d >[2]/dev/null | sed -n 's,/\./,/|/,; /\/$/p' | sort -r '-t|' +1 | sed 's,/+\|/+,/,'
|
2008-12-24 04:19:06 -07:00
|
|
|
}
|