diff options
author | Zero~Informatique | 2020-09-11 21:06:31 +0200 |
---|---|---|
committer | G.Fouet | 2020-09-11 21:53:18 +0200 |
commit | eb636568643e892491fd925f7a92fc3feba6a67e (patch) | |
tree | 1a82841f45e757f020c3ed9c84ad21cc456ae8a3 | |
parent | f89ed0bd94ea570d9e6533301783d13b13033db0 (diff) | |
download | ldgallery-eb636568643e892491fd925f7a92fc3feba6a67e.tar.gz |
viewer: config.json url parameter + index.json configuration
github: resolves #160
-rw-r--r-- | example/config.json | 1 | ||||
-rw-r--r-- | viewer/src/@types/gallery.d.ts | 3 | ||||
-rw-r--r-- | viewer/src/store/galleryStore.ts | 11 |
3 files changed, 12 insertions, 3 deletions
diff --git a/example/config.json b/example/config.json index 5827d25..b66bfcd 100644 --- a/example/config.json +++ b/example/config.json | |||
@@ -1,4 +1,5 @@ | |||
1 | { | 1 | { |
2 | "galleryRoot": "out/", | 2 | "galleryRoot": "out/", |
3 | "galleryIndex": "index.json", | ||
3 | "initialTagDisplayLimit": 10 | 4 | "initialTagDisplayLimit": 10 |
4 | } | 5 | } |
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts index 56feff0..b756331 100644 --- a/viewer/src/@types/gallery.d.ts +++ b/viewer/src/@types/gallery.d.ts | |||
@@ -20,7 +20,8 @@ | |||
20 | declare namespace Gallery { | 20 | declare namespace Gallery { |
21 | interface Config { | 21 | interface Config { |
22 | galleryRoot: string; | 22 | galleryRoot: string; |
23 | initialTagDisplayLimit: number; | 23 | galleryIndex?: string; |
24 | initialTagDisplayLimit?: number; | ||
24 | } | 25 | } |
25 | 26 | ||
26 | interface GalleryProperties { | 27 | interface GalleryProperties { |
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 768adb6..b672551 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts | |||
@@ -85,7 +85,7 @@ export default class GalleryStore extends VuexModule { | |||
85 | 85 | ||
86 | // Fetches the gallery's JSON config | 86 | // Fetches the gallery's JSON config |
87 | @action async fetchConfig() { | 87 | @action async fetchConfig() { |
88 | return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) | 88 | return fetch(`${process.env.VUE_APP_DATA_URL}${GalleryStore.getUrlConfig()}`, { cache: "no-cache" }) |
89 | .then(response => response.json()) | 89 | .then(response => response.json()) |
90 | .then(this.setConfig); | 90 | .then(this.setConfig); |
91 | } | 91 | } |
@@ -93,7 +93,8 @@ export default class GalleryStore extends VuexModule { | |||
93 | // Fetches the gallery's JSON metadata | 93 | // Fetches the gallery's JSON metadata |
94 | @action async fetchGalleryItems() { | 94 | @action async fetchGalleryItems() { |
95 | const root = this.config?.galleryRoot ?? ""; | 95 | const root = this.config?.galleryRoot ?? ""; |
96 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) | 96 | const index = this.config?.galleryIndex ?? "index.json"; |
97 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}${index}`, { cache: "no-cache" }) | ||
97 | .then(response => response.json()) | 98 | .then(response => response.json()) |
98 | .then(this.setGalleryIndex) | 99 | .then(this.setGalleryIndex) |
99 | .then(this.indexTags) | 100 | .then(this.indexTags) |
@@ -121,4 +122,10 @@ export default class GalleryStore extends VuexModule { | |||
121 | this.setCurrentSearch(results); | 122 | this.setCurrentSearch(results); |
122 | return results; | 123 | return results; |
123 | } | 124 | } |
125 | |||
126 | private static getUrlConfig() { | ||
127 | let search = window.location.search; | ||
128 | if (search.length > 1) return search.substr(1) + ".json"; | ||
129 | return "config.json"; | ||
130 | } | ||
124 | } | 131 | } |