changelog shortlog tags branches files raw gz bz2 help

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

changeset 318: dcc289b14b9f
parent 317: c062cb8f9c32
child 319: 1778dca75833
author: uriel@engel.se.cat-v.org
date: Tue, 13 Jan 2009 03:19:45 +0100
files: apps/blagh/app.rc
description: Blagh: improve handler setup for atom/rss feeds, also filter out blog posts with non-url-allowed path elements.
     1.1--- a/apps/blagh/app.rc	Tue Jan 13 03:18:19 2009 +0100
     1.2+++ b/apps/blagh/app.rc	Tue Jan 13 03:19:45 2009 +0100
     1.3@@ -20,16 +20,20 @@
     1.4 <link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.atom" />'
     1.5 
     1.6         }
     1.7-        if not {
     1.8-            response_format=raw
     1.9-            if(~ $req_path */index.atom)
    1.10-                master_template=_apps/blagh/atom.tpl
    1.11-            if not if(~ $req_path */index.rss)
    1.12-                master_template=_apps/blagh/rss20.tpl
    1.13-        }
    1.14+        if not if(~ $req_path */index.atom)
    1.15+            blagh_setup_feed_handlers atom.tpl
    1.16+        if not if(~ $req_path */index.rss)
    1.17+            blagh_setup_feed_handlers rss20.tpl
    1.18     }
    1.19 }
    1.20 
    1.21+fn blagh_setup_feed_handlers {
    1.22+    handler_body_main=NOT_USED_by_blagh_feeds
    1.23+    headers=() # Headers included in master tpl
    1.24+    res_tail=()
    1.25+    master_template=_apps/blagh/$1
    1.26+}
    1.27+
    1.28 fn blagh_body {
    1.29     for(p in `{get_post_list $blagh_root^$blaghDirs}) {
    1.30         l=`{echo -n $p|sed 's!'$sitedir^$req_path'!!'}
    1.31@@ -40,7 +44,7 @@
    1.32 fn get_post_list {
    1.33     # the /./->/|/ are added so we can sort -t| and order only the file name
    1.34     # NOTE: this breaks if any path element in blogDirs contain '/./' or '|'
    1.35-    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,/+\|/+,/,'
    1.36+    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,/+\|/+,/,'
    1.37 }
    1.38 
    1.39