From 695ec94d7cc66d2194b0cb45ed41ad78afd88b4f Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Mar 2022 21:06:58 +0100 Subject: [PATCH 1/5] Always load lg-admin plugin --- photologue/static/lightgallery/plugins/admin/lg-admin.js | 2 ++ photologue/templates/photologue/gallery_detail.html | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/photologue/static/lightgallery/plugins/admin/lg-admin.js b/photologue/static/lightgallery/plugins/admin/lg-admin.js index 64ba238..53b0f4f 100644 --- a/photologue/static/lightgallery/plugins/admin/lg-admin.js +++ b/photologue/static/lightgallery/plugins/admin/lg-admin.js @@ -8,6 +8,7 @@ class lgAdmin { constructor(instance, $LG) { this.core = instance; this.$LG = $LG; + this.isStaff = instance.settings.isStaff; return this; } @@ -19,6 +20,7 @@ class lgAdmin { 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-admin").style.display = this.isStaff ? 'block' : 'none'; } // Admin must have destroy prototype 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 %} From 1e98c517298f263d09a68d5a5e1629f936c163b8 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Mar 2022 21:21:02 +0100 Subject: [PATCH 2/5] Add report and delete icons --- .../lightgallery/plugins/admin/lg-admin.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/photologue/static/lightgallery/plugins/admin/lg-admin.js b/photologue/static/lightgallery/plugins/admin/lg-admin.js index 53b0f4f..890c983 100644 --- a/photologue/static/lightgallery/plugins/admin/lg-admin.js +++ b/photologue/static/lightgallery/plugins/admin/lg-admin.js @@ -13,16 +13,29 @@ class lgAdmin { } 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-admin").style.display = this.isStaff ? 'block' : 'none'; } - // Admin must have destroy prototype + // Plugins must have destroy prototype destroy() { } } From 84e96e2497835deeee28deb5d3437801a6dd995b Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Mar 2022 21:30:52 +0100 Subject: [PATCH 3/5] Align viewer icons --- photologue/static/lightgallery/css/lightgallery.css | 4 ++++ .../static/lightgallery/plugins/admin/lg-admin.js | 12 ++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) 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 890c983..44a3b04 100644 --- a/photologue/static/lightgallery/plugins/admin/lg-admin.js +++ b/photologue/static/lightgallery/plugins/admin/lg-admin.js @@ -13,20 +13,20 @@ class lgAdmin { } init() { - const adminIcon = ""; - const deleteIcon = "";; - const reportIcon = ""; + const adminIcon = ""; + const deleteIcon = "";; + const reportIcon = ""; // Add button linking to Django admin page - this.core.$toolbar.append(`${adminIcon}`); + 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}`); + 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.$toolbar.append(`${reportIcon}`); this.core.LGel.on("lgAfterSlide.admin", this.onAfterSlide.bind(this)); } From d2506a587d0acab304695199707ead5cc33dd246 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Mar 2022 21:38:58 +0100 Subject: [PATCH 4/5] Link delete and report icons --- photologue/static/lightgallery/plugins/admin/lg-admin.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/photologue/static/lightgallery/plugins/admin/lg-admin.js b/photologue/static/lightgallery/plugins/admin/lg-admin.js index 44a3b04..6884b2d 100644 --- a/photologue/static/lightgallery/plugins/admin/lg-admin.js +++ b/photologue/static/lightgallery/plugins/admin/lg-admin.js @@ -34,6 +34,8 @@ class lgAdmin { 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)}`; } // Plugins must have destroy prototype From 407a73cc89c15ae44d094d280456110c897a739b Mon Sep 17 00:00:00 2001 From: Alexandre Iooss Date: Tue, 1 Mar 2022 21:41:31 +0100 Subject: [PATCH 5/5] Add titles to viewer action buttons --- photologue/static/lightgallery/plugins/admin/lg-admin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/photologue/static/lightgallery/plugins/admin/lg-admin.js b/photologue/static/lightgallery/plugins/admin/lg-admin.js index 6884b2d..9f8695c 100644 --- a/photologue/static/lightgallery/plugins/admin/lg-admin.js +++ b/photologue/static/lightgallery/plugins/admin/lg-admin.js @@ -18,15 +18,15 @@ class lgAdmin { const reportIcon = ""; // Add button linking to Django admin page - this.core.$toolbar.append(`${adminIcon}`); + 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}`); + 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.$toolbar.append(`${reportIcon}`); this.core.LGel.on("lgAfterSlide.admin", this.onAfterSlide.bind(this)); }