initial import of changes from 9front bikeshedding; bundle rc-httpd
This commit is contained in:
parent
6d3bcc867c
commit
a99fa8b44f
46 changed files with 1061 additions and 572 deletions
33
apps/paste/app.rc
Executable file
33
apps/paste/app.rc
Executable file
|
|
@ -0,0 +1,33 @@
|
|||
fn conf_enable_paste {
|
||||
paste_url=$conf_wd
|
||||
paste_dir=`{pwd}
|
||||
conf_enable_app paste
|
||||
}
|
||||
|
||||
fn paste_init {
|
||||
if (~ $REQUEST_METHOD POST && ~ $post_arg_url url && ~ $req_path $paste_url ) { # incoming paste
|
||||
now=`{ date -n }
|
||||
cksum=`{ echo $"post_arg_paste | sum | awk '{ print $1 }' }
|
||||
if (~ $cksum '1715a8eb' ) { # empty paste; discard
|
||||
post_redirect $base_url^$paste_url
|
||||
}
|
||||
if not { # save and redirect
|
||||
# TODO: stop using echo
|
||||
echo $"post_arg_paste > $paste_dir^/^$now^.^$cksum
|
||||
#cat<<EOF > $paste_dir^/^$now^.^$cksum
|
||||
#$"post_arg_paste
|
||||
#EOF
|
||||
#post_redirect $base_url^$paste_url^$now^.^$cksum
|
||||
echo 'Content-type: text/plain'; echo ''; exec echo $base_url^$paste_url^$now^.^$cksum
|
||||
}
|
||||
}
|
||||
if not { # show a paste if there is one
|
||||
if (test -r $werc_root/$local_path && ~ $QUERY_STRING raw ) {
|
||||
echo 'Content-type: text/plain'; echo ''; exec cat $werc_root/$local_path
|
||||
}
|
||||
}
|
||||
|
||||
# if we haven't done anything by now, we don't care. we just exit and let
|
||||
# werc handle it from here.
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue