swerc

anselm's simpler werc fork
git clone git://git.suckless.org/swerc
Log | Files | Refs | README

commit 1995d43d318899ae8f1cdbd29f86ca1e2c86eca2
parent b120c41df52caf60d9f2d12fa37a255d98a61d6d
Author: uriel@engel.se.cat-v.org <unknown>
Date:   Sun, 11 Jan 2009 04:40:40 +0100

Fix blah to work with new handler interfaces.
Remove outdated app-framework code.
Clanup some of the fallback handler setting code.
Diffstat:
Mapps/blagh/app.rc | 2+-
Mbin/cgilib.rc | 11+----------
Mbin/werc.rc | 14++++++++------
3 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/apps/blagh/app.rc b/apps/blagh/app.rc @@ -13,7 +13,7 @@ fn blagh_init { status='Use default handler' if not if(~ $req_path */index */) { - app_body_handler='blagh_body' + handler_body_main=blagh_body u=$blagh_uri'index' extraHeaders=$"extraHeaders ^ \ '<link rel="alternate" type="application/rss+xml" title="RSS" href="'$"u'.rss" /> diff --git a/bin/cgilib.rc b/bin/cgilib.rc @@ -279,19 +279,10 @@ fn make_blog_post { # App framework fn init_apps { - found=() for(a in $enabled_apps) { . ./apps/$a/app.rc - if($a^'_init') - found=yes + $a^'_init' } - - ~ $#found 1 # Set status -} - -fn app_handler { - if(! ~ $#app_body_handler 0) - $app_body_handler } diff --git a/bin/werc.rc b/bin/werc.rc @@ -103,17 +103,19 @@ fn setup_handlers { init_apps # Dir listing - if(~ $#handler_body_main 0 && ~ $local_path */index) - set_handler dir_listing_handler $local_path + if(! ~ $#handler_body_main 0) + { } # Pass + if not if(~ $local_path */index) + handler_body_main=(dir_listing_handler $local_path) # Explicit .html urls, the web server might handle this first! - if not if(~ $#handler_body_main 0 && ~ $local_path *.html && test -f $local_path) + if not if(~ $local_path *.html && test -f $local_path) perm_redirect `{ echo $req_path|sed 's/.html$//' } # Fallback static file handler - if not if(~ $#handler_body_main 0 && test -f $local_path) + if not if(test -f $local_path) static_file $local_path # File not found - if not if(~ $#handler_body_main 0) { - set_handler tpl_handler `{get_lib_file 404.tpl} + if not { + handler_body_main=(tpl_handler `{get_lib_file 404.tpl}) dprint 'NOT FOUND: '$SERVER_NAME^$"REQUEST_URI^' - '^$"HTTP_REFERER^' - '^$"HTTP_USER_AGENT echo 'Status: 404 Not Found' }