From 7bd88b9d462903ae7753b9ef7a3613ebcd9bad45 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 25 Jun 2021 12:09:30 +0200
Subject: viewer/GalleryNavigation: uniquely identify viewer instances by item

This forces viewer components to be re-instantiated on item change.

GitHub: fixes #268
---
 viewer/src/views/GalleryNavigation.vue | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index fd1f19a..c53df66 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -21,7 +21,7 @@
   <div>
     <ld-error v-if="isError" icon="folder-open" :message="$t('gallery.unknown-resource')" />
     <gallery-search v-else-if="isSearch" :path="path" />
-    <component :is="componentName" v-else :item="$galleryStore.currentItem" />
+    <component :is="componentName" v-else :key="$galleryStore.currentItem.path" :item="$galleryStore.currentItem" />
   </div>
 </template>
 
-- 
cgit v1.2.3


From 6b125a393d8ce10bfd9273c24ea1615b335abeba Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sat, 26 Jun 2021 17:44:03 +0200
Subject: viewer/GalleryNavigation: uniquely identify viewer instances by item

Fixed error "Object is possibly 'null'" in the template
---
 viewer/src/views/GalleryNavigation.vue | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index c53df66..69198f6 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -21,7 +21,7 @@
   <div>
     <ld-error v-if="isError" icon="folder-open" :message="$t('gallery.unknown-resource')" />
     <gallery-search v-else-if="isSearch" :path="path" />
-    <component :is="componentName" v-else :key="$galleryStore.currentItem.path" :item="$galleryStore.currentItem" />
+    <component :is="componentName" v-else :key="componentKey" :item="$galleryStore.currentItem" />
   </div>
 </template>
 
@@ -66,6 +66,10 @@ export default class GalleryNavigation extends Vue {
     return this.COMPONENT_BY_TYPE[this.$galleryStore.currentItem?.properties.type ?? ItemType.OTHER];
   }
 
+  get componentKey() {
+    return this.$galleryStore.currentItem?.path ?? "";
+  }
+
   @Watch("path")
   pathChanged() {
     this.$galleryStore.setCurrentPath(this.path);
-- 
cgit v1.2.3


From 9165cc1efcf7791f78b61b2c51a9de651b1b09aa Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Fri, 2 Jul 2021 22:53:16 +0200
Subject: viewer: types normalization - gallery.d.ts

GitHub: closes #301
---
 viewer/src/views/GalleryNavigation.vue | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 69198f6..8bb225a 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -26,10 +26,10 @@
 </template>
 
 <script lang="ts">
-import { Component, Vue, Prop, Watch } from "vue-property-decorator";
 import { ItemType } from "@/@types/ItemType";
 import Navigation from "@/services/navigation";
 import GallerySearch from "@/views/GallerySearch.vue";
+import { Component, Prop, Vue, Watch } from "vue-property-decorator";
 
 @Component({
   components: {
@@ -41,13 +41,13 @@ export default class GalleryNavigation extends Vue {
   @Prop(Array) readonly query!: string[];
 
   readonly COMPONENT_BY_TYPE: Record<ItemType, string> = {
-    directory: "ld-directory",
-    picture: "ld-picture",
+    directory: "ld-directory-viewer",
+    picture: "ld-picture-viewer",
     plaintext: "ld-plain-text-viewer",
     pdf: "ld-pdf-viewer",
     video: "ld-video-viewer",
     audio: "ld-audio-viewer",
-    other: "ld-download",
+    other: "ld-download-viewer",
   };
 
   mounted() {
-- 
cgit v1.2.3


From dfa1c6e2f2977c32f75c1d93d9e7eb44fbed28c0 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sun, 4 Jul 2021 02:22:39 +0200
Subject: viewer: use CSS modules

GitHub: closes #196
---
 viewer/src/views/GalleryNavigation.vue | 2 --
 1 file changed, 2 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 8bb225a..fdd3922 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -80,5 +80,3 @@ export default class GalleryNavigation extends Vue {
   }
 }
 </script>
-
-<style lang="scss"></style>
-- 
cgit v1.2.3


From 2f9e51b5cd7dfafadac90ec896edd365da12a1c8 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Sat, 3 Jul 2021 23:07:09 +0200
Subject: viewer: add markdown item handler

Extracted from b170f49 (GH PR #304)
---
 viewer/src/views/GalleryNavigation.vue | 1 +
 1 file changed, 1 insertion(+)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index fdd3922..200637e 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -44,6 +44,7 @@ export default class GalleryNavigation extends Vue {
     directory: "ld-directory-viewer",
     picture: "ld-picture-viewer",
     plaintext: "ld-plain-text-viewer",
+    markdown: "ld-markdown-viewer",
     pdf: "ld-pdf-viewer",
     video: "ld-video-viewer",
     audio: "ld-audio-viewer",
-- 
cgit v1.2.3


From 00510820a2794efcadbc83f7f8b54318fe198ecb Mon Sep 17 00:00:00 2001
From: Zéro~Informatique
Date: Tue, 26 Jul 2022 08:44:34 +0200
Subject: viewer: migrate to vue 3, general refactoring and cleanup

Non-exhaustive list of fixes and improvements done at the same time:

- html default background to grey (avoids white flash during init)
- unified links behavior
- added more theme variables
- removed the flex-expand transition (it wasn't working) and replaced it
  with a slide
- fixed LdLoading not centered on the content
- title on removable tags
- fixed an issue with encoded URI from vue-router
- unified Item resource URLs
- removed the iframe for PlainTextViewer (it wasn't working properly)
  and replaced it with a pre
- fixed clear and search buttons tabindex
- fixed the information panel bumping up during the fade animation of
  tag's dropdown
- fixed some focus outlines not appearing correctly
- moved CSS variables to the :root context
- Code cleaning

GitHub: closes #217
GitHub: closes #300
GitHub: closes #297
GitHub: closes #105
GitHub: closes #267
GitHub: closes #275
GitHub: closes #228
GitHub: closes #215
GitHub: closes #112
---
 viewer/src/views/GalleryNavigation.vue | 106 ++++++++++++++++-----------------
 1 file changed, 52 insertions(+), 54 deletions(-)

(limited to 'viewer/src/views/GalleryNavigation.vue')

diff --git a/viewer/src/views/GalleryNavigation.vue b/viewer/src/views/GalleryNavigation.vue
index 200637e..0869aaf 100644
--- a/viewer/src/views/GalleryNavigation.vue
+++ b/viewer/src/views/GalleryNavigation.vue
@@ -1,7 +1,7 @@
 <!-- ldgallery - A static generator which turns a collection of tagged
 --             pictures into a searchable web gallery.
 --
--- Copyright (C) 2019-2020  Guillaume FOUET
+-- Copyright (C) 2019-2022  Guillaume FOUET
 --
 -- This program is free software: you can redistribute it and/or modify
 -- it under the terms of the GNU Affero General Public License as
@@ -19,65 +19,63 @@
 
 <template>
   <div>
-    <ld-error v-if="isError" icon="folder-open" :message="$t('gallery.unknown-resource')" />
-    <gallery-search v-else-if="isSearch" :path="path" />
-    <component :is="componentName" v-else :key="componentKey" :item="$galleryStore.currentItem" />
+    <LdNotice
+      v-if="isError"
+      :icon="faFolderOpen"
+      :message="t('gallery.unknown-resource')"
+    />
+    <GallerySearch v-else-if="isSearch" />
+    <component
+      :is="componentName"
+      v-else
+      :key="componentKey"
+      :item="galleryStore.currentItem"
+    />
   </div>
 </template>
 
-<script lang="ts">
-import { ItemType } from "@/@types/ItemType";
-import Navigation from "@/services/navigation";
-import GallerySearch from "@/views/GallerySearch.vue";
-import { Component, Prop, Vue, Watch } from "vue-property-decorator";
+<script setup lang="ts">
+import { ItemType } from '@/@types/itemType';
+import LdNotice from '@/components/LdNotice.vue';
+import { isDirectory } from '@/services/itemGuards';
+import { useGalleryStore } from '@/store/galleryStore';
+import { faFolderOpen } from '@fortawesome/free-solid-svg-icons';
+import { computedEager } from '@vueuse/shared';
+import { computed, watchEffect } from 'vue';
+import { useI18n } from 'vue-i18n';
+import GallerySearch from './GallerySearch.vue';
+import AudioViewer from './item_handlers/AudioViewer.vue';
+import DirectoryViewer from './item_handlers/DirectoryViewer.vue';
+import DownloadViewer from './item_handlers/DownloadViewer.vue';
+import MarkdownViewer from './item_handlers/MarkdownViewer.vue';
+import PdfViewer from './item_handlers/PdfViewer.vue';
+import PictureViewer from './item_handlers/PictureViewer.vue';
+import PlainTextViewer from './item_handlers/PlainTextViewer.vue';
+import VideoViewer from './item_handlers/VideoViewer.vue';
 
-@Component({
-  components: {
-    GallerySearch,
-  },
-})
-export default class GalleryNavigation extends Vue {
-  @Prop(String) readonly path!: string;
-  @Prop(Array) readonly query!: string[];
+const props = defineProps({
+  path: { type: String, required: true },
+  query: { type: Array<string>, required: true },
+});
 
-  readonly COMPONENT_BY_TYPE: Record<ItemType, string> = {
-    directory: "ld-directory-viewer",
-    picture: "ld-picture-viewer",
-    plaintext: "ld-plain-text-viewer",
-    markdown: "ld-markdown-viewer",
-    pdf: "ld-pdf-viewer",
-    video: "ld-video-viewer",
-    audio: "ld-audio-viewer",
-    other: "ld-download-viewer",
-  };
+const { t } = useI18n();
+const galleryStore = useGalleryStore();
 
-  mounted() {
-    this.pathChanged();
-  }
+const COMPONENT_BY_TYPE: Record<ItemType, unknown> = {
+  directory: DirectoryViewer,
+  picture: PictureViewer,
+  plaintext: PlainTextViewer,
+  markdown: MarkdownViewer,
+  pdf: PdfViewer,
+  video: VideoViewer,
+  audio: AudioViewer,
+  other: DownloadViewer,
+};
 
-  get isError() {
-    return this.checkType(null);
-  }
+const isError = computedEager(() => !galleryStore.currentItem?.properties.type);
+const isSearch = computedEager(() => isDirectory(galleryStore.currentItem) && props.query.length > 0);
+const componentName = computed(() => COMPONENT_BY_TYPE[galleryStore.currentItem?.properties.type ?? ItemType.OTHER]);
+const componentKey = computed(() => galleryStore.currentItem?.path ?? '');
 
-  get isSearch() {
-    return this.checkType(ItemType.DIRECTORY) && this.query.length > 0;
-  }
-
-  get componentName() {
-    return this.COMPONENT_BY_TYPE[this.$galleryStore.currentItem?.properties.type ?? ItemType.OTHER];
-  }
-
-  get componentKey() {
-    return this.$galleryStore.currentItem?.path ?? "";
-  }
-
-  @Watch("path")
-  pathChanged() {
-    this.$galleryStore.setCurrentPath(this.path);
-  }
-
-  checkType(type: ItemType | null): boolean {
-    return Navigation.checkType(this.$galleryStore.currentItem, type);
-  }
-}
+watchEffect(() => (galleryStore.currentPath = props.path));
 </script>
-- 
cgit v1.2.3

