]> git.plutz.net Git - serve0/commitdiff
implemented full multi file tagging
authorPaul Hänsch <paul@plutz.net>
Sat, 14 Jul 2018 13:48:28 +0000 (15:48 +0200)
committerPaul Hänsch <paul@plutz.net>
Sat, 14 Jul 2018 13:48:28 +0000 (15:48 +0200)
index.cgi
list.sh
style.css

index 68d6b5bd91b06d50b420531573792670b3d126e5..8790fa9b814edb4dc71cd01714859658fd8b51d6 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -57,6 +57,8 @@ elif [ -d "$_DATA/$ITEM" ]; then
       REDIRECT "$(POST ref)"
     ;;
     multitag)
       REDIRECT "$(POST ref)"
     ;;
     multitag)
+      . "$_EXEC/multitag.sh"
+      REDIRECT "$(POST ref)"
     ;;
     *) . "$_EXEC/list.sh"
     ;;
     ;;
     *) . "$_EXEC/list.sh"
     ;;
diff --git a/list.sh b/list.sh
index 324d8eb29007e6e548b63da225b25595ac723a90..d0868baffeda9c0af2b778c85a048f05f618b3dc 100644 (file)
--- a/list.sh
+++ b/list.sh
@@ -15,11 +15,13 @@ list_item() {
     printf '[div .list .file
               [a href="%s" [img src="%s?a=thumbnail"][label %s]]
               [span .time %i:%imin] [span .dim %ix%i] %s
     printf '[div .list .file
               [a href="%s" [img src="%s?a=thumbnail"][label %s]]
               [span .time %i:%imin] [span .dim %ix%i] %s
+              [checkbox "select" "%s" id="select_%s" form="multitag"][label for="select_%s" +]
             ]' \
       "$path" "$path" "$name" \
       "$((length / 60))" "$((length % 60))" \
       "$width" "$height" \
             ]' \
       "$path" "$path" "$name" \
       "$((length / 60))" "$((length % 60))" \
       "$width" "$height" \
-      "$(printf %s\\n "${tags#tags=}" |tr , ' ' |xargs printf '[span .tag %s]')"
+      "$(printf %s\\n "${tags#tags=}" |tr , ' ' |xargs printf '[span .tag %s]')" \
+      "$path" "$path" "$path"
   else
     printf '[div .list .file [a href="%s" [img src="%s?a=thumbnail"][label %s]]]' \
       "$path" "$path" "$name"
   else
     printf '[div .list .file [a href="%s" [img src="%s?a=thumbnail"][label %s]]]' \
       "$path" "$path" "$name"
@@ -119,6 +121,23 @@ list_paginate() {
   printf ']'
 }
 
   printf ']'
 }
 
+w_tagging(){
+  printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$(HTML "$REQUEST_URI")"
+  printf '[a href="#" Hide][br]'
+  find "$_DATA/$ITEM" -path '*/.index/meta' \
+       -exec cut -f4 '{}' + \
+  | cut -d= -f2- |tr , '\n' | sort -u \
+  | while read tag; do
+    cat_old="${category}"; category="${tag%%:*}"
+    [ "$category" = "$tag" ] && category="(none)"
+    [ "$cat_old" -a "$cat_old" != "$category" ] && printf ']]'
+    [ "$cat_old" != "$category" ] \
+    && printf '[fieldset [legend %s:][select name="tag" size=4 multiple' $(HTML "$category")
+    printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "${tag#*:}")"
+  done
+  printf ']][fieldset [legend New:][textarea name=newtag\n][button type=Submit Add Tags]]]'
+}
+
 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
 
 "$_EXEC/cgilite/html-sh.sed" <<-EOF
 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
 
 "$_EXEC/cgilite/html-sh.sed" <<-EOF
@@ -134,11 +153,14 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
   ]
   $(w_prefs)
 
   ]
   $(w_prefs)
 
-  $(list_items \
-    | list_paginate
-  )
-  [div #editing
-    $(w_index)
+  [form method=POST action="?a=multitag"
+    $(list_items \
+      | list_paginate
+    )
+    [div #editing
+      [a href="#multitag" Add Tags] $(w_tagging)
+      $(w_index)
+    ]
   ]
 ] ]
 EOF
   ]
 ] ]
 EOF
index 0d2bd6eda4d4b18dd92bbe46ea436bc3d789ea3b..1bbc2fff933f8c4b11fe1eee20f6674aa4d97bf6 100644 (file)
--- a/style.css
+++ b/style.css
@@ -8,16 +8,20 @@ a { color: inherit; text-decoration: none;}
 body {
   color: white;
   background-color: black;
 body {
   color: white;
   background-color: black;
+  min-height: 100%;
 }
 
 }
 
-#prefs, #bookmarks {
+#prefs, #bookmarks, #multitag {
   display: block;
   overflow: hidden;
   height: 0;
   display: block;
   overflow: hidden;
   height: 0;
+  text-align: left;
 }
 #prefs:target,
 }
 #prefs:target,
+#multitag:target,
 #bookmarks:target {
   height: auto;
 #bookmarks:target {
   height: auto;
+  overflow: visible;
 }
 
 #navigation{
 }
 
 #navigation{
@@ -64,8 +68,11 @@ a[href="#advsearch"]:before {
 }
 
 #prefs:target a[href="#"] {
 }
 
 #prefs:target a[href="#"] {
-  position: absolute;
-  right: .25em; margin-top: -1.5em;
+  display: block;
+  position: relative;
+  top: -1.5em; right: -.5em;
+  margin-left: 4em;
+  text-align: right;
   font-size: 1.5em;
   padding: 0 .25em;
   background-color: #333;
   font-size: 1.5em;
   padding: 0 .25em;
   background-color: #333;
@@ -90,7 +97,6 @@ a[href="#advsearch"]:before {
   max-width: 85%;
 }
 
   max-width: 85%;
 }
 
-.itemlist { display: block; overflow: hidden; }
 .list {
   position: relative;
   display: inline-block;
 .list {
   position: relative;
   display: inline-block;
@@ -101,6 +107,7 @@ a[href="#advsearch"]:before {
   word-wrap: break-word;
   vertical-align: top;
   color: black;
   word-wrap: break-word;
   vertical-align: top;
   color: black;
+  overflow: hidden;
 }
 .list.dir {
   padding: .5em 1em;
 }
 .list.dir {
   padding: .5em 1em;
@@ -129,6 +136,13 @@ a[href="#advsearch"]:before {
   background-color: rgba(0,0,0,.625);
 }
 
   background-color: rgba(0,0,0,.625);
 }
 
+.list.file .time,
+.list.file .dim,
+.list.file .tag,
+.list.file label {
+  display: inline-block;
+  margin-top: .125em;
+}
 .list.file .time,
 .list.file .dim {
   color: white;
 .list.file .time,
 .list.file .dim {
   color: white;
@@ -136,6 +150,17 @@ a[href="#advsearch"]:before {
   padding: .125em .5em;
 }
 
   padding: .125em .5em;
 }
 
+.list.file input[type="checkbox"] { display: none; }
+.list.file input[type="checkbox"] + label {
+  border: 1px solid;
+  border-radius: .125em;
+  padding: 0 .25em;
+  background-color: #FBB;
+}
+.list.file input[type="checkbox"]:checked + label {
+  background-color: #4F4;
+}
+
 .pagination {
   display: block;
   text-align: center;
 .pagination {
   display: block;
   text-align: center;
@@ -151,8 +176,8 @@ a[href="#advsearch"]:before {
 }
 
 #editing {
 }
 
 #editing {
-  position: absolute;
-  width: 100%; bottom: 0;
+  text-align: left;
+  width: 100%;
   background-color: #333;
   border-top: 1px solid;
   padding: .25em;
   background-color: #333;
   border-top: 1px solid;
   padding: .25em;
@@ -160,3 +185,19 @@ a[href="#advsearch"]:before {
 
 #index label:first-of-type { font-weight: bold; }
 #index input, #index button { margin-left: 1em;}
 
 #index label:first-of-type { font-weight: bold; }
 #index input, #index button { margin-left: 1em;}
+
+#multitag:target a[href="#"] {
+  position: relative;
+  top: -1em;
+  padding-right: 10em;
+  background-color: #333;
+}
+#multitag fieldset{
+  display: inline-block;
+  width: 25%; min-width: 250px;
+  vertical-align: top;
+  padding: 0 .25em;
+  border: none;
+}
+#multitag fieldset * { width: 100%; }
+#multitag fieldset button { width: 50%; }