From: Paul Hänsch Date: Wed, 18 Jul 2018 15:31:58 +0000 (+0200) Subject: integrated bookmark manager X-Git-Url: http://git.plutz.net/?p=serve0;a=commitdiff_plain;h=915841ffcd76d15c1a6e503d6b14ec740abeac3e integrated bookmark manager --- diff --git a/cgilite b/cgilite index fcb3e20..ec06ef4 160000 --- a/cgilite +++ b/cgilite @@ -1 +1 @@ -Subproject commit fcb3e2096bd811a910c686bbfe181708878ba8b4 +Subproject commit ec06ef45d19a1a76462e5f871e0c40ce6c5b4f4e diff --git a/index.cgi b/index.cgi index 1b305e4..4dbd115 100755 --- a/index.cgi +++ b/index.cgi @@ -20,6 +20,21 @@ case $(GET a) in SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -axE 'yes' || printf no)" REDIRECT "$(POST ref)" ;; + bookmark) + bm="$_DATA/.index/bookmarks" + . "$_EXEC/cgilite/storage.sh" + + s="$(POST search |STRING)"; f="$(POST filter |STRING)" + if LOCK "$bm"; then + grep -m1 -avF " search=$s filter=$f${CR}" "$bm" >"$bm.tmp" + [ ! "$(POST delete)" ] \ + && printf '%s search=%s filter=%s\r\n' \ + "$(POST name |STRING)" "$s" "$f" >>"$bm.tmp" + mv "$bm.tmp" "$bm" + RELEASE "$bm" + fi + REDIRECT "$(POST ref)" + ;; esac if [ "$ITEM" = "/style.css" ]; then diff --git a/list.sh b/list.sh index 9e2f2f8..8b8ea8e 100644 --- a/list.sh +++ b/list.sh @@ -162,8 +162,9 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n' [a #t_avsearch href="#advsearch" Advanced] [a #t_prefs href="#prefs" ⚙] ]' - w_prefs + w_bookmarks w_advsearch + w_prefs printf ' [form method=POST action="?a=multitag"' list_items \ diff --git a/style.css b/style.css index e31117e..c19ee48 100644 --- a/style.css +++ b/style.css @@ -58,12 +58,13 @@ a[href="#advsearch"]:before { #prefs, #bookmarks, #multitag, #advsearch { display: block; position: absolute; - height: 0; max-width: 100%; + height: 0; width: 100%; max-width: 100%; margin-top: -1px; padding: 0 1em; border: 1px none; overflow: hidden; background-color: #333; + z-index: 1; } #bookmarks { left: 0; width: 30%; @@ -75,12 +76,13 @@ a[href="#advsearch"]:before { min-width: 200px; margin-left: auto; } -#advsearch { text-align: center; } +#advsearch { + text-align: center; +} #advsearch:target, #multitag:target, #prefs:target, #bookmarks:target { - height: auto; - overflow: visible; + height: auto; overflow: visible; } #advsearch:target { border-style: none none solid none; } #prefs:target { border-style: none none solid solid; } @@ -102,6 +104,9 @@ a[href="#advsearch"]:before { #advsearch a[href="#"] { border-bottom: 1px solid; } #multitag a[href="#"] { top: -1em; line-height: 1em; } + +/* ### Preferences Drawer ### */ + #prefs label[for=prefs_ps] { font-weight: bold; } @@ -120,9 +125,30 @@ a[href="#advsearch"]:before { max-width: 85%; } + +/* ### Bookmarks Drawer ### */ + +#bookmarks input, +#bookmarks button { + margin-bottom: 1.25em; +} +#bookmarks label { + display: block; + font-weight: bold; +} +#bookmarks a.link { + display: inline-block; + font-size: .75em; + text-decoration: underline; + margin: 0 1em 1.25em 0; +} + + +/* ### Advance Search Drawer ###*/ + #advsearch .help { display: block; - margin: -1em .625em 1em .625em; + margin: -1em .5em 1em .5em; padding: .5em 1em; background-color: #444; line-height: 1.5em; @@ -197,6 +223,9 @@ a[href="#advsearch"]:before { width: 50%; } + +/* ### Item Listing ### */ + .list { position: relative; display: inline-block; @@ -285,12 +314,15 @@ a[href="#advsearch"]:before { width: 100%; background-color: #333; border-top: 1px solid; - padding: .25em; + padding: .25em 0; } #index label:first-of-type { font-weight: bold; } #index input, #index button { margin-left: 1em;} + +/* ### Multi Tagging Drawer ### */ + #multitag fieldset{ display: inline-block; width: 25%; min-width: 250px; diff --git a/widgets.sh b/widgets.sh index 4a64deb..9bb6d93 100644 --- a/widgets.sh +++ b/widgets.sh @@ -5,7 +5,7 @@ include_widgets="$0" . "$_EXEC/cgilite/storage.sh" -w_refuri="$(HTML "$REQUEST_URI")" +w_refuri="$(URL "$PATH_INFO")?$(HTML "$QUERY_STRING")" w_tags="$(find "$_DATA/" -path '*/.index/meta' -print0 \ | xargs -r0 sed -r ' @@ -19,24 +19,52 @@ w_tagcategories="$(printf %s "$w_tags" | cut -sd: -f1 | uniq)" [ "$ORDER" = Length ] && w_colength=checked w_bookmarks(){ - local name link bm - bm="$_DATA/.index/bookmarks" - - printf '[form #bookmarks action=?a=bookmarks method=POST - [a href="#" X] + local name='' cf='' cs='' bm="$_DATA/.index/bookmarks" proposed_name='' + [ ! -d "${bm%/*}" ] && return 0 + [ ! -f "$bm" ] && touch "$bm" + + [ "$SEARCH" ] && cs="$(STRING "$SEARCH")" + [ "$FILTER" ] && cf="$(STRING "$FILTER")" + + name="$(grep -m1 -aF " search=$cs filter=$cf${CR}" "$bm" |cut -f1 |UNSTRING)" + [ ! "$name" ] && proposed_name="$( + printf '%s\t%s' "$SEARCH" "$FILTER" \ + |sed -r '/^\t$/{ s;\t;All;; q;} + /.*\t$/{ s;\t$;;; q;} + /^\t.*/{ s;^\t;;; + :x; s;(^|[~^|])([^|^~:]+):;\1;; tx; + s;\^; and ;g; s;\|;,;g; s;~;not ;g; q;}' + )" + + printf '[form #bookmarks action=?a=bookmark method=POST + [a href="#" x] [hidden "ref" "%s"] - ' "$w_refuri" - - name="$(grep -m1 -F " $(STRING "${REQUEST_URI}")" "$bm")" - printf '[hidden "link" "%s"][input name="name" value="%s"]' \ - "$(HTML "$link")" "$(HTML "$name")" - - sort "$bm" |while read -r name link; do - name="$(UNSTRING "$name")" - link="$(UNSTRING "$link")" - if [ "$link" != "$REQUEST_URI" ]; then - printf '[a href="%s"\n%s]' "$(HTML "$link")" "$(HTML "$name")" - fi + [hidden "search" "%s"][hidden "filter" "%s"] + [label Name for current page:] + [input name="name" value="%s" placeholder="Name" ] + [button type="submit" %s]' \ + "$w_refuri" \ + "$(HTML "$SEARCH")" "$(HTML "$FILTER")" \ + "$(HTML "${name:-${proposed_name}}")" \ + "${name:+Update}${proposed_name:+Add}" + [ "$name" ] && printf ' [submit "delete" "delete" Delete]' + + sort "$bm" |while read -r name search filter; do + search="${search#search=}" filter="${filter#filter=}" filter="${filter%${CR}}" + [ "$search" = "${cs}" -a "$filter" = "${cf}" ] && continue + + name="$(UNSTRING "$name")"; + search="$(UNSTRING "${search}" |URL)"; + filter="$(UNSTRING "${filter}" |URL)"; + printf '[label .link %s] + [a .link target=blank href="?o=Name&s=%s&f=%s" by Name] + [a .link target=blank href="?o=Date&s=%s&f=%s" by Date] + [a .link target=blank href="?o=Length&s=%s&f=%s" by Length] + [br]' \ + "$(HTML "$name")" \ + "$search" "$filter" \ + "$search" "$filter" \ + "$search" "$filter" done printf ']' }