diff --git a/backend/static/css/30-download.css b/backend/static/css/30-download.css
index 005c70f..04342b1 100644
--- a/backend/static/css/30-download.css
+++ b/backend/static/css/30-download.css
@@ -704,6 +704,11 @@
pointer-events: none;
}
+.download-share-button {
+ margin-top: 1rem;
+ margin-bottom: 0.65rem;
+}
+
.upload-processing-alert {
margin: 1rem 0;
padding: .85rem 1rem;
diff --git a/backend/static/js/13-share.js b/backend/static/js/13-share.js
new file mode 100644
index 0000000..a4a7954
--- /dev/null
+++ b/backend/static/js/13-share.js
@@ -0,0 +1,50 @@
+(function () {
+ const shareButtons = document.querySelectorAll("[data-share-box]");
+ if (shareButtons.length === 0) {
+ return;
+ }
+
+ shareButtons.forEach((button) => {
+ const label = button.querySelector("[data-share-box-label]") || button;
+ const shareData = {
+ title: button.dataset.shareTitle || document.title,
+ text: button.dataset.shareText || "",
+ url: window.Warpbox.absoluteURL(button.dataset.shareUrl || window.location.href),
+ };
+ const canShare = typeof navigator.share === "function" && (!navigator.canShare || navigator.canShare(shareData));
+
+ label.textContent = canShare ? "Share" : "Copy Link";
+ button.setAttribute("aria-label", canShare ? "Share this box" : "Copy box link");
+
+ button.addEventListener("click", async () => {
+ if (canShare) {
+ try {
+ await navigator.share(shareData);
+ return;
+ } catch (error) {
+ if (error && error.name === "AbortError") {
+ return;
+ }
+ }
+ }
+ await copyShareURL(button, label, shareData.url, canShare);
+ });
+ });
+
+ async function copyShareURL(button, label, url, shareMode) {
+ try {
+ await window.Warpbox.writeClipboard(url);
+ const previous = label.textContent;
+ label.textContent = "Copied";
+ window.setTimeout(() => {
+ label.textContent = shareMode ? "Share" : "Copy Link";
+ }, 1400);
+ } catch (error) {
+ if (window.Warpbox && typeof window.Warpbox.error === "function") {
+ window.Warpbox.error("The share link could not be copied.", {
+ title: "Copy failed",
+ });
+ }
+ }
+ }
+})();
diff --git a/backend/templates/layouts/base.html b/backend/templates/layouts/base.html
index 0a69102..7d58ee5 100644
--- a/backend/templates/layouts/base.html
+++ b/backend/templates/layouts/base.html
@@ -72,6 +72,7 @@
+
diff --git a/backend/templates/pages/download.html b/backend/templates/pages/download.html
index 92dea3c..9d2e3de 100644
--- a/backend/templates/pages/download.html
+++ b/backend/templates/pages/download.html
@@ -43,6 +43,10 @@
{{if not .Data.Locked}}
+
{{if or $processing $failed}}
{{if $failed}}Download unavailable{{else}}Files processing{{end}}