diff --git a/photologue/static/lightgallery/css/lightgallery.css b/photologue/static/lightgallery/css/lightgallery.css index d74d81f..fd98e44 100644 --- a/photologue/static/lightgallery/css/lightgallery.css +++ b/photologue/static/lightgallery/css/lightgallery.css @@ -719,3 +719,7 @@ body:not(.lg-from-hash) .lg-outer.lg-start-zoom .lg-item.lg-complete .lg-object right: 0; left: 0; } + +.lg-toolbar .lg-bi-icon { + padding: 5px 0 !important; +} diff --git a/photologue/static/lightgallery/plugins/admin/lg-admin.js b/photologue/static/lightgallery/plugins/admin/lg-admin.js index 64ba238..9f8695c 100644 --- a/photologue/static/lightgallery/plugins/admin/lg-admin.js +++ b/photologue/static/lightgallery/plugins/admin/lg-admin.js @@ -8,19 +8,36 @@ class lgAdmin { constructor(instance, $LG) { this.core = instance; this.$LG = $LG; + this.isStaff = instance.settings.isStaff; return this; } init() { - this.core.$toolbar.append("\uE033"); + const adminIcon = ""; + const deleteIcon = "";; + const reportIcon = ""; + + // Add button linking to Django admin page + this.core.$toolbar.append(`${adminIcon}`); + document.getElementById("lg-admin").style.display = this.isStaff ? 'block' : 'none'; + + // Add button to delete photo + this.core.$toolbar.append(`${deleteIcon}`); + document.getElementById("lg-delete").style.display = this.isStaff ? 'block' : 'none'; + + // Add button to report photo + this.core.$toolbar.append(`${reportIcon}`); + this.core.LGel.on("lgAfterSlide.admin", this.onAfterSlide.bind(this)); } onAfterSlide(event) { const photoId = this.core.galleryItems[event.detail.index].slideName; document.getElementById("lg-admin").href = `https://photos.crans.org/admin/photologue/photo/${photoId}/change/`; + document.getElementById("lg-delete").href = `https://photos.crans.org/admin/photologue/photo/${photoId}/delete/`; + document.getElementById("lg-report").href = `mailto:photos@crans.org?subject=[ABUS] Photo ${photoId}&body=${encodeURIComponent(window.location.href)}`; } - // Admin must have destroy prototype + // Plugins must have destroy prototype destroy() { } } diff --git a/photologue/templates/photologue/gallery_detail.html b/photologue/templates/photologue/gallery_detail.html index 4975d54..3561932 100644 --- a/photologue/templates/photologue/gallery_detail.html +++ b/photologue/templates/photologue/gallery_detail.html @@ -20,8 +20,9 @@ SPDX-License-Identifier: GPL-3.0-or-later {% endblock %}