#10 improvement in case of missing media folder

This commit is contained in:
Vincent CLAVIEN
2025-01-26 14:02:11 +01:00
parent 42639a8556
commit b89eccbe02
10 changed files with 45 additions and 14 deletions

View File

@@ -252,8 +252,14 @@ function loadAttachedMedia(att, index) {
url = url.slice(prefix); url = url.slice(prefix);
} }
if (!data[root + url]) { if (!data[root + url]) {
// 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: null,
};
return; return;
} } else {
data[root + url].async("base64").then((content) => { data[root + url].async("base64").then((content) => {
Alpine.store("files").sources[index][att.url] = { Alpine.store("files").sources[index][att.url] = {
type: att.mediaType, type: att.mediaType,
@@ -261,6 +267,7 @@ function loadAttachedMedia(att, index) {
}; };
}); });
} }
}
} }
function pagingUpdated() { function pagingUpdated() {

View File

@@ -118,6 +118,7 @@ appStrings["en"] = {
linkToPost: "link", linkToPost: "link",
attachmentNoAlt: "No description provided", attachmentNoAlt: "No description provided",
attachmentInArchive: "In archive:", attachmentInArchive: "In archive:",
attachmentNotFound: "⚠️ Content not found in archive",
people: "People", people: "People",
hashtags: "Hashtags", hashtags: "Hashtags",
extLinks: "External links", extLinks: "External links",

View File

@@ -118,6 +118,7 @@ appStrings["fr"] = {
linkToPost: "lien", linkToPost: "lien",
attachmentNoAlt: "Aucune description fournie", attachmentNoAlt: "Aucune description fournie",
attachmentInArchive: "Dans l'archive :", attachmentInArchive: "Dans l'archive :",
attachmentNotFound: "⚠️ Média introuvable à l'emplacement indiqué",
people: "Personnes", people: "Personnes",
hashtags: "Hashtags", hashtags: "Hashtags",
extLinks: "Liens externes", extLinks: "Liens externes",

View File

@@ -1,12 +1,21 @@
<div class="att-description"> <div class="att-description">
<span <div
class="att-not-found"
x-show="$store.files.sources[toot._marl.source][att.url].content === null"
>
<span x-text="$t('post.attachmentNotFound')"></span>
(<span x-text="att.mediaType"></span>)
</div>
<div
class="desc-body" class="desc-body"
x-text="att.name ?? $t('post.attachmentNoAlt')" x-text="att.name ?? $t('post.attachmentNoAlt')"
:id="'att-' + toot._marl.id + '-' + index + '-desc'" :id="'att-' + toot._marl.id + '-' + index + '-desc'"
aria-hidden="true" aria-hidden="true"
></div>
<div class="desc-source">
<strong x-text="$t('post.attachmentInArchive')"></strong>
<span
x-text="$store.files.sources[toot._marl.source].fileInfos.archiveRoot + att.url"
></span> ></span>
<span class="desc-source"> </div>
<strong x-text="$t('post.attachmentInArchive')"></strong> <span
x-text="$store.files.sources[toot._marl.source].fileInfos.archiveRoot + att.url"></span>
</span>
</div> </div>

View File

@@ -10,6 +10,7 @@ import AttachmentDescription from './AttachmentDescription.astro'
class="att-img-wrapper" class="att-img-wrapper"
@click="$store.lightbox.open(toot, index, 'att-' + toot._marl.id + '-' + index)" @click="$store.lightbox.open(toot, index, 'att-' + toot._marl.id + '-' + index)"
:id="'att-' + toot._marl.id + '-' + index" :id="'att-' + toot._marl.id + '-' + index"
x-show="$store.files.sources[toot._marl.source][att.url].content"
> >
<img <img
alt="" alt=""

View File

@@ -8,6 +8,7 @@ import AttachmentDescription from './AttachmentDescription.astro'
<div class="att-wrapper"> <div class="att-wrapper">
<audio <audio
controls controls
x-show="$store.files.sources[toot._marl.source][att.url].content"
:src="`data:${att.mediaType}; base64,${await $store.files.sources[toot._marl.source][att.url].content}`" :src="`data:${att.mediaType}; base64,${await $store.files.sources[toot._marl.source][att.url].content}`"

View File

@@ -8,6 +8,7 @@ import AttachmentDescription from './AttachmentDescription.astro'
<div class="att-wrapper"> <div class="att-wrapper">
<video <video
controls controls
x-show="$store.files.sources[toot._marl.source][att.url].content"
:width="att.width" :width="att.width"
:height="att.height" :height="att.height"
:src="`data:${att.mediaType}; base64,${await $store.files.sources[toot._marl.source][att.url].content}`" :src="`data:${att.mediaType}; base64,${await $store.files.sources[toot._marl.source][att.url].content}`"

View File

@@ -125,12 +125,18 @@ $meta-visible: 100ch;
list-style: none; list-style: none;
} }
.att-not-found {
margin-bottom: 0.5rem;
color: var(--accent);
font-weight: bold;
}
.att-description { .att-description {
font-size: 0.85em; font-size: 0.85em;
line-height: 1.4; line-height: 1.4;
} }
.no-alt-text { .no-alt-text {
.att-description { .desc-body {
font-style: italic; font-style: italic;
} }
} }

View File

@@ -17,6 +17,8 @@ Alternatively, you can download this project from its [project page](https://git
⚠️ __Only ZIP files are supported__ —not GZ files. This is a limitation of the JSZip library which is used by MARL to unpack the archive file. Older versions of Mastodon (prior to version 4.2.0) used to export the archive in TAR.GZ. If this is your case, you will have to first convert your archive to a ZIP file. ⚠️ __Only ZIP files are supported__ —not GZ files. This is a limitation of the JSZip library which is used by MARL to unpack the archive file. Older versions of Mastodon (prior to version 4.2.0) used to export the archive in TAR.GZ. If this is your case, you will have to first convert your archive to a ZIP file.
⚠️ __A note about very large archives:__ Browsers may struggle opening very large ZIP files (several GB), in which case you will see an error and the archive will not be loaded. If this happens, you can try upacking your archive, removing the `media_attachments` folder, and repacking everything else. This will significantly reduce the size of the archive, by removing all attachments from your posts (images, videos or sounds). MARL will still be able to work without those attachments and display their media type and alt text (or lack thereof). Filters related to attachments still work too. Also note that for each attachment, MARL indicates where you can find it in your archive.
## Screenshots ## Screenshots
<img src="screenshot-multiple-archives.png" alt="app screenshot with multiple files loaded"> <img src="screenshot-multiple-archives.png" alt="app screenshot with multiple files loaded">
@@ -126,6 +128,8 @@ Mastodon: https://lou.lt/@s427
## Version history ## Version history
- v. 2.3
- [Github issue #10](https://github.com/s427/MARL/issues/10) Support for archives with `media_attachments` folder removed. This allows very large archive files, which would normally fail to load because they exceed the browser cache capacity, to still be loaded, although without any attachment visible. Attachments metadata (alt text and path) are still shown, and attachment-related filters still work.
- v. 2.2 - v. 2.2
- Better error handling when loading files - Better error handling when loading files
- In case of errors, MARL should not remain stuck on the loading screen anymore, but will get back to the welcome screen (or the main screen if another archive is already loaded) and show an error message (either directly on the welcome screen, or in the tools panel). - In case of errors, MARL should not remain stuck on the loading screen anymore, but will get back to the welcome screen (or the main screen if another archive is already loaded) and show an error message (either directly on the welcome screen, or in the tools panel).