[hackers] [diri] applied JG's recent changes, cleaned up dirirc, renamed template into template.awk

From: <arg_AT_suckless.org>
Date: Thu Apr 26 11:40:15 2007

changeset: 70:87d6cb117425
tag: tip
user: arg_AT_suckless.org
date: Thu Apr 26 11:36:20 2007 +0200
summary: applied JG's recent changes, cleaned up dirirc, renamed template into template.awk

diff -r 834b4ad9f0d8 -r 87d6cb117425 common.rc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/common.rc Thu Apr 26 11:36:20 2007 +0200
@@ -0,0 +1,35 @@
+. /etc/dirirc
+
+fn redirect {
+ echo Location: $ADDRESS/$"*
+ echo
+ exit 0
+}
+
+fn setvars {
+ ifs='&
+' for(pair in `{cat}) {
+ pair = `{echo -n $pair | sed 's/=/\&/'} \
+ ifs=() \
+ if(~ $pair(1) $*)
+ eval $pair(1)'=`{urldecode $pair(2)}'
+ }
+}
+
+fn passok {
+ test $"* && ~ `{hash $"*} $PASSHASH
+}
+
+fn do_template {
+ # awk => buffer
+ template $TEMPLATE | rc \
+ | awk '{ buf = buf $0"\n"; if(length buf > 65535) { printf "%s", buf; buf = "" } } END{ printf "%s", buf }'
+}
+
+if(~ $PATH_INFO '' || echo $PATH_INFO | ! grep -s '^[a-zA-Z0-9_/]+$')
+ redirect $SHOW/
+
+PATH_INFO=`{cleanname $PATH_INFO | sed 's,^/,,'}
+if(~ $PATH_INFO '')
+ PATH_INFO=''
+base=$DIRIDIR/$PATH_INFO
diff -r 834b4ad9f0d8 -r 87d6cb117425 contrib/template.awk
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/template.awk Thu Apr 26 11:36:20 2007 +0200
@@ -0,0 +1,55 @@
+#!/usr/bin/awk -f
+function pr(str) {
+ if(lastc !~ "[{(]")
+ gsub(/'/, "''", str)
+ printf "%s", str
+}
+function trans(c) {
+ printf "%s", end
+
+ lastc = c
+ end = "\n"
+ if(c == "%")
+ end = ""
+ else if(c == "(")
+ printf "echo -n "
+ else if(c ~ "[})]") {
+ end = "'\n"
+ printf "echo -n '"
+ }
+}
+
+BEGIN {
+ lastc = "{"
+ trans("}")
+}
+END {
+ print end
+}
+
+/^%/ && $0 !~ /^%[{()}%]/ && lastc !~ /[({]/ {
+ trans("%")
+ print substr($0, 2)
+ next
+}
+{
+ if(lastc == "%")
+ trans("}")
+ n = split($0, a, "%")
+ pr(a[1])
+ for(i=2; i<=n; i++) {
+ c = substr(a[i], 1, 1)
+ rest = substr(a[i], 2)
+
+ if((lastc !~ "[({]" && c ~ "[({]") ||
+ (lastc == "{" && c == "}") ||
+ (lastc == "(" && c == ")"))
+ trans(c)
+ else if(c == "%")
+ pr("%")
+ else
+ pr("%" c)
+ pr(rest)
+ }
+ pr("\n")
+}
diff -r 834b4ad9f0d8 -r 87d6cb117425 dirirc
--- a/dirirc Sat Mar 31 07:29:33 2007 +0200
+++ b/dirirc Thu Apr 26 11:36:20 2007 +0200
@@ -1,13 +1,24 @@ ADDRESS=http://www.example.com
-ADDRESS=http://www.example.com
+ADDRESS=http://www.somehost.org
 DIRIDIR=/var/www/diri
-HASHCMD=sha1
-HASHPASSWD=94779b692fe5fd6c5adcf7e24216cf31a33d2fa8
-PLAN9=/usr/local/plan9
-PATH=$PLAN9/bin:$PATH
 SLOGAN='your slogan'
-URLDECODE=/usr/local/bin/urldecode.awk
-WIKIFMT=/usr/local/bin/markdown.pl
+PASSHASH=your hash
 SHOW=show.rc
 EDIT=edit.rc
 REMOVE=remove.rc
-SAVE=save.rc
+TEMPLATE=./tmpl.html
+
+fn wikifmt { ./contrib/markdown.pl $* }
+fn template { ./contrib/template.awk $* }
+fn urldecode { echo -n $"* | ./contrib/urldecode.awk }
+fn hash { echo -n $"* }
+fn title {
+ echo `{basename $PATH_INFO | sed 's/^[0-9]+_//; s/_/ /g'} '&mdash;' \
+ `{basename -d $PATH_INFO | sed 's,^/,,'} '&mdash;' \
+ `{echo $ADDRESS | sed 's,^https?://(www\.)?([^/]+).*,\2,'}
+
+}
+
+if(~ $PLAN9 '')
+ PLAN9=/usr/local/plan9
+path=($PLAN9/bin $path)
+
diff -r 834b4ad9f0d8 -r 87d6cb117425 edit.rc
--- a/edit.rc Sat Mar 31 07:29:33 2007 +0200
+++ b/edit.rc Thu Apr 26 11:36:20 2007 +0200
@@ -1,80 +1,61 @@
 #!/usr/local/plan9/bin/rc
-. /etc/dirirc
+. ./common.rc
 
-if(! test $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$'
- || echo $PATH_INFO | grep -v -s '[a-zA-Z0-9]')
-{
- echo Location: $ADDRESS/$SHOW
- echo
- exit 0
+if(test -d $base)
+ redirect $SHOW/$PATH_INFO
+
+setvars text save preview password
+
+if(test $"save) {
+ echo Pass: $password Save: $save >[1=2]
+ if(passok $password) {
+ . ./save.rc
+ redirect $SHOW/$PATH_INFO
+ }
+ if not
+ error = 'Incorrect password'
 }
-PATH_INFO=`{cleanname $PATH_INFO | sed 's/^.//'}
-if(test -d $DIRIDIR/$PATH_INFO) {
- echo Location: $ADDRESS/$SHOW/$PATH_INFO
- echo
- exit 0
+
+fn escape { sed 's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g' $* }
+fn text {
+ if(~ $text '' && test -f $base.diri)
+ cat $base.diri
+ if not
+ echo -n $text
 }
-title=( Edit: `{basename $PATH_INFO | sed 's/^[0-9]+_//; s/_/ /g'} '&mdash;' \
- `{basename -d $PATH_INFO | sed 's,^/,,'} '&mdash;' \
- `{echo $ADDRESS | sed 's,^https?://(www\.)?,,'})
-cat <<END
-Cache-Control: no-cache
-Content-Type: text/html
 
-<!DOCTYPE HTML SYSTEM>
-<html>
- <head>
- <title>$title</title>
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="pragma" content="no-cache">
- <meta name="author" content="Anselm R. Garbe">
- <meta name="searchtitle" content="dwm wmii suck less">
- <meta name="keywords" content="x11 dwm wmi wmii dmenu slock suck less window manager xlib">
- <meta name="description" content="dynamic window manager improved 2">
- <meta name="revisit-after" content="2 days">
- <meta name="audience" content="all">
- <meta name="content-language" content="en">
- <meta name="copyright" content="(C)opyright 2006-2007 by Anselm R. Garbe">
- <meta name="robots" content="noindex,nofollow">
- <style type="text/css">
- body { background-color: #444; color: #ddd; font-family: sans-serif; margin: 0px 0px 0px 0px; max-width: 80em; }
- img { border: 0px; /* top right bartom left */ }
- a { color: #9cf; }
- textarea { background-color: #444; border: 1px solid #555; color: #eee; width: 100%; }
- input { background-color: #444; border: 1px solid #555; color: #eee; }
- div#editor{ background-color: #333; border: 0px; color: #ddd; padding: 2%; width: 96%; }
- div#bar { background-color: #222; border: 0px; clear: both; padding: 5px 1% 5px 0px; text-align: right; width: 99%; }
- </style>
- </head>
- <body>
- <div id="bar">
- <i>$SLOGAN</i>
- </div>
+title=(Edit: `{title})
+ifs=() {body=`{cat<<'!'}}
                 <div id="editor">
- <h1>
-END
- echo $PATH_INFO
-cat <<END
-</h1>
- <form action="$ADDRESS/$SAVE/$PATH_INFO" method="post">
- <textarea name='text' id='text' cols='80' rows='43'>
-END
-if(test -f $DIRIDIR/$PATH_INFO.diri)
- cat $DIRIDIR/$PATH_INFO.diri
-cat <<END
-</textarea>
- <p><small>
+%{
+ error $error
+ if(test $"preview) {
+%}
+ <H1>Preview:</H1>
+ <div id="preview">
+% text | wikifmt
+ </div>
+%{
+ }
+%}
+ <h1>%($PATH_INFO%)</h1>
+ <form action="%($ADDRESS/$EDIT/$PATH_INFO%)" method="post">
+ <textarea name="text" id="text" cols="80" rows="43">%{
+ text | escape
+ %}</textarea>
+ <p>
+ <small>
                                 diri documents are written using Markdown syntax.
- </small></p>
+ </small>
+ </p>
                                 <p align="right">
- <b>Password:</b> <input type='password' name='password' size='20'/>
- <input type='submit' value='Save'/><br />
+ <b>Password:</b> <input type="password" name="password" size="20"/>
+ <input type="submit" name="save" value="Save"/>
+ <input type="submit" name="preview" value="Preview" style="margin-left: .5em"/><br />
                                 </p>
                         </form>
                 </div>
- <div id="bar">
- <small>&copy Copyright 2007 Anselm R. Garbe Impressum</small>
- </div>
- </body>
-</html>
-END
+!
+
+do_template
+
diff -r 834b4ad9f0d8 -r 87d6cb117425 hg.rc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hg.rc Thu Apr 26 11:36:20 2007 +0200
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+#
+# An example CGI script to export multiple hgweb repos, edit as necessary
+
+import cgitb, sys
+cgitb.enable()
+
+# sys.path.insert(0, "/path/to/python/lib") # if not a system-wide install
+from mercurial import hgweb
+
+# The config file looks like this:
+# [paths]
+# virtual/path = /real/path
+# virtual/path = /real/path
+
+# Alternatively you can pass a list of ('virtual/path', '/real/path') tuples
+# or use a dictionary with entries like 'virtual/path': '/real/path'
+
+h = hgweb.hgwebdir("/var/www/repos.list")
+h.run()
diff -r 834b4ad9f0d8 -r 87d6cb117425 remove.rc
--- a/remove.rc Sat Mar 31 07:29:33 2007 +0200
+++ b/remove.rc Thu Apr 26 11:36:20 2007 +0200
@@ -1,89 +1,35 @@
 #!/usr/local/plan9/bin/rc
-. /etc/dirirc
+. ./common.rc
 
-fn redirect {
- echo Location: $ADDRESS/$"*
- echo
- exit 0
+setvars password
+if(test $"password) {
+ if(passok $password) {
+ if(test -e $DIRIDIR/$PATH_INFO) {
+ /bin/rm -rf $DIRIDIR/$PATH_INFO.diri
+ /bin/rm -rf $DIRIDIR/$PATH_INFO
+ }
+ redirect $SHOW ^ `{echo /$PATH_INFO | sed 's/(.*/)/\1/'}
+ }
+ error = 'Incorrect password'
 }
 
-fn setvars {
- for(input in `{sed 's/\&/ /g'}) {
- for(var) {
- if(echo $"input | grep -s '^'$"var'=') {
- value=`{echo $"input | sed 's/^'$"var'=//'}
- eval $"var'=$"value'
- }
- }
- }
-}
+title=(Remove: `{title})
 
-if(! test $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$')
- redirect $SHOW
-PATH_INFO=`{cleanname $PATH_INFO | sed 's/^.//'}
-setvars password
-if(test $password) {
- password=`{echo -n $password | $URLDECODE | $HASHCMD}
- if(! ~ $password $HASHPASSWD || test ! $text)
- redirect $SHOW/$PATH_INFO
- if(test -e $DIRIDIR/$PATH_INFO) {
- /bin/rm -rf $DIRIDIR/$PATH_INFO.diri
- /bin/rm -rf $DIRIDIR/$PATH_INFO
- }
- redirect $SHOW
-}
-title=( Remove: `{basename $PATH_INFO | sed 's/^[0-9]+_//; s/_/ /g'} '&mdash;' \
- `{basename -d $PATH_INFO | sed 's,^/,,'} '&mdash;' \
- `{echo $ADDRESS | sed 's,^https?://(www\.)?,,'})
-cat <<END
-Cache-Control: no-cache
-Content-Type: text/html
-
-<!DOCTYPE HTML SYSTEM>
-<html>
- <head>
- <title>$title</title>
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="pragma" content="no-cache">
- <meta name="author" content="Anselm R. Garbe">
- <meta name="searchtitle" content="dwm wmii suck less">
- <meta name="keywords" content="x11 dwm wmi wmii dmenu slock suck less window manager xlib">
- <meta name="description" content="dynamic window manager improved 2">
- <meta name="revisit-after" content="2 days">
- <meta name="audience" content="all">
- <meta name="content-language" content="en">
- <meta name="copyright" content="(C)opyright 2006-2007 by Anselm R. Garbe">
- <meta name="robots" content="noindex,nofollow">
- <style type="text/css">
- body { background-color: #444; color: #ddd; font-family: sans-serif; margin: 0px 0px 0px 0px; max-width: 80em; }
- img { border: 0px; /* top right bartom left */ }
- a { color: #9cf; }
- input { background-color: #333; border: 1px solid #555; color: #ddd; }
- div#editor{ background-color: #333; border: 0px; color: #ddd; padding: 2%; width: 96%; }
- div#bar { background-color: #222; border: 0px; clear: both; padding: 5px 1% 5px 0px; text-align: right; width: 99%; }
- </style>
- </head>
- <body>
- <div id="bar">
- <i>$SLOGAN</i>
- </div>
+ifs=() {body=`{cat<<'!'}}
                 <div id="editor">
- <h1>
-END
- echo $PATH_INFO
-cat <<END
-</h1>
- <form action="$ADDRESS/$REMOVE/$PATH_INFO" method="post">
- <p style='color: #f00;'>Please confirm removing '$PATH_INFO' through entering the password.</p>
+ %{
+ error $error
+ %}
+ <h1>%($PATH_INFO%)</h1>
+ <form action="%($ADDRESS/$REMOVE/$PATH_INFO%)" method="post">
+ <p style="color: #f00;">Please confirm removing "%($PATH_INFO%)" through entering the password.</p>
                                 <p align="right">
- <b>Password:</b> <input type='password' name='password' size='20'/>
- <input type='submit' value='Confirm'/><br />
+ <b>Password:</b> <input type="password" name="password" size="20"/>
+ <input type="submit" value="Confirm"/><br />
                                 </p>
                         </form>
                 </div>
- <div id="bar">
- <small>&copy Copyright 2007 Anselm R. Garbe Impressum</small>
- </div>
- </body>
-</html>
-END
+!
+
+do_template
+
diff -r 834b4ad9f0d8 -r 87d6cb117425 save.rc
--- a/save.rc Sat Mar 31 07:29:33 2007 +0200
+++ b/save.rc Thu Apr 26 11:36:20 2007 +0200
@@ -1,39 +1,22 @@
 #!/usr/local/plan9/bin/rc
-. /etc/dirirc
 
-fn redirect {
- echo Location: $ADDRESS/$"*
- echo
- exit 0
-}
+dirs=`{basename -d $PATH_INFO}
+if(test $"dirs)
+ /bin/mkdir -p $DIRIDIR/$dirs
 
-fn setvars {
- for(input in `{sed 's/\&/ /g'}) {
- for(var) {
- if(echo $"input | grep -s '^'$"var'=') {
- value=`{echo $"input | sed 's/^'$"var'=//'}
- eval $"var'=$"value'
- }
- }
+date=`{date -n}
+
+echo $text | awk '
+ /^[ ]*$/{
+ print ""
+ while(getline && $0 ~ /^[ ]*$/)
+ ;
         }
-}
+ /./
+ ' >$base.diri.$pid
 
-if(! test $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$')
- redirect $SHOW
-PATH_INFO=`{cleanname $PATH_INFO | sed 's/^.//'}
-if(test -d $DIRIDIR/$PATH_INFO)
- redirect $SHOW/$PATH_INFO
-setvars text password
-if(test $password)
- password=`{echo -n $password | $URLDECODE | $HASHCMD}
-if not
- redirect $SHOW/$PATH_INFO
-if(! ~ $password $HASHPASSWD || ! test $text)
- redirect $SHOW/$PATH_INFO
-dirs=`{basename -d $PATH_INFO}
-if(test $dirs)
- /bin/mkdir -p $DIRIDIR/$dirs
-echo $text | $URLDECODE > $DIRIDIR/$PATH_INFO.diri
-cp $DIRIDIR/$PATH_INFO.diri $DIRIDIR/$PATH_INFO.`{date -n}
-$WIKIFMT < $DIRIDIR/$PATH_INFO.diri > $DIRIDIR/$PATH_INFO
-redirect $SHOW/$PATH_INFO
+cp $base.diri.$pid $base.$date.$pid
+wikifmt < $base.diri.$pid > $base.$pid
+for(i in $base^('' .diri .$date))
+ mv $i.$pid $i
+
diff -r 834b4ad9f0d8 -r 87d6cb117425 show.rc
--- a/show.rc Sat Mar 31 07:29:33 2007 +0200
+++ b/show.rc Thu Apr 26 11:36:20 2007 +0200
@@ -1,5 +1,5 @@
 #!/usr/local/plan9/bin/rc
-. /etc/dirirc
+. ./common.rc
 
 fn menu {
         ls -F $1 | sed 's,^\./,,' | awk -v urlbase'='$ADDRESS/$SHOW/ '
@@ -9,13 +9,14 @@ fn menu {
                 /^([a-zA-Z0-9_]+[\/*]?)+$/ {
                         isdir = match($0, "/$");
                         sub("[*/]$", "");
+
                         bname = $0;
                         sub("^(.*/)?([0-9]+_)?", "", bname);
                         gsub("_", " ", bname);
                         if(isdir)
                                 bname = bname "/"
 
- if(ispath = match(ENVIRON["PATH_INFO"]"/", "^"$0)) {
+ if(index(ENVIRON["PATH_INFO"]"/", $0) == 1) {
                                 print "<li><a href=\"" urlbase $0 "\" class=\"current\">" bname "</a>"
                                 if(isdir)
                                         system("rc -c ''menu " $0 "''");
@@ -25,94 +26,39 @@ fn menu {
                 }' | awk '{ print "\t" $0 }'
 }
 
-if(test $PATH_INFO && echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$') {
- echo Location: $ADDRESS/$SHOW
- echo
- exit 0
-}
-if(! test $PATH_INFO || ~ `{cleanname $PATH_INFO} '/')
- PATH_INFO=''
-if not
- PATH_INFO=`{cleanname $PATH_INFO | sed 's,^/,,'}
-if(test -d $DIRIDIR/$PATH_INFO) {
- file=`{find $DIRIDIR/$PATH_INFO -type f | grep '/[a-zA-Z0-9_]+$' | sort | sed 1q}
- if(test $file && test -f $file) {
- file=`{cleanname $file}
- arg='s,'^$DIRIDIR^'/,,'
- PATH_INFO=`{echo $file | sed $arg}
+ifs='#
+' if(test -d $base) {
+ base=`{find $base -type f | grep '/[a-zA-Z0-9_]+$' | sort | sed 1q}
+ if(test $base && test -f $base) {
+ pat=`{echo -n $DIRIDIR/ | tr -c '' .}
+ PATH_INFO=`{echo $base | sed s,$pat,,}
         }
 }
-title=( `{basename $PATH_INFO | sed 's/^[0-9]+_//; s/_/ /g'} '&mdash;' \
- `{basename -d $PATH_INFO | sed 's,^/,,'} '&mdash;' \
- `{echo $ADDRESS | sed 's,^https?://(www\.)?,,'})
-cat <<END
-Cache-Control: no-cache
-Content-Type: text/html
 
-<!DOCTYPE HTML SYSTEM>
-<html>
- <head>
- <title>$title</title>
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="pragma" content="no-cache">
- <meta name="author" content="Anselm R. Garbe">
- <meta name="searchtitle" content="dwm wmii suck less">
- <meta name="keywords" content="x11 dwm wmi wmii dmenu slock suck less window manager xlib">
- <meta name="description" content="dynamic window manager improved 2">
- <meta name="revisit-after" content="2 days">
- <meta name="audience" content="all">
- <meta name="content-language" content="en">
- <meta name="copyright" content="(C)opyright 2006-2007 by Anselm R. Garbe">
- <meta name="robots" content="index,follow">
- <style type="text/css">
- body { background-color: #444; color: #ddd; font-family: sans-serif; height: 100%; margin: 0px; width: 100%; }
- img { border: 0px; /* top right bottom left */ }
- a { color: #9cf; }
- div#slogan { background-color: #222; border: 0px; float: left; padding: 5px 1% 5px 1%; width: 68%; }
- div#ctrlmenu { background-color: #222; border: 0px; float: left; padding: 5px 1% 5px 0px; text-align: right; width: 29%; }
- #ctrlmenu ul { list-style: none; margin: 0; padding: 0px; }
- #ctrlmenu li { display: inline; }
- #ctrlmenu a { color: #9cf; padding: 5px; text-decoration: none; }
- #ctrlmenu a:hover { background-color: #333; padding: 5px; text-decoration: none; }
- div#menu { border: 0px; float: left; font-size: 95%; min-height: 100%; padding: 0%; width: 25%; }
- #menu ul { padding: 5px 5px 5px 1.5em; }
- #menu li { list-style: none; padding: 6px; }
- #menu a { color: #ddd; padding: 4px; text-decoration: none; }
- #menu a:hover { background-color: #555; padding: 4px; text-decoration: none; }
- #menu a.current { color: #fff; padding: 4px; text-decoration: none; }
- div#page { background-color: #333; border: 0px; float: left; min-height: 100%; padding: 2%; width: 71%; }
-
- div#bot { background-color: #222; border: 0px; clear: both; padding: 5px 1% 5px 0px; text-align: right; width: 99%; }
- </style>
- </head>
- <body>
- <div id="slogan">
- <i>$SLOGAN</i>
+title=`{title}
+ifs=() {body=`{cat<<'!'}}
+ <div style="clear: both; padding: 0px;"></div>
+ <div id="menu">
+%{
+ cd $DIRIDIR
+ menu .
+%}
                 </div>
                 <div id="ctrlmenu">
                         <ul>
- <li>edit</li>
- <li>remove</li>
+ <li>edit</li>
+ <li>remove</li>
                         </ul>
- </div>
- <div style='clear: both; padding: 0px;'></div>
- <div id="menu">
-END
-cd $DIRIDIR
-menu .
-cat <<END
                 </div>
                 <div id="page">
                         <div id="content" style="max-width: 60em;">
-END
-if(test -f $DIRIDIR/$PATH_INFO)
- cat $DIRIDIR/$PATH_INFO
-cat <<END
+%{
+ if(test -f $base)
+ cat $base
+%}
                         </div>
                 </div>
- <div id="bot">
- <small>&copy Copyright 2007 Anselm R. Garbe Impressum</small>
- </div>
- </body>
-</html>
-END
+!
+
+do_template
+
diff -r 834b4ad9f0d8 -r 87d6cb117425 sudoku.rc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sudoku.rc Thu Apr 26 11:36:20 2007 +0200
@@ -0,0 +1,191 @@
+#!/usr/local/plan9/bin/rc
+
+fn setvars {
+ for(var)
+ eval $"var'=.'
+ for(input in `{sed 's/\&/ /g'})
+ eval $"input
+}
+
+setvars a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50 a51 a52 a53 a54 a55 a56 a57 a58 a59 a60 a61 a62 a63 a64 a65 a66 a67 a68 a69 a70 a71 a72 a73 a74 a75 a76 a77 a78 a79 a80
+
+cat <<END
+Cache-Control: no-cache
+Content-Type: text/html
+
+<!DOCTYPE HTML SYSTEM>
+<html>
+ <head>
+ <title>$title</title>
+ <meta http-equiv="cache-control" content="no-cache">
+ <meta http-equiv="pragma" content="no-cache">
+ <meta name="author" content="Anselm R. Garbe">
+ <meta name="searchtitle" content="dwm wmii suck less">
+ <meta name="keywords" content="x11 dwm wmi wmii dmenu slock suck less window manager xlib">
+ <meta name="description" content="dynamic window manager improved 2">
+ <meta name="revisit-after" content="2 days">
+ <meta name="audience" content="all">
+ <meta name="content-language" content="en">
+ <meta name="copyright" content="(C)opyright 2006-2007 by Anselm R. Garbe">
+ <meta name="robots" content="noindex,nofollow">
+ <style type="text/css">
+ body { background-color: #444; color: #ddd; font-family: sans-serif; margin: 0px 0px 0px 0px; max-width: 50em; }
+ table { background-color: #444; border: 0px; }
+ input { background-color: #555; border: 1px solid #666; color: #fff; }
+ div#solution { background-color: #336; border: 0px; color: #ddd; padding: 2%; width: 96%; }
+ div#editor{ background-color: #333; border: 0px; color: #ddd; padding: 2%; width: 96%; }
+ div#bar { background-color: #222; border: 0px; clear: both; padding: 5px 1% 5px 0px; text-align: right; width: 99%; }
+ </style>
+ </head>
+ <body>
+ <div id="bar">
+ <i>sudoku solver</i>
+ </div>
+ <div id="solution">
+ <h3>Solutions</h3>
+ <code>
+END
+ sudoku -c -G -p $a0$a1$a2$a3$a4$a5$a6$a7$a8$a9$a10$a11$a12$a13$a14$a15$a16$a17$a18$a19$a20$a21$a22$a23$a24$a25$a26$a27$a28$a29$a30$a31$a32$a33$a34$a35$a36$a37$a38$a39$a40$a41$a42$a43$a44$a45$a46$a47$a48$a49$a50$a51$a52$a53$a54$a55$a56$a57$a58$a59$a60$a61$a62$a63$a64$a65$a66$a67$a68$a69$a70$a71$a72$a73$a74$a75$a76$a77$a78$a79$a80 >[2=1] | sed 's/$/<br>/g'
+cat <<END
+ </code>
+ </div>
+ <div id="editor">
+ <p><small>Enter your values and press solve:</small><br>
+ &nbsp;</p>
+ <form action="$ADDRESS/sudoku.rc" method="post">
+ <center>
+ <table cellpadding="5" cellspacing="5">
+ <tbody><tr><td>
+ <table border='0' cellpadding="5" cellspacing="0">
+ <tbody><tr>
+ <td><input name="a0" value="$a0" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a1" value="$a1" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a2" value="$a2" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a3" value="$a3" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a4" value="$a4" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a5" value="$a5" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a6" value="$a6" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a7" value="$a7" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a8" value="$a8" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr>
+ <td><input name="a9" value="$a9" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a10" value="$a10" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a11" value="$a11" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a12" value="$a12" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a13" value="$a13" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a14" value="$a14" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a15" value="$a15" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a16" value="$a16" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a17" value="$a17" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr>
+ <td><input name="a18" value="$a18" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a19" value="$a19" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a20" value="$a20" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a21" value="$a21" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a22" value="$a22" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a23" value="$a23" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a24" value="$a24" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a25" value="$a25" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a26" value="$a26" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr><td colspan="11">&nbsp;</td></tr>
+ <tr>
+ <td><input name="a27" value="$a27" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a28" value="$a28" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a29" value="$a29" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a30" value="$a30" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a31" value="$a31" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a32" value="$a32" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a33" value="$a33" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a34" value="$a34" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a35" value="$a35" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr>
+ <td><input name="a36" value="$a36" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a37" value="$a37" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a38" value="$a38" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a39" value="$a39" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a40" value="$a40" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a41" value="$a41" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a42" value="$a42" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a43" value="$a43" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a44" value="$a44" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr>
+ <td><input name="a45" value="$a45" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a46" value="$a46" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a47" value="$a47" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a48" value="$a48" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a49" value="$a49" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a50" value="$a50" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a51" value="$a51" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a52" value="$a52" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a53" value="$a53" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr><td colspan="11">&nbsp;</td></tr>
+ <tr>
+ <td><input name="a54" value="$a54" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a55" value="$a55" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a56" value="$a56" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a57" value="$a57" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a58" value="$a58" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a59" value="$a59" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a60" value="$a60" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a61" value="$a61" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a62" value="$a62" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr>
+ <td><input name="a63" value="$a63" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a64" value="$a64" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a65" value="$a65" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a66" value="$a66" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a67" value="$a67" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a68" value="$a68" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a69" value="$a69" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a70" value="$a70" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a71" value="$a71" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ <tr>
+ <td><input name="a72" value="$a72" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a73" value="$a73" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a74" value="$a74" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a75" value="$a75" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a76" value="$a76" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a77" value="$a77" size="1" maxlength="1" type="text"><br></td>
+ <td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
+ <td><input name="a78" value="$a78" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a79" value="$a79" size="1" maxlength="1" type="text"><br></td>
+ <td><input name="a80" value="$a80" size="1" maxlength="1" type="text"><br></td>
+ </tr>
+ </tbody></table>
+ </td></tr>
+ </tbody></table>
+ <p><input type='submit' value='Solve'/></p>
+ </center>
+ </form>
+ </div>
+ <div id="bar">
+ <small>&copy Copyright 2007 Anselm R. Garbe Impressum</small>
+ </div>
+ </body>
+</html>
+END
diff -r 834b4ad9f0d8 -r 87d6cb117425 tmpl.html
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tmpl.html Thu Apr 26 11:36:20 2007 +0200
@@ -0,0 +1,66 @@
+Cache-Control: no-cache
+Content-Type: text/html
+
+% fn error {
+% if(test $"*) {
+ <div id="error">
+ %($"*%)
+ </div>
+% }
+% }
+<!DOCTYPE HTML SYSTEM>
+<html>
+ <head>
+ <title>%($title%)</title>
+ <meta http-equiv="cache-control" content="no-cache">
+ <meta http-equiv="pragma" content="no-cache">
+ <meta name="author" content="Anselm R. Garbe">
+ <meta name="searchtitle" content="dwm wmii suck less">
+ <meta name="keywords" content="x11 dwm wmi wmii dmenu slock suck less window manager xlib">
+ <meta name="description" content="dynamic window manager improved 2">
+ <meta name="revisit-after" content="2 days">
+ <meta name="audience" content="all">
+ <meta name="content-language" content="en">
+ <meta name="copyright" content="(C)opyright 2006-2007 by Anselm R. Garbe">
+ <meta name="robots" content="index,follow">
+ <style type="text/css">
+ body { background-color: #444; color: #ddd; font-family: sans-serif; height: 100%; margin: 0px; width: 100%; }
+ img { border: 0px; /* top right bottom left */ }
+ a { color: #9cf; }
+ div#slogan { background-color: #222; border: 0px; padding: 5px 0 5px 1%; }
+ div#error { background-color: #444; border: 1px solid #555; color: #f00; padding: .2em .5em .2em .5em; margin-top: 1em; }
+ div#error:before { content: "Error: "; color: white; font-weight: bold; }
+ div#error + H1 { margin-top: .25em }
+ div#ctrlmenu { background-color: #222; border: 0px; position: absolute; top: 0; right: 0; padding: 5px 1% 5px 0px; text-align: right; }
+ #ctrlmenu ul { list-style: none; margin: 0; padding: 0px; }
+ #ctrlmenu li { display: inline; }
+ #ctrlmenu a { color: #9cf; padding: 5px; text-decoration: none; }
+ #ctrlmenu a:hover { background-color: #333; padding: 5px; text-decoration: none; }
+ div#menu { border: 0px; float: left; font-size: 95%; min-height: 100%; padding: 0%; width: 25%; }
+ #menu ul { padding: 5px 5px 5px 1.5em; }
+ #menu li { list-style: none; padding: 6px; }
+ #menu a { color: #ddd; padding: 4px; text-decoration: none; }
+ #menu a:hover { background-color: #555; padding: 4px; text-decoration: none; }
+ #menu a.current { color: #fff; padding: 4px; text-decoration: none; }
+ div#page { background-color: #333; border: 0px; float: left; min-height: 100%; padding: 2%; width: 71%; }
+ div#preview { background-color: #444; border: 1px solid #555; color: #eee; padding: 2%; width: 71%; margin-bottom: .7em; }
+ div#page :first-child, div#content :first-child, div#preview :first-child { margin-top: 0px; }
+ div#editor{ background-color: #333; border: 0px; color: #ddd; padding: 2%; width: 96%; }
+ div#bot, div#bar { background-color: #222; border: 0px; clear: both; padding: 5px 1% 5px 0px; text-align: right; width: 99%; }
+ textarea { background-color: #444; border: 1px solid #555; color: #eee; width: 100%; }
+ input { background-color: #444; border: 1px solid #555; color: #eee; }
+ </style>
+ </head>
+ <body>
+ <div id="slogan">
+ <i>%($SLOGAN%)</i>
+ </div>
+%{
+ echo -n $body | template | rc
+%}
+ <div id="bot">
+ <small>Copyright &copy; 2007 suckless.org project Impressum</small>
+ </div>
+ </body>
+</html>
+
Received on Thu Apr 26 2007 - 11:40:15 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:56:42 UTC