From d9b240e143ac20c3a06eda2b4ebdea063f4385a8 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 23 Feb 2012 19:08:38 +0000 Subject: [PATCH] initial source commit svn path=/trunk/; revision=2 --- bookmarks.css | 83 ++++++++++++++++++++++++++++++++++++++ bookmarks.sh | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++ error.sh | 2 + index.cgi | 31 ++++++++++++++ 4 files changed, 225 insertions(+) create mode 100644 bookmarks.css create mode 100644 bookmarks.sh create mode 100644 error.sh create mode 100644 index.cgi diff --git a/bookmarks.css b/bookmarks.css new file mode 100644 index 0000000..8f2ee81 --- /dev/null +++ b/bookmarks.css @@ -0,0 +1,83 @@ +body { + text-align: left; + background-color: #EEF; + color: #000; +} + +.folder { + column-width: 16em; + -moz-column-width: 16em; + -webkit-column-width: 16em; + column-gap: .5em; + -moz-column-gap: .5em; + -webkit-column-gap: .5em; + column-rule: 1px solid #BBB; + -moz-column-rule: 1px solid #BBB; + -webkit-column-rule: 1px solid #BBB; + + background-color: #FFF; + overflow: none; + + padding: .1em 1em .5em 1em; + margin: 0em 1em 1em 0em ; + + border-width: 1px; + border-style: solid; + -moz-border-radius: 1em 1em .5em .5em; + -webkit-border-radius: 1em 1em .5em .5em; + border-radius: 1em 1em .5em .5em; +} + +.fName { + width: 100%; + margin: 0px 0px .2em 0px; + border-style: none none solid none; + border-width: 1px; + border-color: #999; + text-indent: 1.5em; + font-weight: bold; + font-size: 1.3em; + color: #333; + -moz-column-span: all; + -webkit-column-span: all; + column-span: all; +} +.fName a { + text-decoration: none; + font-weight: normal; + color: #333; +} +.efName { + width: 100%; + border-style: none none solid none; + border-width: 1px; + border-color: #999; + display: none; + -moz-column-span: all; + -webkit-column-span: all; + column-span: all; +} +.efName a { + text-decoration: none; +} + +.edButton { + width: 4em; + margin: 2px; + text-decoration: none; +} + +.bmEdit { + display: none; + margin: .3em 0em .3em 0em; + border-style: solid none solid none; + border-width: 1px; + border-color: #BBB; + -moz-break-inside: avoid; + -webkit-break-inside: avoid; + break-inside: avoid; +} +.bmDisplay img { + position: relative; + top: 4px; +} diff --git a/bookmarks.sh b/bookmarks.sh new file mode 100644 index 0000000..af020b4 --- /dev/null +++ b/bookmarks.sh @@ -0,0 +1,109 @@ +#!/bin/zsh +bdir="bookmarks/${REMOTE_USER}" +icodir=icodir +alias wget="/usr/bin/wget -T 5 -t 1 -q -U ''" + +if [ -n "${CONTENT_LENGTH}" -a "${CONTENT_LENGTH}" -gt 0 ]; then + (head -c "${CONTENT_LENGTH}" | sed 's:&:\n:g'; echo) >$bdir/$(date +%s) +fi + +moveName="$(echo -en "$(sed -rn '/mn=.+&mc=.+/{s:(^|.+&)mn=(.+)(&.+|$):\2:;s:\+: :g;s:%:\\x:g;p}' <<<"$QUERY_STRING")")" +moveCont="$(echo -en "$(sed -rn '/mn=.+&mc=.+/{s:(^|.+&)mc=(.+)(&.+|$):\2:;s:\+: :g;s:%:\\x:g;p}' <<<"$QUERY_STRING")")" +[ -n "$moveName" -a -n "$moveCont" ] && move=true || move=false + +[ -d "$bdir" ] || mkdir -p "$bdir" +names=$(sed -rn 's:^name=(.*)$:\1:pg' $bdir/$(ls $bdir |tail -n1)) +hidecmd=$(for each in $(echo $names); do echo "try{hide('e_$each');}catch(e){};"; done) +showcmd=$(for each in $(echo $names); do echo "try{show('d_$each');}catch(e){};"; done) + +delFolder=false +delBookmark=false + +echo " +
+
+ qs $QUERY_STRING + mn $moveName + mc $moveCont +" + +cat $bdir/$(ls $bdir |tail -n1) |while read line; do + case "$line" in + deleteFolder=*) delFolder=true + ;; + deleteBookmark=*) delBookmark=true + ;; + folder=*) echo '' + fId=$(sed 's:^folder=::' <<<"$line") + [ -z "$fId" ] && fId='###' + fName="$(echo -ne "$(sed 's:+: :g;s:%:\\x:g' <<<"$fId")")" + $delFolder || echo " + + +
+
+ $fName +
+ + + +
+ " + delFolder=false + $move && echo " +
+ + +
+ " + ;; + title=*) + bmId=$(sed 's:^title=::' <<<"$line") + [ -z "$bmId" ] && bmId='###' + bmName="$(echo -ne "$(sed 's:+: :g;s:%:\\x:g' <<<"$bmId")")" + ;; + content=*) + bmLink="$(echo -ne "$(sed 's:^content=::;s:+: :g;s:%:\\x:g' <<<"$line")")" + bmBase="$(sed -r 's:^(https?\://[^/]+)/?.*$:\1:' <<<"$bmLink")" + bmFav="$(sed -r 's:^(https?\://[^/]+)/?.*$:\1/favicon.ico:' <<<"$bmLink")" + bmFavFile="$icodir/$(sed -r 's:^https?\://([^/]+)/?.*$:\1.ico:' <<<"$bmLink")" + [ -f "$bmFavFile" ] || (wget -O - "$bmLink" |head -c 4096 |\ + sed -rn "//Is:^.* + + + $bmName +
+ +
+ Move Bookmark
+ Name:
+ Link: +
+ " + $delBookmark || ($move && echo " +
+ + +
+ ") + delBookmark=false + ;; + *) echo "" + ;; + esac +done + +echo " + + + + + +
+" diff --git a/error.sh b/error.sh new file mode 100644 index 0000000..8fa6b50 --- /dev/null +++ b/error.sh @@ -0,0 +1,2 @@ +echo 'No user authentication occured.
' +echo 'This does Probably mean, that this service is misconfigured.' diff --git a/index.cgi b/index.cgi new file mode 100644 index 0000000..a0a8490 --- /dev/null +++ b/index.cgi @@ -0,0 +1,31 @@ +#!/bin/zsh +echo 'Content-type: text/html\n' + +cat < + + + Bookmarks! + + + + + +NOTES + +if [ -z "${REMOTE_USER}" ]; then + . ./error.sh +else + . ./bookmarks.sh +fi + +echo '' -- 2.39.2