shithub: werc

Download patch

ref: cf074093fbb7535178428ecff8b8648305cdf216
parent: d2861fd8f00aa15323ee136f612d7b36c8fea0f5
author: uriel <uriel@engel.se.cat-v.org>
date: Sun Dec 28 06:51:03 EST 2008

Minor comment cleanups.

--- a/apps/blagh/app.rc
+++ b/apps/blagh/app.rc
@@ -1,9 +1,29 @@
-fn blagh_test {
-    ! ~ $#blaghDirs 0 # && test -d / `{echo '-a -d '^blaghDirs}
-}
+fn blagh_init {
+    if(~ $#blaghDirs 0 && ~ $req_path */[bB]log/index)
+        blaghDirs=( . )
 
-fn blagh_setup {
-    app_body_handler='blagh_body'
+    # Should not match sub-dirs!
+    if(! ~ $#blaghDirs 0) {
+    # && test -d / `{echo '-a -d '^$req_path^$blaghDirs}
+
+        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]/*)
+            status='Use default handler'
+
+        if not if(~ $req_path */index) {
+            app_body_handler='blagh_body'
+            #u=`{cleanname $baseuri^`{basename -d '/'^$uri}|sed 's,:/,://,'} # Sed recovers '/' in 'http:/' stripped by cleanname
+            u=`{cleanname $baseuri^$req_path'index}
+            extraHeaders=$"extraHeaders ^ \
+'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" />' ^ \
+'<link rel="alternate" type="application/atom+xml" title="ATOM" href="'$"u'.atom" />'
+
+        }
+        if not if(~ $req_path */index.atom)
+            app_body_handler='blagh_body'
+        if not if(~ $req_path */index.rss)
+            app_body_handler='blagh_body'
+
+    }
 }
 
 fn blagh_body {
--- a/apps/hello/app.rc
+++ b/apps/hello/app.rc
@@ -1,10 +1,8 @@
-fn hello_test {
-    ~ $req_path /hello
-}
-
-fn hello_setup {
-    app_body_handler = 'hello_body'
-    pageTitle='Hi title!'
+fn hello_init {
+    if(~ $req_path /hello) {
+        app_body_handler = 'hello_body'
+        pageTitle='Hi title!'
+    }
 }
 
 fn hello_body {
--- a/bin/cgilib.rc
+++ b/bin/cgilib.rc
@@ -265,10 +265,8 @@
     found=()
     for(a in $enabled_apps) {
         . ./apps/$a/app.rc
-        if($a^'_test') {
-            $a^'_setup'
+        if($a^'_test')
             found=yes
-        }
     }
 
     ~ $#found 1 # Set status
--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -31,7 +31,7 @@
 
 # Sidebar 
 fn gensidebar {
-    # Ignore stderr, last item in path might be a file that doesn't exist (eg., foo for foo.md)
+    # Ignore stderr, last path element might be a file that doesn't exist (eg., foo for foo.md)
     ls -F $sitedir^/./^$req_paths_list >[2]/dev/null | sed 's,^'$sitedir',,; '^$dirfilter | sort -u | awk -F/ ' 
     function p(x, y, s) {
         for(i=0; i < x-y; i+=1)
@@ -248,7 +248,6 @@
 p=()
 cd $sitedir
 for(i in ('' $args)) {
-    # TODO We can build a list of paths here that can be used in sidebar, instead of iterating args twice
     p=($"p^/^$i)
     req_paths_list=($req_paths_list $p)
     # We don't want blog settings to cascade into posts, note that we are inBlog instead