From b89eccbe026bffc1026c934cb8a2a1a68bc6e34b Mon Sep 17 00:00:00 2001 From: Vincent CLAVIEN Date: Sun, 26 Jan 2025 14:02:11 +0100 Subject: [PATCH] #10 improvement in case of missing media folder --- dev/public/js/MARL/utils.js | 17 ++++++++++----- dev/public/js/i18n/en.js | 1 + dev/public/js/i18n/fr.js | 1 + .../panels/posts/AttachmentDescription.astro | 21 +++++++++++++------ .../panels/posts/AttachmentImage.astro | 1 + .../panels/posts/AttachmentSound.astro | 1 + .../panels/posts/AttachmentVideo.astro | 1 + dev/src/css/_toot.scss | 8 ++++++- dev/src/pages/index.astro | 4 ++-- readme.md | 4 ++++ 10 files changed, 45 insertions(+), 14 deletions(-) diff --git a/dev/public/js/MARL/utils.js b/dev/public/js/MARL/utils.js index fe98aa7..962b873 100644 --- a/dev/public/js/MARL/utils.js +++ b/dev/public/js/MARL/utils.js @@ -252,14 +252,21 @@ function loadAttachedMedia(att, index) { url = url.slice(prefix); } if (!data[root + url]) { - return; - } - data[root + url].async("base64").then((content) => { + // media not found in archive + // we still want to show the metadata for the attachement Alpine.store("files").sources[index][att.url] = { type: att.mediaType, - content: content, + content: null, }; - }); + return; + } else { + data[root + url].async("base64").then((content) => { + Alpine.store("files").sources[index][att.url] = { + type: att.mediaType, + content: content, + }; + }); + } } } diff --git a/dev/public/js/i18n/en.js b/dev/public/js/i18n/en.js index cc70f80..d353547 100644 --- a/dev/public/js/i18n/en.js +++ b/dev/public/js/i18n/en.js @@ -118,6 +118,7 @@ appStrings["en"] = { linkToPost: "link", attachmentNoAlt: "No description provided", attachmentInArchive: "In archive:", + attachmentNotFound: "⚠️ Content not found in archive", people: "People", hashtags: "Hashtags", extLinks: "External links", diff --git a/dev/public/js/i18n/fr.js b/dev/public/js/i18n/fr.js index 70b6eba..6ffc62a 100644 --- a/dev/public/js/i18n/fr.js +++ b/dev/public/js/i18n/fr.js @@ -118,6 +118,7 @@ appStrings["fr"] = { linkToPost: "lien", attachmentNoAlt: "Aucune description fournie", attachmentInArchive: "Dans l'archive :", + attachmentNotFound: "⚠️ Média introuvable à l'emplacement indiqué", people: "Personnes", hashtags: "Hashtags", extLinks: "Liens externes", diff --git a/dev/src/components/panels/posts/AttachmentDescription.astro b/dev/src/components/panels/posts/AttachmentDescription.astro index 5508a61..23a8cee 100644 --- a/dev/src/components/panels/posts/AttachmentDescription.astro +++ b/dev/src/components/panels/posts/AttachmentDescription.astro @@ -1,12 +1,21 @@
- + + () +
+ +
+ + +
diff --git a/dev/src/components/panels/posts/AttachmentImage.astro b/dev/src/components/panels/posts/AttachmentImage.astro index cb6516d..27a66cf 100644 --- a/dev/src/components/panels/posts/AttachmentImage.astro +++ b/dev/src/components/panels/posts/AttachmentImage.astro @@ -10,6 +10,7 @@ import AttachmentDescription from './AttachmentDescription.astro' class="att-img-wrapper" @click="$store.lightbox.open(toot, index, 'att-' + toot._marl.id + '-' + index)" :id="'att-' + toot._marl.id + '-' + index" + x-show="$store.files.sources[toot._marl.source][att.url].content" >