]> git.plutz.net Git - bookman/commitdiff
start of complete rewrite
authorpaul <paul@plutz.net>
Wed, 22 Nov 2017 22:02:20 +0000 (22:02 +0000)
committerpaul <paul@plutz.net>
Wed, 22 Nov 2017 22:02:20 +0000 (22:02 +0000)
svn path=/trunk/; revision=6

.htaccess [deleted file]
.proxy [new file with mode: 0644]
bookmarks.css
bookmarks.sh [deleted file]
error.sh [deleted file]
index.cgi

diff --git a/.htaccess b/.htaccess
deleted file mode 100644 (file)
index d947339..0000000
--- a/.htaccess
+++ /dev/null
@@ -1,5 +0,0 @@
-Options +ExecCGI
-AddHandler cgi-script .cgi
-DirectoryIndex index.cgi
-
-Require valid-user
diff --git a/.proxy b/.proxy
new file mode 100644 (file)
index 0000000..e69de29
index 8f2ee818c790aa84c470c0d2678f0d7404093363..cadf1aab0a1f1b541b2ceed3757cf3a00af4a7dc 100644 (file)
-body {
-  text-align: left;
-  background-color: #EEF;
-  color: #000;
+* { /* RESET */
+  font-size: 12pt;
+  margin: 0;
+  padding: 0;
+  text-decoration: none;
+  font-weight: normal;
+  color: black;
+  background-color: white;
+  box-sizing: border-box;
 }
 
 }
 
-.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 ;
+html, body {
+  background-color: #DDD;
+}
 
 
-  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;
+.folder, form.newfolder{
+  display: block;
+  width: 98%;
+  border: 1px solid black;
+  border-radius: .5em;
+  margin: 1em auto;
+  padding: 0;
+  overflow: hidden;
+  #column-width: 16em;
+  #column-rule: 1px solid #BBB;
 }
 
 }
 
-.fName {
-  width: 100%;
-  margin: 0px 0px .2em 0px;
-  border-style: none none solid none;
-  border-width: 1px;
-  border-color: #999;
-  text-indent: 1.5em;
+.folder > h1 {
+  font-size: 1.25em;
   font-weight: bold;
   font-weight: bold;
-  font-size: 1.3em;
-  color: #333;
-  -moz-column-span: all;
-  -webkit-column-span: all;
-  column-span: all;
+  padding: .125em 1em .125em 2em;
+  border-bottom: 1px solid black;
+  background-color: #ACF;
+  border-radius: .375em .375em 0 0;
+  min-height: 1em;
+  #column-span: all;
 }
 }
-.fName a {
-  text-decoration: none;
-  font-weight: normal;
+
+.folder > h1 + a {
+  display: block;
+  position: relative;
+  top: -1.5em;
+  margin-left: 1em;
+  color: transparent;
+  background-color: transparent;
+  width: 0; height: 0;
+}
+.folder > h1 + a:before {
+  content: '\2699';
   color: #333;
 }
   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;
+
+.modfolder {
+  display: block;
+  position: fixed;
+  left: 50%; margin: 0 -15em;
+  vertical-align: middle;
+  text-align: center;
+  width: 30em;
+  min-width: 240px;
+  z-index: 3;
+  border-radius: .5em;
+  border: 1px solid black;
+  padding: .125em 0;
+  min-height: 3em;
+  background-color: #ACF;
+}
+.modfolder:before {
+  display: block;
+  content: '';
+  border: 1px solid black;
+  border-radius: 0 0 .5em .5em;
+  border-top: 0px;
+  top: 1.75em; bottom: .125em; left: .5%; right: .5%;
+  position: absolute;
+  background-color: white;
+  z-index: -1;
+}
+.modfolder + *:after {
+  content: ' ';
+  position: fixed;
+  top: 0; bottom: 0; left: 0; right: 0;
+  background-color: rgba(0,0,0,.5);
 }
 
 }
 
-.edButton {
-  width: 4em;
-  margin: 2px;
-  text-decoration: none;
+.modfolder > label,
+.modfolder > a {
+  display: inline-block;
+  width: 33%;
+  padding: .25em;
+  border: 1px solid black;
+  border-radius: .5em .5em 0 0;
 }
 }
+.modfolder > label { border-bottom: 0px; }
+.modfolder > a { background-color: #EEE; }
 
 
-.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;
+.modfolder > input {
+  display: block;
+  width: 28em;
+  max-width: 95%;
+  margin: 1em;
 }
 }
-.bmDisplay img {
-  position: relative;
-  top: 4px;
+.modfolder > button {
+  display: inline-block;
+  float: right;
+  margin: .5em;
+  padding: 0 .5em;
+}
+
+.bookmark {
+  width: 16em;
+  display: inline-block;
+  margin: .5em 1em;
+}
+
+.bookmark > a.modify {
+  font-size: 0;
+  color: white;
+}
+.bookmark > a.modify:before {
+  content: '\2699';
+  color: #333;
+  font-size: initial;
+}
+
+.bookmark > a.link >  img {
+  height: 1.25em;
+  vertical-align: text-bottom;
+  margin: 0 .5ex;
+}
+
+form.newbookmark,
+form.modbookmark {
+  margin: .5em 1em;
+  break-inside: avoid;
 }
 }
diff --git a/bookmarks.sh b/bookmarks.sh
deleted file mode 100644 (file)
index 212ac8f..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/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 "
-<form action='index.cgi' method='post' accept-charset='utf-8'>
-  <div style='display:none;'>
-  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 '<!-- FOLDER -->'
-       fId=$(sed 's:^folder=::' <<<"$line")
-       [ -z "$fId" ] && fId='###'
-       fName="$(echo -ne "$(sed 's:+: :g;s:%:\\x:g' <<<"$fId")")"
-       $delFolder || echo "
-         <input type='hidden' name='title' value='New Bookmark'>
-         <input type='submit' name='content' value='New Bookmark'>
-       </div><div class='folder'>
-         <div class='fName' id='fName_$fId'>
-           <a href='#' onclick='javascript:hide(\"fName_$fId\");show(\"efName_$fId\")'>&rarr;</a>$fName
-         </div><div class='efName' id='efName_$fId'>
-           <a href='#' onclick='javascript:hide(\"efName_$fId\");show(\"fName_$fId\")'>&larr;</a>
-           <input type='submit' value='Rename'><input type='submit' name='deleteFolder' value='Remove'>
-           <input type='text' name='folder' value='$fName'>
-         </div>
-       "
-       delFolder=false
-       $move && echo "
-         <div class='moveButton'>
-           <input type='hidden' name='title' value='$moveName'>
-           <button type='submit' name='content' value='$moveCont'>Move Here</button>
-         </div>
-       "
-       ;;
-    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 "/<link.*rel=[\"'](shortcut )?icon[\"'].*>/Is:^.*<link.*href=[\"']([^\"']*)[\"'].*$:\1:ip" |\
-          read p && [ -n "$p" ] && (wget -O "$bmFavFile" "$p" || wget -O "$bmFavFile" "$bmBase/$p") ||\
-          wget -O "$bmFavFile" "$bmFav"
-       ) &
-       [ "$bmName" = "$moveName" -a "$bmLink" = "$moveCont" ] && delBookmark=true
-       $delBookmark || echo "
-         <div class='bmDisplay' id='d_$bmId'>
-           <a class='edButton' href='#' onclick='javascript:${hidecmd}${showcmd}show(\"e_$bmId\");hide(\"d_$bmId\");'>&rarr;</a>
-           <img width=16 height=16 src='$bmFavFile'>
-           <a target='_blank' href='$bmLink'>$bmName</a>
-         </div><div class='bmEdit' id='e_$bmId'>
-           <a class='edButton' href='#' onclick='javascript:show(\"d_$bmId\");hide(\"e_$bmId\");'>&larr;</a>
-           <input type='submit' value='Update'><input type='submit' name='deleteBookmark' value='Remove'><br>
-           <a href='?mn=$bmName&mc=$bmLink'>Move Bookmark</a><br>
-           Name: <input type='text' name='title' value='$bmName'><br>
-           Link: <input type='text' name='content' value='$bmLink'>
-         </div>
-       "
-       $delBookmark || ($move && echo "
-         <div class='moveButton'>
-           <input type='hidden' name='title' value='$moveName'>
-           <button type='submit' name='content' value='$moveCont'>Move Here</button>
-         </div>
-       ")
-       delBookmark=false
-       ;;
-    *) echo "<!-- $line -->"
-       ;;
-  esac
-done
-
-echo "
-    <input type='hidden' name='title' value='New Bookmark'>
-    <input type='submit' name='content' value='New Bookmark'>
-  </div>
-  <input type='submit' value='Submit Changes'>
-  <input type='submit' name='folder' value='New Folder'>
-</form>
-"
diff --git a/error.sh b/error.sh
deleted file mode 100644 (file)
index 8fa6b50..0000000
--- a/error.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-echo 'No user authentication occured.<br>'
-echo 'This does Probably mean, that this service is misconfigured.'
index a0a84906df8e5f443ed23c43b2836d8ce4b88cb2..8129b7e3434edcd0c26f70fcfa006f237e2bf49f 100644 (file)
--- a/index.cgi
+++ b/index.cgi
-#!/bin/zsh
-echo 'Content-type: text/html\n'
+#!/bin/sh
 
 
-cat <<NOTES
-<!DOCTYPE HTML>
-<html>
-  <head>
-    <title>Bookmarks!</title>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
-    <link rel="stylesheet" type="text/css" href="bookmarks.css">
-    <script type="text/javascript">
-    <!--
-    function show(id){
-      document.getElementById(id).style.display = "block";
-    }
-    function hide(id){
-      document.getElementById(id).style.display = "none";
-    }
-    -->
-    </script>
-  </head>
-  <body>
-NOTES
-
-if [ -z "${REMOTE_USER}" ]; then
-  . ./error.sh
-else
-  . ./bookmarks.sh
+exec 2>>error.log
+
+. shcgi/cgilite.sh
+mkdir -p users
+#env >>debug
+printf 'POST: %s\n' "$cgilite_post" >>debug
+printf 'action: %s\n' "$(GET action)" >>debug
+
+wget="$(which wget)"
+wget(){ "$wget" -T 5 -t 1 -q -U '' $@; }
+checkid(){ grep -m 1 -xE '[0-9a-zA-Z:_]{12}'; }
+
+genid(){
+  # generate random ID
+  head -c9 /dev/urandom \
+  | uuencode -m - \
+  | sed -n '2{y;+/;:_;;p}'
+}
+
+timeid(){
+  # generate time based ID
+  d=$(date +%s)
+  { printf $(
+      while [ "$d" -gt 0 ]; do
+        printf \\%o $((d % 256))
+        d=$((d / 256))
+      done
+    ) | tac
+    head -c5 /dev/urandom
+  } \
+  | uuencode -m - \
+  | sed -n '2{y;+/;:_;;p}'
+}
+
+getFavicon(){
+  url="$1"
+  bid="$2"
+  prot=${url%%://*}
+  domain="${url#*://}"
+  domain="${domain%%/*}"
+  ubase="${prot}://${domain}"
+  file="${BDB}/favicons/${bid}.ico"
+
+  mkdir -p "${BDB}/favicons/" && chmod a+rx "${BDB}/favicons/"
+
+  favinfo="$(
+    wget -O- "$url" \
+    | head -c4096 \
+    | sed -rn \
+      's;^.*(<[Ll][Ii][Nn][Kk]( [^>]*)? [Rr][Re][Ll]='\''([Ss][Hh][Oo][Rr][Tt][Cc][Uu][Tt] )?[Ii][Cc][Oo][Nn]'\''[^>]*>).*$;\1;;
+       s;^.*(<[Ll][Ii][Nn][Kk]( [^>]*)? [Rr][Re][Ll]="([Ss][Hh][Oo][Rr][Tt][Cc][Uu][Tt] )?[Ii][Cc][Oo][Nn]"[^>]*>).*$;\1;;
+       tX; b; :X;
+       s;^.*<([^>]+) [Hh][Rr][Ee][Ff]="([^"]+)".*$:\2;;
+       s;^.*<([^>]+) [Hh][Rr][Ee][Ff]='\''([^'\'']+)'\''.*$:\2;;
+       tY; b; :Y; p
+      '
+  )"
+
+  printf 'Shortcut icon for %s is %s\n' "$url" "$favinfo" >>debug
+  [ -z "$favinfo" ] && favinfo="${ubase}/favicon.ico"
+  case "$favinfo" in
+    http://*|https://*|//*) wget -O "$file" "$favinfo"
+    ;;
+    /*) wget -O "$file" "${ubase}/${favinfo}"
+    ;;
+    *) wget -O "$file" "${url%/*}/${favinfo}"
+    ;;
+  esac
+  [ -f "${file}.1" ] && mv "${file}.1" "$file"
+  chmod a+r "$file"
+}
+
+QRYID="$(GET    id |checkid)"
+COKID="$(COOKIE id |checkid)"
+BDB="users/${QRYID}"
+
+case "$(GET action)" in
+  newid)
+    NEWID="$(genid)"
+
+    { git init "users/${NEWID}" || mkdir -p "users/${NEWID}"; } >&-
+
+    printf '%s 303 See Other\r\n' "$SERVER_PROTOCOL"
+    printf 'Location: %s\r\n' "${SCRIPT_NAME}?id=${NEWID}"
+    SET_COOKIE +8640000 "id=${NEWID}"
+    printf '\r\n'
+    exit 0
+    ;;
+  newfolder)
+    name="$(POST name |head -n1)"
+    fid="$(timeid)"
+    order="$(
+      head -qn1 "${BDB}"/????????????.bm \
+      | cut -f3 \
+      | sort -n \
+      | tail -n1 \
+      || printf 1
+    )"
+    order="$(((order + 1000) / 1000 * 1000))"
+    if [ -n "$name" -a -d "${BDB}" ]; then
+      printf '%s\t%s\t%s\n' "$fid" "$(HTML "$name")" "$order" >"${BDB}/${fid}.bm"
+    fi
+    REDIRECT "${SCRIPT_NAME}?id=${QRYID}#${fid}"
+    ;;
+  modfolder)
+    name="$(POST name |head -n1)"
+    fid="$(POST fid | checkid)"
+    file="${BDB}/${fid}.bm"
+    if [ "$(POST control)" = confirm -a -n "$name" -a -f "$file" ]; then
+      order="$(head -n1 "$file" |cut -f3 || printf 1000)"
+      printf '%s\t%s\t%s\n' "$fid" "$(HTML "$name")" "$order" >"${file%.bm}.tmp"
+      tail -n+2 "$file" >>"${file%.bm}.tmp"
+      mv "${file%.bm}.tmp" "$file"
+    fi
+    REDIRECT "${SCRIPT_NAME}?id=${QRYID}#${fid}"
+    ;;
+  newbookmark)
+    fid="$(POST fid | checkid)"
+    name="$(POST name |head -n1)"
+    url="$(POST url |head -n1)"
+    file="${BDB}/${fid}.bm"
+    bid="$(timeid)"
+    if [ -n "$name" -a -f "${file}" ]; then
+      printf '%s\t%s\t%s\n' "$bid" "$(HTML "$name")" "$(HTML "$url")" >>"${file}"
+    fi
+    getFavicon "$url" "$bid"
+    REDIRECT "${SCRIPT_NAME}?id=${QRYID}#${fid}"
+    ;;
+  modbookmark)
+    bid="$(POST bid | checkid)"
+    name="$(POST name |head -n1)"
+    url="$(POST url |head -n1)"
+    file="$(grep -lE "^${bid}" "${BDB}"/????????????.bm)"
+    if [ -w "$file" -a -n "$name" -a -n "$url" ]; then
+      bm="$(printf '%s\t%s\t%s' "$bid" "$(HTML "$name")" "$(HTML "$url")" |sed -r 's;[\&\;];\\&;g;')"
+      sed -ri "s;^${bid}\t.*$;${bm};" "$file"
+    fi
+    getFavicon "$url" "$bid"
+    REDIRECT "${SCRIPT_NAME}?id=${QRYID}#${fid}"
+    ;;
+esac
+
+if [ -z "$QRYID" -a -n "$COKID" ]; then
+  REDIRECT "${SCRIPT_NAME}?id=${COKID}"
+elif [ -n "$QRYID" -a -z "$COKID" ]; then
+  SET_COOKIE +8640000 "id=${QRYID}"
+fi
+
+if [ -z "$QRYID" -a -z "$COKID" ]; then
+  printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
+
+  cat <<-EOF
+       <!DOCTYPE HTML>
+       <HTML><head>
+         <title>Bookman - New Collection</title>
+       </head><body id="newcollection">
+         <h1>You have not yet set up a collection on this server.</h1>
+         Click <a href="${SCRIPT_NAME}?action=newid">here</a> to start a new collection.
+       </body></HTML>
+       EOF
+  exit 0
+elif ! [ -d "users/${QRYID}" ]; then
+  printf '%s 404 Not Found\r\n' "$SERVER_PROTOCOL"
+  printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
+
+  cat <<-EOF
+       <!DOCTYPE HTML>
+       <HTML><head>
+         <title>Bookman - 404</title>
+       </head><body id="missingcollection">
+         <h1>The collection you requested does not exist on this server.</h1>
+         Click <a href="${SCRIPT_NAME}?action=newid">here</a> to start a new collection.
+       </body></HTML>
+       EOF
+  exit 0
 fi
 
 fi
 
-echo '</body></html>'
+list_bookmarks(){
+  fid="$1"
+  bmodify="$(GET bmodify |checkid)"
+
+  tail -n+2 "${BDB}/${fid}.bm" \
+  | while read bid name url; do
+    if [ "${bid}" = "$bmodify" ]; then
+      cat <<-EOF
+       <form class="modbookmark" method="POST" action="${SCRIPT_NAME}?id=${QRYID}&action=modbookmark">
+         <input type="hidden" name="bid" value="${bid}" />
+         <input type="text" name="name" value="${name}")" placeholder="Name" />
+         <input type="text" name="url"  value="${url}")" placeholder="URL" />
+         <button type="submit">Modify</button>
+       </form>
+       EOF
+    else
+      cat <<-EOF
+       <div class="bookmark">
+         <a class="modify" href="${SCRIPT_NAME}?id=${QRYID}&bmodify=${bid}">Modify</a>
+         <a class="link" href="${url}")"><img src="${BDB}/favicons/${bid}.ico"/>${name}</a>
+       </div>
+       EOF
+    fi
+  done
+}
+
+list_folders(){
+  fmodify="$(GET fmodify |checkid )"
+  fdelete="$(GET fdelete |checkid )"
+  fmove="$(GET fmove |checkid )"
+
+  head -qn1 "${BDB}"/????????????.bm \
+  | sort -nk3 \
+  | while read fid fname order; do
+    cat <<-EOF
+       <section class="folder" id="${fid}">
+         <h1>${fname}</h1>
+         <a class="modify" href="${SCRIPT_NAME}?id=${QRYID}&fmodify=${fid}">Modify</a>
+         $(list_bookmarks "$fid")
+          <form class="newbookmark" method="POST" action="${SCRIPT_NAME}?id=${QRYID}&action=newbookmark">
+           <input type="hidden" name="fid" value="${fid}" />
+           <input type="text" name="name" value="" placeholder="Name" />
+           <input type="text" name="url"  value="" placeholder="URL" />
+           <button type="submit">New Bookmark</button>
+          </form>
+       </section>
+       EOF
+    if [ "$fid" = "$fmodify" ]; then
+      cat <<-EOF
+       <form class="modfolder rename" method="POST" action="${SCRIPT_NAME}?id=${QRYID}&action=modfolder">
+         <input type="hidden" name="fid" value="${fid}" />
+          <label>Rename</label><a
+           href="${SCRIPT_NAME}?id=${QRYID}&fdelete=${fid}">Delete</a><a
+           href="${SCRIPT_NAME}?id=${QRYID}&fmove=${fid}">Move</a>
+         <input type="text" name="name" value="${fname}" />
+         <button type="submit" name="control" value="confirm">OK</button>
+         <button type="submit" name="control" value="cancel">Cancel</button>
+       </form>
+       EOF
+    elif [ "$fid" = "$fdelete" ]; then
+      cat <<-EOF
+       <form class="modfolder delete" method="POST" action="${SCRIPT_NAME}?id=${QRYID}&action=modfolder">
+         <input type="hidden" name="fid" value="${fid}" />
+         <a href="${SCRIPT_NAME}?id=${QRYID}&fmodify=${fid}">Rename</a><label
+            >Delete</label><a
+           href="${SCRIPT_NAME}?id=${QRYID}&fmove=${fid}">Move</a>
+         <input type="text" name="name" value="${fname}" />
+         <button type="submit" name="control" value="confirm">OK</button>
+         <button type="submit" name="control" value="cancel">Cancel</button>
+       </form>
+       EOF
+    elif [ "$fid" = "$fmove" ]; then
+      cat <<-EOF
+       <form class="modfolder move" method="POST" action="${SCRIPT_NAME}?id=${QRYID}&action=modfolder">
+         <input type="hidden" name="fid" value="${fid}" />
+         <a href="${SCRIPT_NAME}?id=${QRYID}&fmodify=${fid}">Rename</a><a
+           href="${SCRIPT_NAME}?id=${QRYID}&fdelete=${fid}">Delete</a><label
+           >Move</label>
+         <input type="text" name="name" value="${fname}" />
+         <button type="submit" name="control" value="confirm">OK</button>
+         <button type="submit" name="control" value="cancel">Cancel</button>
+       </form>
+       EOF
+    fi
+  done
+}
+
+printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
+cat <<EOF
+<!DOCTYPE HTML>
+<HTML><head>
+  <title>Bookman - Your Collection</title>
+  <link rel="stylesheet" type="text/css" href="bookmarks.css" />
+</head><body id="collection">
+  $(list_folders)
+  <form class="newfolder" method="POST" action="${SCRIPT_NAME}?id=${QRYID}&action=newfolder">
+    <input type="text" name="name" value="" placeholder="New Folder" />
+    <button type="submit">New</button>
+  </form>
+</body></HTML>
+EOF
+
+#set filetype=sh