[hackers] diri: new tip (= 38)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Thu, 01 Feb 2007 13:00:02 +0100

changeset: 38:631d51d39b28
tag: tip
user: arg_AT_suckless.org
date: Thu Feb 01 12:57:54 2007 +0100
files: README dirirc edit.rc remove.rc save.rc show.rc
description:
adding special variables

diff -r ab000f23d58c -r 631d51d39b28 README
--- a/README Thu Feb 01 09:55:26 2007 +0100
+++ b/README Thu Feb 01 12:57:54 2007 +0100
@@ -34,6 +34,6 @@ Afterwards perform following steps:
 
 Then open the following URL in a browser:
 
- http://<your-host>/show.rc
+ http://<your-host>/
 
 --Anselm
diff -r ab000f23d58c -r 631d51d39b28 dirirc
--- a/dirirc Thu Feb 01 09:55:26 2007 +0100
+++ b/dirirc Thu Feb 01 12:57:54 2007 +0100
@@ -8,3 +8,7 @@ TITLE=suckless.org
 TITLE=suckless.org
 URLDECODE=/usr/local/bin/urldecode.awk
 WIKIFMT=/usr/local/bin/markdown.pl
+SHOW=wiki # show.rc
+EDIT=edit # edit.rc
+REMOVE=remove # remove.rc
+SAVE=save # save.rc
diff -r ab000f23d58c -r 631d51d39b28 edit.rc
--- a/edit.rc Thu Feb 01 09:55:26 2007 +0100
+++ b/edit.rc Thu Feb 01 12:57:54 2007 +0100
@@ -4,12 +4,12 @@ if(! test $PATH_INFO || echo $PATH_INFO
 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.rc'
+ echo 'Location: '^$ADDRESS^'/'^$SHOW
         echo
         exit 0
 }
 if(test -d $DIRIDIR/$PATH_INFO) {
- echo 'Location: '^$ADDRESS^'/show.rc'^$PATH_INFO
+ echo 'Location: '^$ADDRESS^'/'^$SHOW^'/'^$PATH_INFO
         echo
         exit 0
 }
@@ -51,7 +51,7 @@ END
         echo $PATH_INFO
 cat <<END
 </h1>
- <form action="$ADDRESS/save.rc$PATH_INFO" method="post">
+ <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') {
diff -r ab000f23d58c -r 631d51d39b28 remove.rc
--- a/remove.rc Thu Feb 01 09:55:26 2007 +0100
+++ b/remove.rc Thu Feb 01 12:57:54 2007 +0100
@@ -4,13 +4,13 @@ if(! test $PATH_INFO || echo $PATH_INFO
 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.rc'
+ echo 'Location: '^$ADDRESS^'/'^$SHOW
         echo
         exit 0
 }
 
 fn escape {
- echo 'Location: '^$ADDRESS^'/show.rc'^$PATH_INFO
+ echo 'Location: '^$ADDRESS^'/'^$SHOW^'/'^$PATH_INFO
         echo
         exit 0
 }
@@ -26,7 +26,7 @@ if(test $password) {
                 /bin/rm -rf $DIRIDIR^'/'^$PATH_INFO^'.diri'
                 /bin/rm -rf $DIRIDIR^'/'^$PATH_INFO
         }
- echo 'Location: '^$ADDRESS^'/show.rc'
+ echo 'Location: '^$ADDRESS^'/'^$SHOW
         echo
         exit 0
 }
@@ -67,7 +67,7 @@ END
         echo $PATH_INFO
 cat <<END
 </h1>
- <form action="$ADDRESS/remove.rc$PATH_INFO" method="post">
+ <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'/>
diff -r ab000f23d58c -r 631d51d39b28 save.rc
--- a/save.rc Thu Feb 01 09:55:26 2007 +0100
+++ b/save.rc Thu Feb 01 12:57:54 2007 +0100
@@ -4,13 +4,13 @@ if(! test $PATH_INFO || echo $PATH_INFO
 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.rc'
+ echo 'Location: '^$ADDRESS^'/'^$SHOW
         echo
         exit 0
 }
 
 fn escape {
- echo 'Location: '^$ADDRESS^'/show.rc'^$PATH_INFO
+ echo 'Location: '^$ADDRESS^'/'^$SHOW^'/'^$PATH_INFO
         echo
         exit 0
 }
@@ -37,5 +37,5 @@ echo $text | $URLDECODE > $DIRIDIR^'/'^$
 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
-echo 'Location: '^$ADDRESS^'/show.rc'^$PATH_INFO
+echo 'Location: '^$ADDRESS^'/'^$SHOW^'/'^$PATH_INFO
 echo
diff -r ab000f23d58c -r 631d51d39b28 show.rc
--- a/show.rc Thu Feb 01 09:55:26 2007 +0100
+++ b/show.rc Thu Feb 01 12:57:54 2007 +0100
@@ -18,20 +18,20 @@ fn menu {
                         if(test -d $file)
                                 bname=$"bname^'/'
                         if(test $sub && ~ $base $sub) {
- echo '<li>'^$"bname^''
+ echo '<li>'^$"bname^''
                                 if(test -d $file)
                                         @{menu $level $file}
                                 echo '</li>'
                         }
                         if not
- echo '<li>'^$"bname^'</li>'
+ echo '<li>'^$"bname^'</li>'
                 }
         }
         echo '</ul>'
 }
 
 if(test $PATH_INFO && echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$') {
- echo 'Location: '^$ADDRESS^'/show.rc'
+ echo 'Location: '^$ADDRESS^'/'^$SHOW
         echo
         exit 0
 }
@@ -97,8 +97,8 @@ Content-Type: text/html
                 </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>
Received on Thu Feb 01 2007 - 13:00:02 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:49 UTC