shithub: werc

Download patch

ref: d97b856b26a1c5d2a467c006b3e8ebb677567e1e
parent: 5b1239bd6253f34178436af28df0987d1ada1df8
author: uriel <uriel@engel.se.cat-v.org>
date: Sun Jan 4 18:21:55 EST 2009

Simplify and optimize some of the canonical-url-redirections.

--- a/bin/werc.rc
+++ b/bin/werc.rc
@@ -192,13 +192,17 @@
     login_user
 }
 
-if(! ~ $args '') {
-    if(~ $args($#args) 'index')
-        perm_redirect `{echo $req_path | sed 's,/index$,/,'}
-        
-    pageTitle=`{echo $args | sed -e 's/ / - /g' -e 's/_/ /g'}
-}
+if(! ~ $#args 0)
+    pageTitle=`{ echo $args|sed -e 's/ / - /g' -e 's/_/ /g' }
 
+if(~ $req_path '/index')
+    perm_redirect `{echo $req_path | sed 's,/index$,/,'}
+
+if(~ $local_path */)
+    local_path=$local_path^'index'
+if not if(test -d $local_path)
+    perm_redirect $req_path^'/'
+
 p=()
 cd $sitedir
 if(test -f _werc/config)
@@ -230,13 +234,6 @@
 	pageTitle=$siteTitle^' '^$siteSubTitle
 if not
 	pageTitle=$"pageTitle^' | '^$"siteTitle^' '^$"siteSubTitle
-
-
-if(test -d $local_path) {
-    if(! ~ $local_path */)
-    	perm_redirect $req_path^'/'
-    local_path=$local_path^'index'
-}
 
 select_handler