swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit a386437604455a930c9c549a47528b2c48e2697d
parent f32034d4f8b1581b7d9133863009fcd1c5d4155f
Author: uriel@engel.se.cat-v.org <unknown>
Date:   Tue, 13 Jan 2009 03:19:45 +0100

Blagh: improve handler setup for atom/rss feeds, also filter out blog posts with non-url-allowed path elements.
Diffstat:
Mapps/blagh/app.rc | 20++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/apps/blagh/app.rc b/apps/blagh/app.rc @@ -20,16 +20,20 @@ fn blagh_init { <link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.atom" />' } - 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 if(~ $req_path */index.atom) + blagh_setup_feed_handlers atom.tpl + if not if(~ $req_path */index.rss) + blagh_setup_feed_handlers rss20.tpl } } +fn blagh_setup_feed_handlers { + handler_body_main=NOT_USED_by_blagh_feeds + headers=() # Headers included in master tpl + res_tail=() + master_template=_apps/blagh/$1 +} + fn blagh_body { for(p in `{get_post_list $blagh_root^$blaghDirs}) { l=`{echo -n $p|sed 's!'$sitedir^$req_path'!!'} @@ -40,7 +44,7 @@ fn blagh_body { fn get_post_list { # the /./->/|/ are added so we can sort -t| and order only the file name # NOTE: this breaks if any path element in blogDirs contain '/./' or '|' - ls -F $*^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/ >[2]/dev/null | sed -n 's,/\./,/|/,; /\/$/p' | sort -r '-t|' +1 | sed 's,/+\|/+,/,' + ls -F $*^/./[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/ >[2]/dev/null | sed -n '/'^$forbidden_uri_chars^'/d; s,/\./,/|/,; /\/$/p' | sort -r '-t|' +1 | sed 's,/+\|/+,/,' }