From 19d40a5ee98fb1f244612155acc559ff2f21bf6b Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 12 Feb 2020 00:09:34 +0100 Subject: viewer: implemented config.json Note: The DevServer needs to know when the file is from the App, or from the FileSystem. We use a tilde to make this separation. The tilde URL is declared in '.env.development' GitHub: Resolves #32 --- example/config.json | 4 ++++ viewer/.env | 6 +++--- viewer/.env.development | 3 +++ viewer/src/@types/gallery.d.ts | 5 +++++ viewer/src/components/LdPicture.vue | 12 +++++++----- viewer/src/components/LdThumbnail.vue | 7 +++---- viewer/src/store/galleryStore.ts | 18 ++++++++++++++++-- viewer/src/views/MainLayout.vue | 3 ++- viewer/vue.config.js | 2 +- 9 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 example/config.json create mode 100644 viewer/.env.development diff --git a/example/config.json b/example/config.json new file mode 100644 index 0000000..6487594 --- /dev/null +++ b/example/config.json @@ -0,0 +1,4 @@ +{ + "generationTimestamp": 0, + "galleryRoot": "out/" +} \ No newline at end of file diff --git a/viewer/.env b/viewer/.env index 959477b..0914292 100644 --- a/viewer/.env +++ b/viewer/.env @@ -1,5 +1,5 @@ +# Override with .env.development.local and .env.production.local + VUE_APP_I18N_LOCALE=en VUE_APP_I18N_FALLBACK_LOCALE=en -VUE_APP_EXAMPLE_PROJECT=../example/out/ -VUE_APP_DATA_URL=gallery/ -VUE_APP_DEVSERVER_PORT=8085 +VUE_APP_DATA_URL=./ diff --git a/viewer/.env.development b/viewer/.env.development new file mode 100644 index 0000000..0d87cf4 --- /dev/null +++ b/viewer/.env.development @@ -0,0 +1,3 @@ +VUE_APP_DEVSERVER_PORT=8085 +VUE_APP_DEVSERVER_CONFIG_PATH=../example/ +VUE_APP_DATA_URL=~/ diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts index 1987416..865f621 100644 --- a/viewer/src/@types/gallery.d.ts +++ b/viewer/src/@types/gallery.d.ts @@ -18,6 +18,11 @@ */ declare namespace Gallery { + interface Config { + generationTimestamp: number, + galleryRoot: string, + } + interface Other extends Item { properties: OtherProperties, } diff --git a/viewer/src/components/LdPicture.vue b/viewer/src/components/LdPicture.vue index 8a9a08e..a5faeb3 100644 --- a/viewer/src/components/LdPicture.vue +++ b/viewer/src/components/LdPicture.vue @@ -28,7 +28,7 @@ @dragscrollend="dragScrollClickFix.onDragScrollEnd()" > diff --git a/viewer/src/components/LdThumbnail.vue b/viewer/src/components/LdThumbnail.vue index 17c7659..13468e1 100644 --- a/viewer/src/components/LdThumbnail.vue +++ b/viewer/src/components/LdThumbnail.vue @@ -21,7 +21,7 @@
config.json()) + .then(this.setConfig); + } + // Fetches the gallery's JSON metadata - @action async fetchGalleryItems(url: string) { - return fetch(url) + @action async fetchGalleryItems() { + const root = this.config?.galleryRoot ?? ''; + const timestamp = this.config?.generationTimestamp ?? 0; + return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json?${timestamp}`) .then(response => response.json()) .then(this.setGalleryItemsRoot) .then(this.indexTags); diff --git a/viewer/src/views/MainLayout.vue b/viewer/src/views/MainLayout.vue index 12388a9..63a1b83 100644 --- a/viewer/src/views/MainLayout.vue +++ b/viewer/src/views/MainLayout.vue @@ -60,7 +60,8 @@ export default class MainLayout extends Vue { fetchGalleryItems() { this.isLoading = true; this.$galleryStore - .fetchGalleryItems(`${process.env.VUE_APP_DATA_URL}index.json`) + .fetchConfig() + .then(this.$galleryStore.fetchGalleryItems) .finally(() => (this.isLoading = false)) .catch(this.displayError); } diff --git a/viewer/vue.config.js b/viewer/vue.config.js index 9d885bd..9b92dc2 100644 --- a/viewer/vue.config.js +++ b/viewer/vue.config.js @@ -43,7 +43,7 @@ module.exports = { const url = req.url.slice(process.env.VUE_APP_DATA_URL.length); const paramIdx = url.indexOf('?'); const filepath = paramIdx < 0 ? url : url.substring(0, paramIdx); - const fullpath = `${process.env.VUE_APP_EXAMPLE_PROJECT}${decodeURIComponent(filepath)}`; + const fullpath = `${process.env.VUE_APP_DEVSERVER_CONFIG_PATH}${decodeURIComponent(filepath)}`; const file = fs.readFileSync(fullpath); res.end(file); }); -- cgit v1.2.3 From ee9d82d0b307dee1c9138babf954a3864a0c2f83 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Wed, 12 Feb 2020 00:33:45 +0100 Subject: example: cleaner examples --- compiler/win_compile_example.cmd | 2 +- example/Glacier 3000/_DSC5475.jpg | Bin 363216 -> 0 bytes example/Glacier 3000/_DSC5475.jpg.yaml | 15 --------------- example/Glacier 3000/_DSC5542.jpg | Bin 457873 -> 0 bytes example/Glacier 3000/_DSC5542.jpg.yaml | 15 --------------- example/Glacier 3000/thumbnail.jpg | Bin 457873 -> 0 bytes example/_DSC8808-1.jpg | Bin 1010643 -> 0 bytes example/_DSC8808-1.jpg.yaml | 12 ------------ example/gallery.yaml | 26 -------------------------- example/readme.md | 3 +-- example/src/Glacier 3000/_DSC5475.jpg | Bin 0 -> 363216 bytes example/src/Glacier 3000/_DSC5475.jpg.yaml | 15 +++++++++++++++ example/src/Glacier 3000/_DSC5542.jpg | Bin 0 -> 457873 bytes example/src/Glacier 3000/_DSC5542.jpg.yaml | 15 +++++++++++++++ example/src/Glacier 3000/thumbnail.jpg | Bin 0 -> 457873 bytes example/src/_DSC8808-1.jpg | Bin 0 -> 1010643 bytes example/src/_DSC8808-1.jpg.yaml | 12 ++++++++++++ example/src/gallery.yaml | 26 ++++++++++++++++++++++++++ viewer/public/config.json | 4 ---- viewer/public/config.json.example | 4 ++++ 20 files changed, 74 insertions(+), 75 deletions(-) delete mode 100644 example/Glacier 3000/_DSC5475.jpg delete mode 100644 example/Glacier 3000/_DSC5475.jpg.yaml delete mode 100644 example/Glacier 3000/_DSC5542.jpg delete mode 100644 example/Glacier 3000/_DSC5542.jpg.yaml delete mode 100644 example/Glacier 3000/thumbnail.jpg delete mode 100644 example/_DSC8808-1.jpg delete mode 100644 example/_DSC8808-1.jpg.yaml delete mode 100644 example/gallery.yaml create mode 100644 example/src/Glacier 3000/_DSC5475.jpg create mode 100644 example/src/Glacier 3000/_DSC5475.jpg.yaml create mode 100644 example/src/Glacier 3000/_DSC5542.jpg create mode 100644 example/src/Glacier 3000/_DSC5542.jpg.yaml create mode 100644 example/src/Glacier 3000/thumbnail.jpg create mode 100644 example/src/_DSC8808-1.jpg create mode 100644 example/src/_DSC8808-1.jpg.yaml create mode 100644 example/src/gallery.yaml delete mode 100644 viewer/public/config.json create mode 100644 viewer/public/config.json.example diff --git a/compiler/win_compile_example.cmd b/compiler/win_compile_example.cmd index 6e166f8..3a52f73 100644 --- a/compiler/win_compile_example.cmd +++ b/compiler/win_compile_example.cmd @@ -5,5 +5,5 @@ IF ERRORLEVEL 2 SET rebuild= echo. @echo on -stack exec ldgallery-compiler-exe -- %rebuild% --clean-output -i=../example/ -o=../example/out/ +stack exec ldgallery-compiler-exe -- %rebuild% --clean-output -i=../example/src/ -o=../example/out/ @pause diff --git a/example/Glacier 3000/_DSC5475.jpg b/example/Glacier 3000/_DSC5475.jpg deleted file mode 100644 index 9835447..0000000 Binary files a/example/Glacier 3000/_DSC5475.jpg and /dev/null differ diff --git a/example/Glacier 3000/_DSC5475.jpg.yaml b/example/Glacier 3000/_DSC5475.jpg.yaml deleted file mode 100644 index 3454a68..0000000 --- a/example/Glacier 3000/_DSC5475.jpg.yaml +++ /dev/null @@ -1,15 +0,0 @@ -title: Fog 3000 - -datetime: 2019-08-10T14:38:47+01:00 - -description: > - © Philippe NGUYEN - -tags: - - photographer.nphilou - - location.switzerland.ormont-dessus - - glacier3000 - - time.day - - weather.foggy - - forest - - trees diff --git a/example/Glacier 3000/_DSC5542.jpg b/example/Glacier 3000/_DSC5542.jpg deleted file mode 100644 index 19a716e..0000000 Binary files a/example/Glacier 3000/_DSC5542.jpg and /dev/null differ diff --git a/example/Glacier 3000/_DSC5542.jpg.yaml b/example/Glacier 3000/_DSC5542.jpg.yaml deleted file mode 100644 index d174911..0000000 --- a/example/Glacier 3000/_DSC5542.jpg.yaml +++ /dev/null @@ -1,15 +0,0 @@ -title: Foggy catwalk - -datetime: 2019-08-10T16:00:45+01:00 - -description: > - © Philippe NGUYEN - -tags: - - photographer.nphilou - - location.switzerland.ormont-dessus - - glacier3000 - - time.day - - weather.foggy - - catwalk - - mountain diff --git a/example/Glacier 3000/thumbnail.jpg b/example/Glacier 3000/thumbnail.jpg deleted file mode 100644 index 19a716e..0000000 Binary files a/example/Glacier 3000/thumbnail.jpg and /dev/null differ diff --git a/example/_DSC8808-1.jpg b/example/_DSC8808-1.jpg deleted file mode 100644 index 51b43b0..0000000 Binary files a/example/_DSC8808-1.jpg and /dev/null differ diff --git a/example/_DSC8808-1.jpg.yaml b/example/_DSC8808-1.jpg.yaml deleted file mode 100644 index b946ff7..0000000 --- a/example/_DSC8808-1.jpg.yaml +++ /dev/null @@ -1,12 +0,0 @@ -title: Book shop - -datetime: 2016-12-19T16:48:50+02:00 - -description: > - © Philippe NGUYEN - -tags: - - photographer.nphilou - - location.germany.berlin - - books - - book-shop diff --git a/example/gallery.yaml b/example/gallery.yaml deleted file mode 100644 index ea23d8a..0000000 --- a/example/gallery.yaml +++ /dev/null @@ -1,26 +0,0 @@ -compiler: - galleryName: Example gallery - - #includedDirectories: ["*"] - #excludedDirectories: [] - - includedFiles: - - "*.jpg" - - #excludedFiles: - #- "*.md" - - tagsFromDirectories: 0 # default - - thumbnailMaxResolution: - width: 400 # default - height: 300 # default - - pictureMaxResolution: - width: 1024 - height: 768 - - #jpegExportQuality: 80 # default - - -viewer: {} diff --git a/example/readme.md b/example/readme.md index d5a7563..087a8bc 100644 --- a/example/readme.md +++ b/example/readme.md @@ -8,7 +8,7 @@ Content ------- ``` -./example +./example/src ├── _DSC8808-1.jpg -- a picture ├── _DSC8808-1.jpg.yaml -- its associated sidecar metadata file ├── Glacier 3000 -- a directory grouping gallery items @@ -18,5 +18,4 @@ Content │   ├── _DSC5542.jpg │   └── _DSC5542.jpg.yaml ├── gallery.yaml -- gallery settings file -└── readme.md -- this README ``` diff --git a/example/src/Glacier 3000/_DSC5475.jpg b/example/src/Glacier 3000/_DSC5475.jpg new file mode 100644 index 0000000..9835447 Binary files /dev/null and b/example/src/Glacier 3000/_DSC5475.jpg differ diff --git a/example/src/Glacier 3000/_DSC5475.jpg.yaml b/example/src/Glacier 3000/_DSC5475.jpg.yaml new file mode 100644 index 0000000..3454a68 --- /dev/null +++ b/example/src/Glacier 3000/_DSC5475.jpg.yaml @@ -0,0 +1,15 @@ +title: Fog 3000 + +datetime: 2019-08-10T14:38:47+01:00 + +description: > + © Philippe NGUYEN + +tags: + - photographer.nphilou + - location.switzerland.ormont-dessus + - glacier3000 + - time.day + - weather.foggy + - forest + - trees diff --git a/example/src/Glacier 3000/_DSC5542.jpg b/example/src/Glacier 3000/_DSC5542.jpg new file mode 100644 index 0000000..19a716e Binary files /dev/null and b/example/src/Glacier 3000/_DSC5542.jpg differ diff --git a/example/src/Glacier 3000/_DSC5542.jpg.yaml b/example/src/Glacier 3000/_DSC5542.jpg.yaml new file mode 100644 index 0000000..d174911 --- /dev/null +++ b/example/src/Glacier 3000/_DSC5542.jpg.yaml @@ -0,0 +1,15 @@ +title: Foggy catwalk + +datetime: 2019-08-10T16:00:45+01:00 + +description: > + © Philippe NGUYEN + +tags: + - photographer.nphilou + - location.switzerland.ormont-dessus + - glacier3000 + - time.day + - weather.foggy + - catwalk + - mountain diff --git a/example/src/Glacier 3000/thumbnail.jpg b/example/src/Glacier 3000/thumbnail.jpg new file mode 100644 index 0000000..19a716e Binary files /dev/null and b/example/src/Glacier 3000/thumbnail.jpg differ diff --git a/example/src/_DSC8808-1.jpg b/example/src/_DSC8808-1.jpg new file mode 100644 index 0000000..51b43b0 Binary files /dev/null and b/example/src/_DSC8808-1.jpg differ diff --git a/example/src/_DSC8808-1.jpg.yaml b/example/src/_DSC8808-1.jpg.yaml new file mode 100644 index 0000000..b946ff7 --- /dev/null +++ b/example/src/_DSC8808-1.jpg.yaml @@ -0,0 +1,12 @@ +title: Book shop + +datetime: 2016-12-19T16:48:50+02:00 + +description: > + © Philippe NGUYEN + +tags: + - photographer.nphilou + - location.germany.berlin + - books + - book-shop diff --git a/example/src/gallery.yaml b/example/src/gallery.yaml new file mode 100644 index 0000000..ea23d8a --- /dev/null +++ b/example/src/gallery.yaml @@ -0,0 +1,26 @@ +compiler: + galleryName: Example gallery + + #includedDirectories: ["*"] + #excludedDirectories: [] + + includedFiles: + - "*.jpg" + + #excludedFiles: + #- "*.md" + + tagsFromDirectories: 0 # default + + thumbnailMaxResolution: + width: 400 # default + height: 300 # default + + pictureMaxResolution: + width: 1024 + height: 768 + + #jpegExportQuality: 80 # default + + +viewer: {} diff --git a/viewer/public/config.json b/viewer/public/config.json deleted file mode 100644 index 7023edb..0000000 --- a/viewer/public/config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "generationTimestamp": 0, - "galleryRoot": "gallery/" -} \ No newline at end of file diff --git a/viewer/public/config.json.example b/viewer/public/config.json.example new file mode 100644 index 0000000..7023edb --- /dev/null +++ b/viewer/public/config.json.example @@ -0,0 +1,4 @@ +{ + "generationTimestamp": 0, + "galleryRoot": "gallery/" +} \ No newline at end of file -- cgit v1.2.3 From 1763c8ce725098100618079553a9ec4f79386a5d Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 13 Feb 2020 17:44:34 +0100 Subject: viewer: no-cache for config.json and index.json --- example/config.json | 1 - viewer/public/config.json.example | 1 - viewer/src/@types/gallery.d.ts | 1 - viewer/src/store/galleryStore.ts | 4 ++-- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/example/config.json b/example/config.json index 6487594..51baf84 100644 --- a/example/config.json +++ b/example/config.json @@ -1,4 +1,3 @@ { - "generationTimestamp": 0, "galleryRoot": "out/" } \ No newline at end of file diff --git a/viewer/public/config.json.example b/viewer/public/config.json.example index 7023edb..90c5f74 100644 --- a/viewer/public/config.json.example +++ b/viewer/public/config.json.example @@ -1,4 +1,3 @@ { - "generationTimestamp": 0, "galleryRoot": "gallery/" } \ No newline at end of file diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts index 865f621..44eecf6 100644 --- a/viewer/src/@types/gallery.d.ts +++ b/viewer/src/@types/gallery.d.ts @@ -19,7 +19,6 @@ declare namespace Gallery { interface Config { - generationTimestamp: number, galleryRoot: string, } diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index bcd4bc9..6f5f0ad 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -66,7 +66,7 @@ export default class GalleryStore extends VuexModule { // Fetches the gallery's JSON config @action async fetchConfig() { - return fetch(`${process.env.VUE_APP_DATA_URL}config.json`) + return fetch(`${process.env.VUE_APP_DATA_URL}config.json`, { cache: "no-cache" }) .then(config => config.json()) .then(this.setConfig); } @@ -75,7 +75,7 @@ export default class GalleryStore extends VuexModule { @action async fetchGalleryItems() { const root = this.config?.galleryRoot ?? ''; const timestamp = this.config?.generationTimestamp ?? 0; - return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json?${timestamp}`) + return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setGalleryItemsRoot) .then(this.indexTags); -- cgit v1.2.3 From ef1778e051e007f08f9188a479d04fdf95a57d21 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Thu, 13 Feb 2020 18:13:55 +0100 Subject: documentation --- example/readme.md | 5 +++-- ldgallery.1.md | 6 ------ viewer/readme.md | 4 ++++ 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/example/readme.md b/example/readme.md index 087a8bc..e455f03 100644 --- a/example/readme.md +++ b/example/readme.md @@ -8,7 +8,8 @@ Content ------- ``` -./example/src +./example/out -- the output directory for the compiled version of the gallery +./example/src -- source directory with pictures, configuration, tags and metadata ├── _DSC8808-1.jpg -- a picture ├── _DSC8808-1.jpg.yaml -- its associated sidecar metadata file ├── Glacier 3000 -- a directory grouping gallery items @@ -17,5 +18,5 @@ Content │   ├── _DSC5475.jpg.yaml │   ├── _DSC5542.jpg │   └── _DSC5542.jpg.yaml -├── gallery.yaml -- gallery settings file +└── gallery.yaml -- gallery settings file ``` diff --git a/ldgallery.1.md b/ldgallery.1.md index 8928693..f071344 100644 --- a/ldgallery.1.md +++ b/ldgallery.1.md @@ -126,9 +126,6 @@ compiler.pictureMaxResolution.width compiler.pictureMaxResolution.height : Maximum height in pixels of the picture items, unlimited by default. -viewer.defaultSearchMode [TODO] -: Default search view mode ("highlight" or "filter"). Defaults to "filter". - viewer.defaultSearchQuery [TODO] : Default search query string. @@ -138,9 +135,6 @@ viewer.defaultSortOrder [TODO] viewer.tagGroups[].tag [TODO] : Tag prefix defining the tag group. -viewer.tagGroups[].order [TODO] -: Order in which to display tag groups. - viewer.tagGroups[].colour [TODO] : Colour associated to the tag group. diff --git a/viewer/readme.md b/viewer/readme.md index 864dcc6..3757f3e 100644 --- a/viewer/readme.md +++ b/viewer/readme.md @@ -8,6 +8,10 @@ npm install ``` ### Compiles and hot-reloads for development + +The viewer DevServer will serve the compiled version of the example gallery by default. +To override, create a file .env.development.local + ``` npm run serve ``` -- cgit v1.2.3