From 2766f5f9a491c5f7ebf1eeac1c970daec3656be2 Mon Sep 17 00:00:00 2001 From: pacien Date: Tue, 25 Feb 2020 16:03:00 +0100 Subject: transverse: combine item tree and gallery-wide properties GitHub: closes #142 --- compiler/src/Compiler.hs | 18 +++++++++--------- design-notes.md | 2 +- viewer/src/@types/gallery.d.ts | 7 +++++++ viewer/src/store/galleryStore.ts | 1 + 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index 73ac8a4..2970102 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs @@ -22,6 +22,7 @@ module Compiler ) where +import GHC.Generics (Generic) import Control.Monad (liftM2, when) import Data.List (any) import System.FilePath (()) @@ -33,7 +34,7 @@ import qualified Data.Aeson as JSON import Config import Input (readInputTree) -import Resource (buildGalleryTree, galleryCleanupResourceDir) +import Resource (GalleryItem, buildGalleryTree, galleryCleanupResourceDir) import Files ( FileName , FSNode(..) @@ -53,9 +54,6 @@ defaultGalleryConf = "gallery.yaml" indexFile :: String indexFile = "index.json" -viewerConfFile :: String -viewerConfFile = "viewer.json" - itemsDir :: String itemsDir = "items" @@ -63,6 +61,12 @@ thumbnailsDir :: String thumbnailsDir = "thumbnails" +data GalleryIndex = GalleryIndex + { properties :: ViewerConfig + , tree :: GalleryItem + } deriving (Generic, Show, ToJSON) + + writeJSON :: ToJSON a => FileName -> a -> IO () writeJSON outputPath object = do @@ -117,17 +121,13 @@ compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cle resources <- galleryBuilder inputTree when cleanOutput $ galleryCleanupResourceDir resources outputDirPath - writeJSON outputIndex resources - writeJSON outputViewerConf $ viewerConfig config + writeJSON (outputDirPath indexFile) $ GalleryIndex (viewerConfig config) resources where inputGalleryConf :: FilePath -> FilePath inputGalleryConf "" = inputDirPath defaultGalleryConf inputGalleryConf file = file - outputIndex = outputDirPath indexFile - outputViewerConf = outputDirPath viewerConfFile - itemProcessor config cache = itemFileProcessor (pictureMaxResolution config) cache diff --git a/design-notes.md b/design-notes.md index d59f511..0d7b5c1 100644 --- a/design-notes.md +++ b/design-notes.md @@ -234,6 +234,6 @@ By default, the content is rendered in the same ordered as listed in `index.json Items other than directories are displayed by this view, making use of most of the screen space to render the element. -This view should as well display the title, description, date, tags and other information associated to the item. Tags in particular are displayed in a grouped manner as determined in `viewer.json`. +This view should as well display the title, description, date, tags and other information associated to the item. Tags in particular are displayed in a grouped manner as determined in `index.json`. It should be possible to navigate between items of the same directory as the current one through a thumbnail reel and previous/next links. diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts index 03d21fc..d7645b6 100644 --- a/viewer/src/@types/gallery.d.ts +++ b/viewer/src/@types/gallery.d.ts @@ -22,6 +22,13 @@ declare namespace Gallery { galleryRoot: string, } + interface GalleryProperties { + // empty for now + } + interface Index { + properties: GalleryProperties, + tree: Item + } interface Other extends Item { properties: OtherProperties, } diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index d2b28dd..cd09996 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts @@ -77,6 +77,7 @@ export default class GalleryStore extends VuexModule { const root = this.config?.galleryRoot ?? ''; return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) + .then(index => index.tree) .then(this.setGalleryItemsRoot) .then(this.indexTags); } -- cgit v1.2.3