More minnor comment and code formatting changes

This commit is contained in:
Uriel 2008-10-14 01:59:10 +02:00
parent 0837caa70a
commit 5dfce814f6
2 changed files with 61 additions and 2 deletions

View file

@ -1,5 +1,8 @@
# Useful functions
NEW_LINE = '
'
fn dprint { echo $* >[1=2] }
fn escape_html { sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/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 {
}

View file

@ -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
}