+bookmarkgen(){
+ fid="$(GET newbm |checkid)"
+ name="$(GET nbmname)"
+ url="$(GET nbmurl)"
+ file="${BDB}/${fid}.bm"
+
+ [ "$url" = "${url#*://}" ] && url="http://$url"
+ if [ -z "$name" -a -n "$url" ]; then
+ name="$(wget -O- "$url" \
+ | head -c4096 \
+ | sed -rn ':X;$bY;N;bX;:Y; s;^.*<title[^>]*>([^<]+)<.*$;\1;p;'
+ )"
+ fi
+
+ if [ -n "$fid" -o -n "$name" -o -n "$url" ]; then
+ cat <<-EOF
+ <form class="dialog newbookmark" method="POST" action="${SCRIPT_NAME}?action=newbookmark">
+ <h1>New Bookmark</h1>
+ <label>Folder:</label>
+ <select name="fid">
+ $(list_folders |while read id n; do
+ [ "$id" = "$fid" ] \
+ && printf '<option value="%s" selected="selected">%s</option>' "$id" "$n" \
+ || printf '<option value="%s">%s</option>' "$id" "$n"
+ done)
+ $(printf '<option value="%s">%s</option>' $(list_folders))
+ </select>
+ <label>Name:</label>
+ <input type="text" name="name" value="$(HTML ${name})")" placeholder="Name" />
+ <label>URL:</label>
+ <input type="text" name="url" value="$(HTML "${url}")")" placeholder="URL" />
+ <button type="submit" name="control" value="confirm">OK</button>
+ <button type="submit" name="control" value="cancel">Cancel</button>
+ </form>
+ EOF
+ fi
+}
+