From 5dfce814f685d7577f377f7eb14216f5c9318381 Mon Sep 17 00:00:00 2001 From: Uriel Date: Tue, 14 Oct 2008 01:59:10 +0200 Subject: [PATCH] More minnor comment and code formatting changes --- bin/cgilib.rc | 61 +++++++++++++++++++++++++++++++++++++++++++++++ bin/controller.rc | 2 -- 2 files changed, 61 insertions(+), 2 deletions(-) diff --git a/bin/cgilib.rc b/bin/cgilib.rc index 7408065..00dc689 100644 --- a/bin/cgilib.rc +++ b/bin/cgilib.rc @@ -1,5 +1,8 @@ # Useful functions +NEW_LINE = ' +' + fn dprint { echo $* >[1=2] } fn escape_html { sed 's/&/\&/g; s//\>/g' $* } @@ -89,3 +92,61 @@ BEGIN { } ' } + +# Auth code +# Cookie format: WERC_USER: name:timestamp:hash(name.timestamp.password) + +fn auth_user { + group = $1 + user_name = $2 + user_pass = $3 + + pfile = etc/users/$user_name/password + grep -s '^'^$user_name^'$' etc/groups/$group && test -f $pfile && ~ $user_pass `{cat $pfile} +} + + +fn make_blog_post { + bdir = $1 + title = $2 + + date=`{/bin/date +%F} + + n = 1 + for(f in $bdir/$date-*) { + i = `{echo $f | sed -n 's|^.*/'$date'-([0-9]+)_.*|\1|p'} + if(! ~ $#i 0 && test $i -ge $n) + n = `{hoc -e $i'+1'} + } + title = `{echo $"title | sed 's/[ ]+/_/g; 1q'} + + $bdir/$"date^'-'^$"n^_$"title.md + +} + + +# -------- + +app_blog_methods = ( _post index.rss ) +fn app_blog__post { + +} + +app_blog___default { + if (~ $blog + call_app blogpost +} + +# -- +app_blogpost_methods = ( comment _edit ) + +fn app_blogpost_comment { + call_app comments +}_ + +# -- +app_comments_methods = ( _post _edit ) + +fn app_comments___default { + +} diff --git a/bin/controller.rc b/bin/controller.rc index e3be887..ce26350 100755 --- a/bin/controller.rc +++ b/bin/controller.rc @@ -203,7 +203,6 @@ fn select_handler { extraHeaders=$"extraHeaders ^ \ ' ' - set_handler blog_dir_handler $blogDirs } @@ -229,7 +228,6 @@ fn select_handler { fn genbody { - # Actually execute request $handler $handler_args }