]> git.plutz.net Git - serve0/blobdiff - list.sh
various code improvements (skip double sanitizing, bugfix in name handling, slight...
[serve0] / list.sh
diff --git a/list.sh b/list.sh
index 1a5a6cf05fce903418d04d1e956da3fce4609031..2d9dff832cd480ab70f29cacc5e6dfa209ee36ba 100644 (file)
--- a/list.sh
+++ b/list.sh
@@ -25,18 +25,20 @@ list_item() {
     name="$(list_fullname "$(UNSTRING "${name%${CR}}")")"
   fi
   if [ -f "$_DATA/$ITEM/$name" ]; then
-    display="$(HTML "$name")"
     link="$(URL "$ITEM/$name")"
+    name="$(HTML "$ITEM/$name")"
     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"][label for="select_%s" +]
             ]' \
-      "$link" "$link" "$name" \
+      "$link" "$link" "${name##*/}" \
       "$((length / 60))" "$((length % 60))" \
       "$width" "$height" \
-      "$(UNSTRING "${tags#tags=}" |tr , '\0' |xargs -r0 printf ' [span .tag %s]')" \
-      "$link" "$link" "$link"
+      "$(printf '%s\n' "${tags#tags=}" \
+         | sed -r "$UNSTRING"' s;^;,;; s;,+;,;g; s;,$;;;
+                   :X s;,([^,]+)(,|$); [span .tag \1]\2;; tX;'
+      )" "$name" "$link" "$link"
   else
     printf 'Canning record for nonexist file: %s\n' "$name" >&2
     # meta_purge "$_DATA/$ITEM/$name"