]> git.plutz.net Git - serve0/blobdiff - view.sh
Merge commit 'b931bbd0c30907b9cc956d3707b26b449bf41f76'
[serve0] / view.sh
diff --git a/view.sh b/view.sh
old mode 100644 (file)
new mode 100755 (executable)
index 8854c48..7c73592
--- a/view.sh
+++ b/view.sh
@@ -1,43 +1,70 @@
 #!/bin/sh
 
-. "$_EXEC/indexmeta.sh"
+. "$_EXEC/db_meta.sh"
 . "$_EXEC/widgets.sh"
 
-read length width height tags comment short <<-EOF
-       $(meta_info "$_DATA/$ITEM")
-       EOF
+read_meta "${ITEM%.*}"
 
 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
 
-{ printf '
-[!DOCTYPE HTML]
-[html [head [title Listing]
-  [meta name="viewport" content="width=device-width"]
-  [link rel=stylesheet href="/style.css" ]
-] [body #view
-  [script type="text/javascript" src="/stereoview.js"\n]
-  [div #navigation
-    [a #t_bookmarks href="#bookmarks" &#x2605;]'
-    w_search
-    printf '
-    [a #t_avsearch href="#advsearch" Advanced]
-    [a #t_prefs href="#prefs" &#x2699;]
-  ]'
+{ cat <<-EOF
+       [!DOCTYPE HTML]
+       [html [head
+         [title . $(HTML "${ITEM##*/}")]
+         [meta name="viewport" content="width=device-width"]
+         [link rel=stylesheet href="/cgilite/common.css" ]
+         [link rel=stylesheet href="/style.css" ]
+       ] [body #view
+         [script type="text/javascript" src="/stereoview.js"\n]
+         [div #navigation
+           [a #t_bookmarks href="#bookmarks" &#x2605;]
+           $(w_search)
+           [a #t_prefs href="#prefs" &#x2699;]
+         ]
+       EOF
   w_bookmarks
   w_advsearch
   w_prefs
-  printf '
-  [h1\n %s]
-  [a "?a=download" Download]
-  [a "javascript:stereoview(180, document.getElementById(&#34;mainvideo&#34;));" View 180° Stereoscopic]
-  [a "javascript:stereoview(360, document.getElementById(&#34;mainvideo&#34;));" View 360° Stereoscopic]
-  [video #mainvideo controls="controls" [source src="?a=download" type="video/mp4"]]
-  [span .time %i:%imin] [span .dim %ix%i] %s
-  ' "$(HTML "${ITEM##*/}" |sed -r "$w_ascii"' s;[^0-9a-zA-Z&#];&[wbr];g')" \
-    "$((length / 60))" "$((length % 60))" "$width" "$height" \
-    "$(printf '%s\n' "${tags#tags=}" |sed -r "$UNSTRING"'
-       s;^;,;; s;,+;,;g; s;,$;;; :X s;,([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
-    )"
+  cat <<-EOF
+         [input type=hidden id=StereoFOV  name=StereoFOV  value="$(COOKIE StereoFOV  |grep -xE '[0-9]+' || printf 90)"]
+         [input type=hidden id=StereoDist name=StereoDist value="$(COOKIE StereoDist |grep -xE '[0-9]+' || printf 32)"]
+         [video #mainvideo controls="controls" preload="auto" [source src="?a=download" type="video/mp4"]]
+         [a "?a=download" Download]
+         [label Stereoscopic View:]
+         [a "javascript:stereoview('sbs180', document.getElementById(&#34;mainvideo&#34;));" SBS 180°]
+         [a "javascript:stereoview( 'tb360', document.getElementById(&#34;mainvideo&#34;));" Top/Bottom 360°]
+         [a "javascript:stereoview( 'cu360', document.getElementById(&#34;mainvideo&#34;));" Cubic 360°]
+         [h1 . $(HTML "${ITEM##*/}" |sed -E 's;[^0-9a-zA-Z&#];&[wbr];g')]
+         [span .time $((META_LENGTH / 60)):$(printf %02i $((META_LENGTH % 60)))min] [span .dim ${META_WIDTH}x${META_HEIGHT}]
+       EOF
+  printf %s\\n "$META_TAGS" |tr , \\n |while read tag; do
+    [ "$tag" ] && printf '  [span .tag . %s]\n' "$(HTML "${tag#-}")"
+  done
+
+  if [ "${META_GROUP}" ]; then
+    printf '[div .itemlist'
+    list_meta "$_DATA/${ITEM%/*}/.index/meta" \
+    | grep -F "${CR}   ${META_GROUP}" \
+    | sort -n -k8 -k6,6 \
+    | while read_meta; do for file in "$_DATA/${META_NAME}".*; do
+      [ "/${file#${_DATA}/}" = "$ITEM" ] && continue
+      name="$(HTML "/${file#${_DATA}/}")"
+
+      printf '[div .list .file
+                [a href="%s" [img src="%s?a=thumbnail"]][label . %s]
+                [span .time %i:%02imin] [span .dim %ix%i] %s
+              ]' \
+        "$name" "$name" "${name##/}" \
+        "$((META_LENGTH / 60))" "$((META_LENGTH % 60))" \
+        "$META_WIDTH" "$META_HEIGHT" \
+        "$(printf %s\\n "${META_TAGS}" \
+           | sed -r 's;^;,;; s;,+;,;g; s;,$;;;
+                     :X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
+        )"
+    done; done
+    printf ']'
+  fi
+
   printf '
   [div #editing
     [form method=POST action="/?a=multitag"