From 13272cb9c7f9a33e6ee5728f235438d82562d9c5 Mon Sep 17 00:00:00 2001 From: krek0 Date: Sat, 9 May 2026 11:57:50 +0200 Subject: [PATCH] Add possiblity to share gallerie with public link --- photo21/static/copy-button.js | 24 ++++ photo21/templates/base.html | 2 + photo21/views.py | 28 ++++- ...lter_photo_options_gallery_public_token.py | 22 ++++ photologue/models.py | 7 ++ .../templates/photologue/gallery_detail.html | 17 ++- photologue/urls.py | 4 + photologue/views.py | 107 ++++++++++++------ 8 files changed, 174 insertions(+), 37 deletions(-) create mode 100644 photo21/static/copy-button.js create mode 100644 photologue/migrations/0009_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 91f63cb..ccd17c2 100644 --- a/photo21/templates/base.html +++ b/photo21/templates/base.html @@ -37,6 +37,7 @@ SPDX-License-Identifier: GPL-3.0-or-later