commit 3bdbe1390435b133a13eb9a45c1f239b65aeed95
parent 2f62dfc440802134166d0ba4df9f3442fd30fa75
Author: uriel@engel.se.cat-v.org <unknown>
Date: Tue, 14 Oct 2008 01:59:10 +0200
More minnor comment and code formatting changes
Diffstat:
2 files changed, 61 insertions(+), 2 deletions(-)
diff --git 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; 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
@@ -203,7 +203,6 @@ fn select_handler {
extraHeaders=$"extraHeaders ^ \
'<link rel="alternate" type="application/rss+xml" title="RSS" href="'$rssuri'" />
'
-
set_handler blog_dir_handler $blogDirs
}
@@ -229,7 +228,6 @@ fn select_handler {
fn genbody {
- # Actually execute request
$handler $handler_args
}