changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > werc / changeset: Add some comments and replace get_post_args with load_post_args

changeset 358: 031828ebade4
parent 357: be5fe6949481
child 359: 5ab742b6c3ee
author: uriel@engel.se.cat-v.org
date: Sat, 24 Jan 2009 07:11:39 +0100
files: apps/bridge/app.rc bin/cgilib.rc bin/werc.rc lib/_debug.tpl lib/_users/login.tpl
description: Add some comments and replace get_post_args with load_post_args
     1.1--- a/apps/bridge/app.rc	Fri Jan 23 17:51:23 2009 +0100
     1.2+++ b/apps/bridge/app.rc	Sat Jan 24 07:11:39 2009 +0100
     1.3@@ -1,4 +1,5 @@
     1.4 fn bridge_init {
     1.5+    # XXX: Should avoid running for 404s, dir lists, etc.
     1.6     if(! ~ $#enable_comments 0) {
     1.7         ll_add handlers_body_foot bridge_body_foot 
     1.8         if(get_post_args comment_text) {
     1.9@@ -19,9 +20,10 @@
    1.10             }
    1.11 
    1.12             umask 002
    1.13-            mkdir -m 775 -p $d
    1.14-            echo $u > $d/user
    1.15-            echo $comment_text > $d/body
    1.16+            if(mkdir -m 775 -p $d) { # Rudimentary perm checking
    1.17+                echo $u > $d/user
    1.18+                echo $comment_text > $d/body
    1.19+            }
    1.20         }
    1.21     }
    1.22 
     2.1--- a/bin/cgilib.rc	Fri Jan 23 17:51:23 2009 +0100
     2.2+++ b/bin/cgilib.rc	Sat Jan 24 07:11:39 2009 +0100
     2.3@@ -186,11 +186,10 @@
     2.4 # Check loggin status, if called with group arg we check membership too
     2.5 fn check_user {
     2.6     if(! get_user)
     2.7-        status='Not logged in:' $status
     2.8-    if not if(~ $#1 1 && ! grep -s '^'^$logged_user^'$' etc/groups/$1)
     2.9-        status=User $logged_user not in group $1
    2.10-    if not
    2.11-        status=()
    2.12+        _status='Not logged in:' $status
    2.13+    if not if(! ~ $#* 0 && ! grep -s '^'^$logged_user^'$' etc/groups/$*)
    2.14+        _status=User $logged_user not in groups $*
    2.15+    status=$_status
    2.16 }
    2.17 
    2.18 # If not logged in, try to get user login info from POST or from cookie
     3.1--- a/bin/werc.rc	Fri Jan 23 17:51:23 2009 +0100
     3.2+++ b/bin/werc.rc	Sat Jan 24 07:11:39 2009 +0100
     3.3@@ -98,7 +98,8 @@
     3.4     if not if(test -f $local_path.txt)
     3.5         handler_body_main=(txt_handler $local_path.txt)
     3.6 
     3.7-    # Apps, XXX: Maybe we should check that $enabled_apps exist in $werc_apps.
     3.8+    # XXX Should check that $enabled_apps exist in $werc_apps?
     3.9+    # XXX Should split init of apps that provide main handler (eg., blog) and apps that don't (eg., comments)?
    3.10     if(! ~ $#enabled_apps 0)
    3.11         for(a in $enabled_apps)
    3.12             $a^'_init'
    3.13@@ -162,7 +163,7 @@
    3.14 
    3.15 # Hack: preload post data so we can access it from templates where cgi's stdin is not accesible
    3.16 if(~ $REQUEST_METHOD POST) {
    3.17-    get_post_args 
    3.18+    load_post_args
    3.19     login_user
    3.20 }
    3.21 
     4.1--- a/lib/_debug.tpl	Fri Jan 23 17:51:23 2009 +0100
     4.2+++ b/lib/_debug.tpl	Sat Jan 24 07:11:39 2009 +0100
     4.3@@ -1,6 +1,29 @@
     4.4-<pre>
     4.5+% if(! ~ $#debug_shell 0) {
     4.6+<form method="POST" name="prompt">
     4.7+<input type="text" name="command" />
     4.8+<input type="submit" Value="Run" />
     4.9+</form>
    4.10+<script language="javascript"><!--
    4.11+document.prompt.command.focus()
    4.12+//--></script>
    4.13+
    4.14+%{
    4.15+fn evl {
    4.16+    # Buffering is probably messing this up:
    4.17+    #rc -c 'flag x +;{'^$post_arg_command'} |[2] awk ''{print ">> "$0}'''
    4.18+    rc -c 'flag x +;'^$post_arg_command
    4.19+}
    4.20+    if(! ~ $#post_arg_command 0 && ! ~ $#post_arg_command '') {
    4.21+        echo '<hr /><pre>'
    4.22+        evl | escape_html |[2] awk '{print "<b>"$0"</b>"}' 
    4.23+        echo '</pre>'
    4.24+    }
    4.25+%}
    4.26+% }
    4.27+
    4.28+<hr /><pre>
    4.29 % env | escape_html
    4.30----------------------
    4.31+</pre><hr />
    4.32+
    4.33 % umask
    4.34-</pre>
    4.35 
     5.1--- a/lib/_users/login.tpl	Fri Jan 23 17:51:23 2009 +0100
     5.2+++ b/lib/_users/login.tpl	Sat Jan 24 07:11:39 2009 +0100
     5.3@@ -1,13 +1,14 @@
     5.4-%{
     5.5-
     5.6-if(check_user)
     5.7-    echo 'You are logged in as' $logged_user
     5.8-if not if (~ $REQUEST_METHOD POST)
     5.9-    echo 'Login failed!'
    5.10-
    5.11-%}
    5.12+<h1>User login</h1>
    5.13+<br />
    5.14+% if(check_user) {
    5.15+    You are logged in as: <b>%($logged_user%)</b>
    5.16+% }
    5.17+% if not {
    5.18+%    if (~ $REQUEST_METHOD POST)
    5.19+%        echo 'Login failed!'
    5.20 <form method="POST">
    5.21     User name: <input type="text" name="user_name" /><br />
    5.22     User password: <input type="password" name="user_password" /><br />
    5.23     <input name="s" type="submit" value="Login" />
    5.24 </form>
    5.25+% }