X-Git-Url: http://git.plutz.net/?p=bookman;a=blobdiff_plain;f=index.cgi;h=911e5eed684715e6e67cf5413617b33752f831d9;hp=4f24149bd8f53024b5903c7e4a1ed37196185b22;hb=28ce309347435c1dd23beab8104d36cbe640d2dd;hpb=104596e3d1aa06eb5cb6108b477e2b379b202537 diff --git a/index.cgi b/index.cgi index 4f24149..911e5ee 100755 --- a/index.cgi +++ b/index.cgi @@ -173,7 +173,10 @@ case "$(GET action)" in file="${BDB}/${fid}.bm" tfile="${BDB}/${target}.bm" if [ "$(POST control)" = confirm -a -f "$file" ]; then - if [ "$target" = "____________" ] || tail -n+2 "$file" >>"$tfile"; then + if [ "$target" = "____________" ]; then + rm -f "$file" >&- + git -C "${BDB}" commit -m "Deleted folder ${fid}" -- "${fid}.bm" >&- + elif tail -n+2 "$file" >>"$tfile"; then rm -f "$file" >&- git -C "${BDB}" commit -m "Deleted folder ${fid}" -- "${fid}.bm" "${target}.bm" >&- fi @@ -202,12 +205,19 @@ case "$(GET action)" in url="$(POST url |head -n1)" file="${BDB}/${fid}.bm" bid="$(timeid)" - if [ -n "$name" -a -f "${file}" ]; then + ctl="$(POST control)" + [ "$url" = "${url#*://}" ] && url="http://$url" + + if [ -n "$name" -a -n "$url" -a -f "${file}" -a "$ctl" = "confirm" ]; then printf '%s\t%s\t%s\n' "$bid" "$(HTML "$name")" "$url" >>"${file}" git -C "${BDB}" commit -m "New Bookmark: ${name} in ${fid}" -- "${fid}.bm" >&- + getFavicon "$url" "$bid" + REDIRECT "${SCRIPT_NAME}#${fid}" + elif [ "$ctl" = "confirm" ]; then + REDIRECT "${SCRIPT_NAME}?newbm=${fid}&nbmurl=${url}&nbmname=${name}" + else + REDIRECT "${SCRIPT_NAME}#${fid}" fi - getFavicon "$url" "$bid" - REDIRECT "${SCRIPT_NAME}#${fid}" ;; modbookmark) bid="$(POST bid | checkid)" @@ -272,6 +282,44 @@ case "$(GET action)" in ;; esac +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;^.*]*>([^<]+)<.*$;\1;p;' + )" + fi + + if [ -n "$fid" -o -n "$name" -o -n "$url" ]; then + cat <<-EOF +
+

New Bookmark

+ + + + + + + + +
+ EOF + fi +} + bookmarkmod(){ bmod="$(GET bmodify |checkid)" bmove="$(GET bmove |checkid)" @@ -282,7 +330,7 @@ bookmarkmod(){ $(grep -m1 "^${bmod}" "$file") EOF cat <<-EOF -
+

Modify: ${name}

@@ -301,7 +349,7 @@ bookmarkmod(){ $(grep -m1 "^${bmove}" "$file") EOF cat <<-EOF - +

Move: ${name}

Modify @@ -358,7 +406,7 @@ foldermod(){ if [ -n "$fmodify" ]; then read fid fname order <"${BDB}/${fmodify}.bm" cat <<-EOF - +

Rename Folder: ${fname}

@@ -374,7 +422,7 @@ foldermod(){ elif [ -n "$fdelete" ]; then read fid fname order <"${BDB}/${fdelete}.bm" cat <<-EOF - +

Delete Folder: ${fname}

Rename @@ -393,7 +441,7 @@ foldermod(){ elif [ -n "$fmove" ]; then read fid fname order <"${BDB}/${fmove}.bm" cat <<-EOF - +

Move Folder: ${fname}

Rename @@ -416,7 +464,7 @@ show_folders(){ | while read fid fname order; do file="${BDB}/${fid}.bm" cache="${BDB}/${fid}.cache" - if [ "${cache}" -nt "${file}" ]; then + if [ "${cache}" -nt "${file}" -a "${cache}" -nt "$0" ]; then cat "$cache" else tee "$cache" <<-EOF @@ -424,12 +472,7 @@ show_folders(){

${fname}

Modify folder "${fname}" $(show_bookmarks "$fid") - - - - - -
+ New Bookmark EOF fi @@ -447,6 +490,7 @@ cat < $(foldermod) $(bookmarkmod) + $(bookmarkgen) $(show_folders)