werc-1.5.0-tweaks

Tweaks for the werc website builder created by the mad architect Uriel
Log | Files | Refs | README

app.rc (1694B)


      1 fn conf_enable_wercpaste {
      2 	paste_url=$conf_wd
      3 	if (~ $#paste_dir 0) { paste_dir=`{pwd} }
      4 	conf_enable_app wercpaste
      5 }
      6 
      7 fn wercpaste_init {
      8 	if (~ $REQUEST_METHOD POST && ~ $post_arg_url url && ~ $req_path $paste_url ) { # incoming paste 
      9 		now=`{ date -n }
     10 		cksum=`{ echo $"post_arg_paste | sum | awk '{ print $1 }' }
     11 		if (~ $cksum '1715a8eb' ) { # empty paste; discard
     12 			post_redirect $base_url^$paste_url
     13 		}
     14 		if not {  # save and redirect
     15 			# TODO: stop using echo
     16 			# env var size limit is 16kb, this thing dies with larger input.
     17 			echo $"post_arg_paste > $paste_dir^/^$now^.^$cksum
     18 			# uncomment the following line to redirect to the pasted file
     19 			#post_redirect $base_url^$paste_url^$now^.^$cksum
     20 			# uncomment the following line instead to just return the url
     21 			echo 'Content-type: text/plain'; echo ''; exec echo $base_url^$paste_url^$now^.^$cksum
     22 		}
     23 	} 
     24 	if not { # show a paste if there is one
     25 		if (test -r $werc_root/$local_path && ~ $QUERY_STRING raw ) { 
     26 				echo 'Content-type: text/plain'; echo ''; exec cat $werc_root/$local_path
     27 			} 
     28 	}
     29 
     30 # drop a textbox 
     31 	if (~ $REQUEST_METHOD GET ) { handler_body_main='begforpaste' }
     32 
     33 }
     34 
     35 fn begforpaste {
     36 	echo '<article class="pastebox">
     37 	<h3 style="text-align: center">pasted data is not publically indexed</h3>
     38 	<form action="'$paste_url'" method="post" style="margin:2em">
     39 	<textarea name="paste" cols="120" rows="20" required style="display: block; margin: 0 auto 0 auto" ></textarea><br>
     40 	<input type="submit" name="submit" value="SUBMIT" style="display: block; margin: 0 auto 0 auto" ><br><br>
     41 	<span style="display: none"><input type="text" name="url" value="url" > (do not change) </span>
     42 	</form>
     43 	</article>
     44 	'
     45 }