commit 3e74e81bad4e61c8b26b4fddb1a46ddd30dadfbe
parent 5de7250197a722d8e898723525fe578d73314d16
Author: uriel@engel.se.cat-v.org <unknown>
Date: Fri, 9 Jan 2009 03:08:02 +0100
Minor reorg of handler selection, move comment code to bridge app.
Bigger changes still to come.
Diffstat:
2 files changed, 33 insertions(+), 30 deletions(-)
diff --git a/apps/bridge/app.rc b/apps/bridge/app.rc
@@ -0,0 +1,26 @@
+fn bridge_init {
+ if(! ~ $#allowComments 0 && ~ $REQUEST_METHOD POST) {
+ get_post_args comment_text
+ d=`{date -n} # FIXME Obvious race
+ d=$local_path.md_werc/comments/$d/
+
+ u=$logged_user
+ if(~ $#logged_user 0) {
+ get_post_args comment_user_name comment_user_password
+ # TODO Should take this path too if the user can login but doesn't
+ # belong to required group
+ if(! login_user $comment_user_name $comment_user_password) {
+ u=$comment_user_name ':' $comment_user_password
+ d=$d^'_pending'
+ }
+ if not
+ u = $logged_user
+ }
+
+ umask 002
+ mkdir -m 775 -p $d
+ echo $u > $d/user
+ echo $comment_text > $d/body
+ }
+
+}
diff --git a/bin/werc.rc b/bin/werc.rc
@@ -93,43 +93,16 @@ fn dir_listing_handler {
fn select_handler {
- if(test -f $local_path.md) {
+ if(test -f $local_path.md)
set_handler md_handler $local_path.md
- if(! ~ $#allowComments 0 && ~ $REQUEST_METHOD POST) {
- get_post_args comment_text
- d=`{date -n} # FIXME Obvious race
- d=$local_path.md_werc/comments/$d/
-
- u=$logged_user
- if(~ $#logged_user 0) {
- get_post_args comment_user_name comment_user_password
- # TODO Should take this path too if the user can login but doesn't
- # belong to required group
- if(! login_user $comment_user_name $comment_user_password) {
- u=$comment_user_name ':' $comment_user_password
- d=$d^'_pending'
- }
- if not
- u = $logged_user
- }
-
- umask 002
- mkdir -m 775 -p $d
- echo $u > $d/user
- echo $comment_text > $d/body
- }
- }
+
if not if(test -f $local_path.tpl)
set_handler tpl_handler $local_path.tpl
if not if(test -f $local_path.html)
set_handler html_handler $local_path.html
- # Explicit .html urls, unfortunately usually the web server will handle this as static files
- if not if(~ $local_path *.html && test -f $local_path)
- perm_redirect `{ echo $req_path|sed 's/.html$//' }
-
- # Global tpl (eg sitemap.tpl)
+ # Global tpl (eg sitemap.tpl), should take precedence over txt handler!
if not if(test -f lib^$req_path^.tpl)
set_handler tpl_handler lib^$req_path^.tpl
@@ -144,6 +117,10 @@ fn select_handler {
if not if(~ $local_path */index)
set_handler dir_listing_handler $local_path
+ # Explicit .html urls, unfortunately usually the web server will handle this as static files
+ if not if(~ $local_path *.html && test -f $local_path)
+ perm_redirect `{ echo $req_path|sed 's/.html$//' }
+
# File not found
if not {
set_handler tpl_handler `{get_lib_file 404.tpl}