From a875c2707b59ab9b8af68d5bef3871cc0f7cd4fd Mon Sep 17 00:00:00 2001 From: krek0 Date: Mon, 20 Apr 2026 22:29:17 +0200 Subject: [PATCH] Add public shareable link for galleries --- photo21/static/copy-button.js | 24 +++++++ photo21/templates/base.html | 2 + ...lter_photo_options_gallery_public_token.py | 22 +++++++ photologue/models.py | 7 +++ .../templates/photologue/gallery_detail.html | 18 ++++++ photologue/urls.py | 4 ++ photologue/views.py | 63 ++++++++++++++----- 7 files changed, 126 insertions(+), 14 deletions(-) create mode 100644 photo21/static/copy-button.js create mode 100644 photologue/migrations/0004_alter_photo_options_gallery_public_token.py diff --git a/photo21/static/copy-button.js b/photo21/static/copy-button.js new file mode 100644 index 0000000..91f7ec8 --- /dev/null +++ b/photo21/static/copy-button.js @@ -0,0 +1,24 @@ +document.querySelectorAll('[data-clipboard-text]').forEach(function(btn) { + btn.addEventListener('click', function() { + var text = btn.dataset.clipboardText; + if (navigator.clipboard) { + navigator.clipboard.writeText(text); + } else { + var ta = document.createElement('textarea'); + ta.value = text; + ta.style.position = 'fixed'; + ta.style.opacity = '0'; + document.body.appendChild(ta); + ta.select(); + document.execCommand('copy'); + document.body.removeChild(ta); + } + var original = btn.textContent; + btn.textContent = '✓ Copied!'; + btn.disabled = true; + setTimeout(function() { + btn.textContent = original; + btn.disabled = false; + }, 2000); + }); +}); diff --git a/photo21/templates/base.html b/photo21/templates/base.html index 66ea520..9a1c499 100644 --- a/photo21/templates/base.html +++ b/photo21/templates/base.html @@ -36,6 +36,7 @@ SPDX-License-Identifier: GPL-3.0-or-later