]> git.plutz.net Git - shellwiki/commitdiff
gallery macro
authorPaul Hänsch <paul@plutz.net>
Sun, 21 May 2023 19:59:31 +0000 (21:59 +0200)
committerPaul Hänsch <paul@plutz.net>
Sun, 21 May 2023 19:59:31 +0000 (21:59 +0200)
macros/gallery [new file with mode: 0755]
themes/default.css

diff --git a/macros/gallery b/macros/gallery
new file mode 100755 (executable)
index 0000000..306c517
--- /dev/null
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+. "$_EXEC/cgilite/cgilite.sh"
+. "$_EXEC/acl.sh"
+. "$_EXEC/tools.sh"
+
+[ $# = 0 ] && set -- "*"
+
+printf '<div class="macro gallery">'
+for glob in "$@"; do
+  page="${glob%/*}"
+  [ "$page" = "$glob" ] && page=./
+  [ ! "$page" ]         && page=/
+
+  acl_read "$(page_abs "${page}")" \
+  && attachment_glob "$glob"
+done \
+| grep -xiE '.*\.jpe?g|.*\.png|.*\.gif' \
+| sort -u \
+| while read attachment; do
+  case $attachment in
+    */*)
+      printf '<a href="%s"><img src="%s"></a>' \
+             "${attachment%/*}/[attachment]/${attachment##*/}" "${attachment}"
+      ;;
+    *)
+      printf '<a href="%s"><img src="%s"></a>' \
+             "[attachment]/${attachment}" "${attachment}"
+      ;;
+  esac
+done
+printf '</div>'
index 52179a616c2615a5a2400e0c45e28a6fd5fc1f8d..7ef7fb3acb00ee126033991a211354b905581950 100644 (file)
@@ -204,3 +204,13 @@ body[id$="/[newpage]"] textarea {
 .macro.toc li.h5 { margin-left: 5em; }
 .macro.toc li.h6 { margin-left: 6.25em; }
 
+.macro.gallery {
+  text-align: center;
+  margin: 2em 0;
+  padding: .5em .125em;
+  background-color: #444;
+}
+.macro.gallery img {
+  max-height: 9em;
+  margin: 0 .25em;
+}