From a4481dc007ff202882b783ed4b36e03a8b4c1d05 Mon Sep 17 00:00:00 2001 From: B Stack Date: Mon, 1 Feb 2021 09:07:23 -0500 Subject: initial commit --- 60_regen_gallery_sudo | 5 + apply.cgi | 99 + bgstack15-gallery-theme.diff | 112 + bgstack15-gallery-theme/static/css/colorbox.css | 45 + bgstack15-gallery-theme/static/css/skeleton.css | 418 + bgstack15-gallery-theme/static/css/style.css | 91 + bgstack15-gallery-theme/static/images/controls.png | Bin 0 -> 1633 bytes bgstack15-gallery-theme/static/images/loading.gif | Bin 0 -> 9427 bytes .../static/js/app-with-media-page.js | 39 + bgstack15-gallery-theme/static/js/app.js | 36 + bgstack15-gallery-theme/static/js/jquery-2.2.1.js | 9831 ++++++++++++++++++++ .../static/js/jquery-2.2.1.min.js | 4 + .../static/js/jquery.colorbox-min.js | 6 + .../static/js/jquery.colorbox.js | 1105 +++ .../static/js/jquery.touchSwipe.js | 2109 +++++ .../static/js/jquery.touchSwipe.min.js | 14 + bgstack15-gallery-theme/templates/album.html | 84 + bgstack15-gallery-theme/templates/album_list.html | 22 + bgstack15-gallery-theme/templates/base.html | 54 + bgstack15-gallery-theme/templates/footer.html | 16 + bgstack15-gallery-theme/templates/links.html | 10 + bgstack15-gallery-theme/templates/media.html | 37 + edit.cgi | 174 + gallery-cgi.conf | 25 + gallery.md | 148 + gallery.mod | Bin 0 -> 6751 bytes gallery.pp | Bin 0 -> 6767 bytes gallery.te | 84 + generate.py | 86 + generate.sh | 34 + genlib.py | 177 + regen.cgi | 44 + sigal.bin | 38 + sigal.conf.py.example | 305 + toggle-editing.cgi | 145 + 35 files changed, 15397 insertions(+) create mode 100644 60_regen_gallery_sudo create mode 100755 apply.cgi create mode 100644 bgstack15-gallery-theme.diff create mode 100644 bgstack15-gallery-theme/static/css/colorbox.css create mode 100644 bgstack15-gallery-theme/static/css/skeleton.css create mode 100644 bgstack15-gallery-theme/static/css/style.css create mode 100644 bgstack15-gallery-theme/static/images/controls.png create mode 100644 bgstack15-gallery-theme/static/images/loading.gif create mode 100644 bgstack15-gallery-theme/static/js/app-with-media-page.js create mode 100644 bgstack15-gallery-theme/static/js/app.js create mode 100644 bgstack15-gallery-theme/static/js/jquery-2.2.1.js create mode 100644 bgstack15-gallery-theme/static/js/jquery-2.2.1.min.js create mode 100644 bgstack15-gallery-theme/static/js/jquery.colorbox-min.js create mode 100644 bgstack15-gallery-theme/static/js/jquery.colorbox.js create mode 100644 bgstack15-gallery-theme/static/js/jquery.touchSwipe.js create mode 100644 bgstack15-gallery-theme/static/js/jquery.touchSwipe.min.js create mode 100644 bgstack15-gallery-theme/templates/album.html create mode 100644 bgstack15-gallery-theme/templates/album_list.html create mode 100644 bgstack15-gallery-theme/templates/base.html create mode 100644 bgstack15-gallery-theme/templates/footer.html create mode 100644 bgstack15-gallery-theme/templates/links.html create mode 100644 bgstack15-gallery-theme/templates/media.html create mode 100755 edit.cgi create mode 100644 gallery-cgi.conf create mode 100644 gallery.md create mode 100644 gallery.mod create mode 100644 gallery.pp create mode 100644 gallery.te create mode 100755 generate.py create mode 100755 generate.sh create mode 100644 genlib.py create mode 100755 regen.cgi create mode 100755 sigal.bin create mode 100644 sigal.conf.py.example create mode 100755 toggle-editing.cgi diff --git a/60_regen_gallery_sudo b/60_regen_gallery_sudo new file mode 100644 index 0000000..579e68d --- /dev/null +++ b/60_regen_gallery_sudo @@ -0,0 +1,5 @@ +# file: /etc/sudoers.d/60_regen_gallery_sudo +# Reference: vm4:/etc/sudoers.d/60_starbound_sudo +#Defaults:apache !pam_session, !authenticate, !pam_acct_mgmt, !pam_setcred, passprompt_override, pam_service=foo +#apache ALL=(root) NOPASSWD: /bin/su sigal -s /bin/sh -c /home/sigal/.local/bin/sigal build +apache ALL=(root) NOPASSWD: /usr/local/bin/sigal.bin * diff --git a/apply.cgi b/apply.cgi new file mode 100755 index 0000000..33690b4 --- /dev/null +++ b/apply.cgi @@ -0,0 +1,99 @@ +#!/bin/sh +# File: /mnt/public/www/cgi-bin/gallery/apply.cgi +# Author: bgstack15@gmail.com +# Startdate: 2021-01-24 22:12 +# SPDX-License-Identifier: GPL-3.0 +# Title: Apply Changes to Disk +# Package: gallery +# Purpose: apply the requested changes to the image file +# History: +# Usage: called by edit.cgi +# Reference: +# /mnt/public/www/cgi-bin/plex-log.cgi +# Improve: +# Documentation: +# Dependencies: +# /etc/gallery-cgi.conf +# sigal.conf.py from indicated gallery_id +DEBUG=0 +export DRYRUN= +export meta="Saving changes..." +echo "${meta} name=\"viewport\" content=\"width=device-width, initial-scale=1\">" +echo "" +echo "
"
+if test "${REQUEST_METHOD}" != "POST" ;
+then
+   echo "Error! Unable to update title or description."
+   response=1
+   printf '%s' ""
+   exit ${response}
+fi
+export stdin="$( cat )"
+# find separator
+export boundary="$( echo "${CONTENT_TYPE}" | awk '{print $2}' | awk -F'=' '{print $2}' )"
+
+# prepare the stdin
+stdin2="$( echo "${stdin}" | sed -r -e "s/-*${boundary}-*/%%%%%%%%%%/g;" | awk '/%%%%%%%/{a=a+1} $0 !~ /%%%%%/ && a {print a,$0}' )"
+# find metadatafile to write
+export metadatafile="$( echo "${stdin2}" | awk '/Content-Disposition.*="metadatafile"/{a=$1} $1==a && $0 !~ /^[0-9]\s*$|Content-Disposition/{print $2}' | tr -d '[\n\r]' )"
+# find title
+export title="$( echo "${stdin2}" | awk '/Content-Disposition.*="title"/{a=$1} $1==a && $0 !~ /^[0-9]\s*$|Content-Disposition/{$1="";print;}' | sed -r -e 's/^\s*//;' )"
+# find description
+#export description="$( echo "${stdin2}" | awk '/Content-Disposition.*="description"/{a=$1} $1==a && $0 !~ /^[0-9]\s*$|Content-Disposition/{$1="";print;}' | sed -r -e 's/^\s*//;' )"
+export description="$( echo "${stdin2}" | awk '/Content-Disposition.*="description"/{a=$1} $1==a && $0 !~ /Content-Disposition/{$1="";print;}' | sed -r -e 's/^\s*//;' )"
+# find referer
+export referer="$( echo "${stdin2}" | awk '/Content-Disposition.*="referer"/{a=$1} $1==a && $0 !~ /^[0-9]\s*$|Content-Disposition/{print $2}' )"
+# find thumbnail
+export thumbnail="$( echo "${stdin2}" | awk '/Content-Disposition.*="thumbnail"/{a=$1} $1==a && $0 !~ /^[0-9]\s*$|Content-Disposition/{print $2}' )"
+# find author
+export author="$( echo "${stdin2}" | awk '/Content-Disposition.*="author"/{a=$1} $1==a && $0 !~ /^[0-9]\s*$|Content-Disposition/{print $2}' )"
+# find gallery_id from form data
+export gallery_id="$( echo "${stdin2}" | awk '/Content-Disposition.*="id"/{a=$1} $1==a && $0 !~ /^[0-9]\s*$|Content-Disposition/{print $2}' | tr -d '[\r\n]' )"
+
+eval export sigal_conf_py=\"\${"${gallery_id}"}\"/sigal.conf.py
+
+# learn edit_enabled from config file
+edit_enabled="$( awk -F'=' '$1 ~ /edit_enabled/ {print $2}' "${sigal_conf_py}" | sed -r -e "s/[\"']//g;" -e 's/^ //;' | tr '[A-Z]' '[a-z]' )"
+
+test -n "${DEBUG}" && test ${DEBUG} -ge 3 1>/dev/null 2>&1 && {
+   env
+}
+
+test -n "${DEBUG}" && test ${DEBUG} -ge 1 1>/dev/null 2>&1 && {
+   test -n "${title}" && {
+      echo "Title: ${title}"
+      test -n "${thumbnail}" && echo "Thumbnail: ${thumbnail}"
+      echo ""
+   }
+   echo "${description}"
+}
+
+{ test -z "${DRYRUN}" || test "${DRYRUN}" = "0" ; } && {
+   if test "${edit_enabled}" = "false" ;
+   then
+      echo "Unable to edit."
+      echo "${meta} http-equiv=\"Refresh\" content=\"1; url='${referer}'\" />"
+   else
+      echo "Will try to apply to file \"${metadatafile}\"!"
+      {
+         test -n "${title}" && echo "Title: ${title}"
+         test -n "${thumbnail}" && echo "Thumbnail: ${thumbnail}"
+         test -n "${author}" && echo "Author: ${author}"
+         # the whitespace is not necessary because description always has plenty
+         echo "${description}"
+      } | tee "${metadatafile}" 1>/dev/null
+      response=$?
+      test "${response}" = "0" && {
+         echo "Success. Redirecting..."
+         echo "${meta} http-equiv=\"Refresh\" content=\"0.5; url='${referer}'\" />"
+      }
+   fi
+}
+
+printf '%s' ""
+exit ${response}
diff --git a/bgstack15-gallery-theme.diff b/bgstack15-gallery-theme.diff
new file mode 100644
index 0000000..ce18b09
--- /dev/null
+++ b/bgstack15-gallery-theme.diff
@@ -0,0 +1,112 @@
+Differences between the built-in [colorbox](/home/sigal/.local/lib/python3.6/site-packages/sigal/themes/colorbox) theme in sigal and bgstack15 theme.
+diff -Naur colorbox/static/css/style.css bgstack15/static/css/style.css
+--- colorbox/static/css/style.css	2021-01-24 14:32:13.428676605 -0500
++++ bgstack15/static/css/style.css	2021-01-24 16:11:59.211313409 -0500
+@@ -1,4 +1,4 @@
+-body { background-color: white; }
++body { background-color: #e2e2e2; } /* modified bgstack15 2021-01-24 */
+ /* Override a few styles from skeleton */
+ h1 { font-size: 4.0rem; }
+ h2 { font-size: 3.6rem; }
+diff -Naur colorbox/templates/album.html bgstack15/templates/album.html
+--- colorbox/templates/album.html	2021-01-24 14:32:13.437676429 -0500
++++ bgstack15/templates/album.html	2021-01-26 19:48:12.152651121 -0500
+@@ -29,8 +29,9 @@
+         
+         {% endif %}
+-          {{ media.url }}
++          {{ media.url }}{% if '.jpg' not in media.title or settings.edit_enabled %}
{% endif %}{% if '.jpg' not in media.title %}{{ media.title }}{% endif %}{% if settings.edit_enabled %} {{ settings.edit_string }}{% endif %} ++ {% if media.description %}{{ media.description }}{% endif %} + + {% endif %} + {% if media.type == "video" %} +@@ -43,12 +44,13 @@ + {% endif %} + {% if media.big %} data-big="{{ media.big_url }}"{% endif %}> + {{ media.url }} ++ title="{{ media.title }}" />{% if ('.mp4' not in media.title and '.webm' not in media.title) or settings.edit_enabled %}
{% endif %}{% if ('.jpg' not in media.title and '.webm' not in media.title) %}{{ media.title }}{% endif %}{% if settings.edit_enabled %} {{ settings.edit_string }}{% endif %} ++ {% if media.description %}{{ media.description }}{% endif %} + + +
+
+-
+diff -Naur colorbox/templates/album_list.html bgstack15/templates/album_list.html +--- colorbox/templates/album_list.html 2021-01-24 14:32:13.437676429 -0500 ++++ bgstack15/templates/album_list.html 2021-01-26 11:07:33.304994900 -0500 +@@ -13,7 +13,7 @@ + + {{ alb.title }} +- {{ alb.title }} ++ {{ alb.title }}

+

+ {% if loop.last or loop.index % nb_columns == 0 %} + +diff -Naur colorbox/templates/base.html bgstack15/templates/base.html +--- colorbox/templates/base.html 2021-01-24 14:32:13.437676429 -0500 ++++ bgstack15/templates/base.html 2021-01-26 19:48:52.253246381 -0500 +@@ -43,7 +43,7 @@ + + {% if album.description %} +
+- {{ album.description }} ++ {{ album.description }}{%endif%}{% if settings.edit_enabled %} {{ settings.edit_string }}{% if album.description %}{% endif %} +
+ {% endif %} + +Footer.html is from the default sigal theme. +diff -Naur colorbox/templates/footer.html bgstack15/templates/footer.html +--- colorbox/templates/footer.html 1969-12-31 19:00:00.000000000 -0500 ++++ bgstack15/templates/footer.html 2021-01-24 16:12:46.323753022 -0500 +@@ -0,0 +1,16 @@ ++
++

++ {% if album.author %} ++ © {{ album.author }} ++ {% endif %} ++ {# removed "generated by sigal" text from original footer.html bgstack15 #} ++ {% if 'sigal.plugins.feeds' in settings.plugins %} ++ {% if settings.rss_feed %} ++ RSS Feed ++ {% endif %} ++ {% if settings.atom_feed %} ++ Atom Feed ++ {% endif %} ++ {% endif %} ++

++
+Links.html is from the default sigal theme. +diff -Naur colorbox/templates/links.html bgstack15/templates/links.html +--- colorbox/templates/links.html 1969-12-31 19:00:00.000000000 -0500 ++++ bgstack15/templates/links.html 2021-01-26 20:24:11.346480465 -0500 +@@ -0,0 +1,10 @@ ++{% if settings.links or settings.edit_enabled %} ++ ++{% endif %} +diff -Naur colorbox/templates/media.html bgstack15/templates/media.html +--- colorbox/templates/media.html 2021-01-24 14:32:13.438676357 -0500 ++++ bgstack15/templates/media.html 2021-01-24 15:54:56.374587308 -0500 +@@ -16,6 +16,7 @@ +
+ {% if media.type == "image" %} + {{ media.title }} ++

{{ media.title }}

+ {% endif %} + {% if media.type == "video" %} +