From d0a199e9b580e141389614788a2b902762f92084 Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Fri, 3 Apr 2026 20:01:48 +0200 Subject: [PATCH] fix: HTML export tojson filter + authenticated file download (v0.14.1) - Enable minijinja 'json' feature so the tojson filter is available in the Memories.html template (was causing 'unknown filter' render error) - Replace window.location.href downloads with fetch+blob so the Authorization header is sent (window.location.href caused 401) Co-Authored-By: Claude Sonnet 4.6 --- backend/Cargo.toml | 2 +- frontend/src/routes/export/+page.svelte | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 773d281..d909aed 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -29,7 +29,7 @@ sysinfo = "0.32" image = "0.25" oxipng = "9" async_zip = { version = "0.0.17", features = ["tokio", "deflate"] } -minijinja = "2" +minijinja = { version = "2", features = ["json"] } [profile.release] opt-level = 3 diff --git a/frontend/src/routes/export/+page.svelte b/frontend/src/routes/export/+page.svelte index e0eb76f..1e3b892 100644 --- a/frontend/src/routes/export/+page.svelte +++ b/frontend/src/routes/export/+page.svelte @@ -72,13 +72,28 @@ } } + async function downloadFile(endpoint: string, filename: string) { + const token = getToken(); + const res = await fetch(endpoint, { + headers: token ? { Authorization: `Bearer ${token}` } : {} + }); + if (!res.ok) return; + const blob = await res.blob(); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = filename; + a.click(); + URL.revokeObjectURL(url); + } + function downloadZip() { - window.location.href = '/api/v1/export/zip'; + downloadFile('/api/v1/export/zip', 'Gallery.zip'); } function downloadHtml() { if (localStorage.getItem(HTML_GUIDE_KEY)) { - window.location.href = '/api/v1/export/html'; + downloadFile('/api/v1/export/html', 'Memories.zip'); } else { showHtmlGuide = true; } @@ -87,7 +102,7 @@ function confirmHtmlDownload() { localStorage.setItem(HTML_GUIDE_KEY, '1'); showHtmlGuide = false; - window.location.href = '/api/v1/export/html'; + downloadFile('/api/v1/export/html', 'Memories.zip'); }