changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > werc / changeset: Simplify init code to take advantage of the new blagh_root variable. Fix and cleanup various things.

changeset 352: cfc76b6a4254
parent 351: e6e6f75df936
child 353: 7fdba0a7c348
author: uriel@engel.se.cat-v.org
date: Fri, 23 Jan 2009 16:44:42 +0100
files: apps/blagh/app.rc
description: Simplify init code to take advantage of the new blagh_root variable. Fix and cleanup various things.
     1.1--- a/apps/blagh/app.rc	Thu Jan 22 14:24:48 2009 +0100
     1.2+++ b/apps/blagh/app.rc	Fri Jan 23 16:44:42 2009 +0100
     1.3@@ -1,25 +1,23 @@
     1.4-# XXX Should use a function to enable blagh instead of depending on blaghDirs, that way we can save the path of the root of the blog.
     1.5 fn conf_enable_blog {
     1.6-    blagh_root=$conf_wd
     1.7+    blagh_uri=$conf_wd
     1.8     blagh_dirs=$*
     1.9     if(~ $#blagh_dirs 0)
    1.10-        blagh_dirs=$conf_wd
    1.11+        blagh_dirs=( . )
    1.12 }
    1.13 
    1.14 fn blagh_init {
    1.15-    if(~ $#blaghDirs 0 && ~ $local_path */[bB]log/index*)
    1.16-        blaghDirs=( . )
    1.17+    if(~ $#blagh_dirs 0 && ~ $req_path */[bB]log/) {
    1.18+        blagh_uri=$req_path
    1.19+        blagh_dirs=( . )
    1.20+    }
    1.21 
    1.22     # Should not match sub-dirs!
    1.23-    if(! ~ $#blaghDirs 0) {
    1.24-    # && test -d / `{echo '-a -d '^$req_path^$blaghDirs}
    1.25-        blagh_uri=`{echo $req_path|sed 's/index(\.(atom|rss))?$//'}
    1.26-        blagh_url=$base_uri^$blagh_root_path
    1.27+    if(! ~ $#blagh_dirs 0) {
    1.28+    # && test -d / `{echo '-a -d '^$blagh_root^$blagh_dirs}
    1.29+        blagh_url=$base_url^$blagh_uri
    1.30         blagh_root=$sitedir^$blagh_uri
    1.31 
    1.32-        # XXX This is a hideous hack, blogs in dirs that match the number patern wont work, and dirs inside posts (eg., comments) wont work either.
    1.33-        # The problem is how to find out the 'root' of this blog, blaghDirs is useless for that.
    1.34-        if(~ $req_path */ && ! ~ $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]/*) {
    1.35+        if(~ $req_path */ && ~ $req_path $blagh_uri) {
    1.36             handler_body_main=blagh_body
    1.37             u=$blagh_uri'index'
    1.38             extraHeaders=$"extraHeaders ^ \
    1.39@@ -41,7 +39,7 @@
    1.40 }
    1.41 
    1.42 fn blagh_body {
    1.43-    for(p in `{get_post_list $blagh_root^$blaghDirs}) {
    1.44+    for(p in `{get_post_list $blagh_root^$blagh_dirs}) {
    1.45         l=`{echo -n $p|sed 's!'$sitedir^$req_path'!!'}
    1.46         sed '1s!.*![&]('$l')!' < $p/index.md | $formatter 
    1.47     }
    1.48@@ -49,7 +47,7 @@
    1.49 
    1.50 fn get_post_list {
    1.51     # the /./->/|/ are added so we can sort -t| and order only the file name
    1.52-    # NOTE: this breaks if any path element in blogDirs contain '/./' or '|'
    1.53+    # NOTE: this breaks if any path element in blagh_dirs contain '/./' or '|'
    1.54     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.55 }
    1.56