From b1c4dcda3d4905135be48101c14d1459daaea05a Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 24 May 2010 02:16:38 +0000 Subject: [PATCH] Adding ls and head --- index.cgi | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/index.cgi b/index.cgi index 6209b0f..b2d9550 100755 --- a/index.cgi +++ b/index.cgi @@ -41,6 +41,24 @@ function header { echo } +# List previous pastes +function do_cmd { +header text/plain +case "$1" in +head) + for i in $(ls -t db/*); do + basename $i + basename $i | sed 's/./-/g' + sed '1,/^$/d; /^\s*$/d' $i | sed -n '1,5s/\(.\{0,60\}\).*/\1/p' + echo + done + ;; +ls) + ls -t db | column + ;; +esac +} + # Format a file for viewing function do_print { if [ -f "./$1" ]; then @@ -230,7 +248,10 @@ cat - <text " echo -n "rainbow" echo "" - done) + done) + +

list all

+

sample all

EOF @@ -241,7 +262,11 @@ url="http://$HTTP_HOST${REQUEST_URI/\?*}" pathinfo="${REQUEST_URI/*\/}" pathinfo="${pathinfo/\?*}" -if [ "$pathinfo" ]; then +if [ "$pathinfo" = ls ]; then + do_cmd ls +elif [ "$pathinfo" = head ]; then + do_cmd head +elif [ "$pathinfo" ]; then do_print "$pathinfo" elif [ "$CONTENT_TYPE" ]; then do_upload "${CONTENT_TYPE/*boundary\=/}" -- 2.43.2