Blagh: improve handler setup for atom/rss feeds, also filter out blog posts with non-url-allowed path elements.

This commit is contained in:
Uriel 2009-01-13 03:19:45 +01:00
parent 96a115b37b
commit d4ecd11693

View file

@ -20,16 +20,20 @@ fn blagh_init {
<link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.atom" />' <link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.atom" />'
} }
if not { if not if(~ $req_path */index.atom)
response_format=raw blagh_setup_feed_handlers atom.tpl
if(~ $req_path */index.atom)
master_template=_apps/blagh/atom.tpl
if not if(~ $req_path */index.rss) if not if(~ $req_path */index.rss)
master_template=_apps/blagh/rss20.tpl 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 { fn blagh_body {
for(p in `{get_post_list $blagh_root^$blaghDirs}) { for(p in `{get_post_list $blagh_root^$blaghDirs}) {
l=`{echo -n $p|sed 's!'$sitedir^$req_path'!!'} l=`{echo -n $p|sed 's!'$sitedir^$req_path'!!'}
@ -40,7 +44,7 @@ fn blagh_body {
fn get_post_list { fn get_post_list {
# the /./->/|/ are added so we can sort -t| and order only the file name # 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 '|' # 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,/+\|/+,/,'
} }