summaryrefslogtreecommitdiff
path: root/apps/paste/app.rc
diff options
context:
space:
mode:
authorglenda <glenda@9front.local>2020-11-15 15:13:27 +0000
committerglenda <glenda@9front.local>2020-11-15 15:13:27 +0000
commit39318169e0b50551db511851829f9337c5fa6313 (patch)
tree65a0ef5c1da9677532fa8105293d017919473057 /apps/paste/app.rc
Import site to git
Diffstat (limited to 'apps/paste/app.rc')
-rwxr-xr-xapps/paste/app.rc45
1 files changed, 45 insertions, 0 deletions
diff --git a/apps/paste/app.rc b/apps/paste/app.rc
new file mode 100755
index 0000000..af0c76d
--- /dev/null
+++ b/apps/paste/app.rc
@@ -0,0 +1,45 @@
+fn conf_enable_wercpaste {
+ paste_url=$conf_wd
+ if (~ $#paste_dir 0) { paste_dir=`{pwd} }
+ conf_enable_app wercpaste
+}
+
+fn wercpaste_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
+ # env var size limit is 16kb, this thing dies with larger input.
+ echo $"post_arg_paste > $paste_dir^/^$now^.^$cksum
+ # uncomment the following line to redirect to the pasted file
+ #post_redirect $base_url^$paste_url^$now^.^$cksum
+ # uncomment the following line instead to just return the url
+ 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
+ }
+ }
+
+# drop a textbox
+ if (~ $REQUEST_METHOD GET ) { handler_body_main='begforpaste' }
+
+}
+
+fn begforpaste {
+ echo '<article class="pastebox">
+ <h3 style="text-align: center">pasted data is not publically indexed</h3>
+ <form action="'$paste_url'" method="post" style="margin:2em">
+ <textarea name="paste" cols="120" rows="20" required style="display: block; margin: 0 auto 0 auto" ></textarea><br>
+ <input type="submit" name="submit" value="SUBMIT" style="display: block; margin: 0 auto 0 auto" ><br><br>
+ <span style="display: none"><input type="text" name="url" value="url" > (do not change) </span>
+ </form>
+ </article>
+ '
+}