changeset: 5:1cb7a17d4644f08a50218c9737745a0c92da21f7
tag: tip
user: Anselm R. Garbe <arg_AT_suckless.org>
date: Tue Jan 30 14:32:52 2007 +0100
files: remove.rc
description:
added remove.rc
diff -r 404ea450460c edit.rc
--- a/edit.rc Tue Jan 30 14:28:55 2007 +0100
+++ b/edit.rc Tue Jan 30 11:27:04 2007 +0100
@@ -1,12 +1,7 @@
#!/usr/local/plan9/bin/rc
. /var/www/dirirc
-if(test ! $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$') {
- echo 'Location: '^$ADDRESS^'/show.rc
- echo
- exit 0
-}
-if(test -d $DIRIDIR/$PATH_INFO) {
+if(~ $PATH_INFO '^[a-zA-Z0-9_/]+$' || test -d $DIRIDIR/$PATH_INFO) {
echo 'Location: '^$ADDRESS^'/show.rc'^$PATH_INFO
echo
exit 0
@@ -43,13 +38,15 @@ Content-Type: text/html
<div id="editor">
<h1>
END
+if(test $PATH_INFO) {
echo $PATH_INFO
+}
cat <<END
</h1>
<form action="$ADDRESS/save.rc$PATH_INFO" method="post">
<textarea name='text' id='text' cols='80' rows='43'>
END
-if(test -f $DIRIDIR^'/'^$PATH_INFO^'.diri') {
+if(test $PATH_INFO && test -f $DIRIDIR^'/'^$PATH_INFO^'.diri') {
cat $DIRIDIR^'/'^$PATH_INFO^'.diri'
}
cat <<END
diff -r 404ea450460c save.rc
--- a/save.rc Tue Jan 30 14:28:55 2007 +0100
+++ b/save.rc Tue Jan 30 11:27:04 2007 +0100
@@ -1,11 +1,5 @@
#!/usr/local/plan9/bin/rc
. /var/www/dirirc
-
-if(test ! $PATH_INFO || echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$') {
- echo 'Location: '^$ADDRESS^'/show.rc
- echo
- exit 0
-}
fn escape {
echo 'Location: '^$ADDRESS^'/show.rc'^$PATH_INFO
@@ -13,7 +7,19 @@ fn escape {
exit 0
}
-if(test -d $DIRIDIR/$PATH_INFO)
+fn mkdirr {
+ ifs='/
+'
+ paths=`{echo $1}
+ prefix=''
+ for(dir in $paths) {
+ if(test ! -d $DIRIDIR^'/'^$prefix^'/'^$dir)
+ mkdir $DIRIDIR^'/'^$prefix^'/'^$dir
+ prefix=$prefix^'/'^$dir
+ }
+}
+
+if(~ $PATH_INFO '^[a-zA-Z0-9_/]+$' || test -d $DIRIDIR/$PATH_INFO)
escape
for(i in `{sed 's/\&/ /g'})
@@ -24,10 +30,13 @@ if not
if not
escape
-if(! ~ $password $HASHPASSWD || test ! $text)
+if(! ~ $password $HASHPASSWD)
escape
-/bin/mkdir -p `{basename -d $PATH_INFO}
+if(! test $text)
+ escape
+
+mkdirr `{basename -d $PATH_INFO}
if(test -f $DIRIDIR^'/'^$PATH_INFO^'.diri')
mv $DIRIDIR^'/'^$PATH_INFO^'.diri' $DIRIDIR^'/'^$PATH_INFO^'.'^`{date -n}
echo $text | $URLDECODE > $DIRIDIR^'/'^$PATH_INFO^'.diri'
diff -r 404ea450460c show.rc
--- a/show.rc Tue Jan 30 14:28:55 2007 +0100
+++ b/show.rc Tue Jan 30 12:00:02 2007 +0100
@@ -27,19 +27,26 @@ fn menu {
}
fn catpage {
- if(test -f $DIRIDIR^'/'^$PATH_INFO)
- cat $DIRIDIR^'/'^$PATH_INFO
- if not {
- if(test -d $DIRIDIR^'/'^$PATH_INFO) {
- file=`{find $DIRIDIR^'/'^$PATH_INFO -type f | grep '/[a-zA-Z0-9_]+$' | sort | sed 1q}
+ if(test $PATH_INFO) {
+ if(test -f $DIRIDIR^'/'^$PATH_INFO)
+ cat $DIRIDIR^'/'^$PATH_INFO
+ if not {
+ 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)
+ cat $file
+ }
+ }
+ }
+ if not {
+ file=`{find $DIRIDIR -type f | grep '/[a-zA-Z0-9_]+$' | sort | sed 1q}
if(test $file && test -f $file)
cat $file
- }
}
}
-if(test $PATH_INFO && echo $PATH_INFO | grep -v -s '^[a-zA-Z0-9_/]+$') {
- echo 'Location: '^$ADDRESS^'/show.rc
+if(test $PATH_INFO && ~ $PATH_INFO '^[a-zA-Z0-9_/]+$') {
+ echo 'Location: '^$ADDRESS^'/show.rc'
echo
exit 0
}
@@ -50,8 +57,6 @@ ifs='/
'
if(test $PATH_INFO)
paths=`{echo $PATH_INFO}
-if not
- PATH_INFO=''
ifs=$tmp
cat <<END
@@ -108,7 +113,7 @@ cat <<END
cat <<END
</div>
<div id="page">
- <div id="content" style="max-width: 60em;">
+ <div id="content" style="max-width: 50em;">
END
catpage
cat <<END
Received on Tue Jan 30 2007 - 14:40:02 UTC
This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:46 UTC