diff options
author | pacien | 2020-02-25 16:03:00 +0100 |
---|---|---|
committer | Notkea | 2020-02-25 19:18:00 +0100 |
commit | 2766f5f9a491c5f7ebf1eeac1c970daec3656be2 (patch) | |
tree | 59e626febb85476a6bc476b94cb28fc186729c34 | |
parent | 9f5b07ccde8f54bb4d1905c8d51e69f762aed057 (diff) | |
download | ldgallery-2766f5f9a491c5f7ebf1eeac1c970daec3656be2.tar.gz |
transverse: combine item tree and gallery-wide properties
GitHub: closes #142
-rw-r--r-- | compiler/src/Compiler.hs | 18 | ||||
-rw-r--r-- | design-notes.md | 2 | ||||
-rw-r--r-- | viewer/src/@types/gallery.d.ts | 7 | ||||
-rw-r--r-- | 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 | |||
22 | ) where | 22 | ) where |
23 | 23 | ||
24 | 24 | ||
25 | import GHC.Generics (Generic) | ||
25 | import Control.Monad (liftM2, when) | 26 | import Control.Monad (liftM2, when) |
26 | import Data.List (any) | 27 | import Data.List (any) |
27 | import System.FilePath ((</>)) | 28 | import System.FilePath ((</>)) |
@@ -33,7 +34,7 @@ import qualified Data.Aeson as JSON | |||
33 | 34 | ||
34 | import Config | 35 | import Config |
35 | import Input (readInputTree) | 36 | import Input (readInputTree) |
36 | import Resource (buildGalleryTree, galleryCleanupResourceDir) | 37 | import Resource (GalleryItem, buildGalleryTree, galleryCleanupResourceDir) |
37 | import Files | 38 | import Files |
38 | ( FileName | 39 | ( FileName |
39 | , FSNode(..) | 40 | , FSNode(..) |
@@ -53,9 +54,6 @@ defaultGalleryConf = "gallery.yaml" | |||
53 | indexFile :: String | 54 | indexFile :: String |
54 | indexFile = "index.json" | 55 | indexFile = "index.json" |
55 | 56 | ||
56 | viewerConfFile :: String | ||
57 | viewerConfFile = "viewer.json" | ||
58 | |||
59 | itemsDir :: String | 57 | itemsDir :: String |
60 | itemsDir = "items" | 58 | itemsDir = "items" |
61 | 59 | ||
@@ -63,6 +61,12 @@ thumbnailsDir :: String | |||
63 | thumbnailsDir = "thumbnails" | 61 | thumbnailsDir = "thumbnails" |
64 | 62 | ||
65 | 63 | ||
64 | data GalleryIndex = GalleryIndex | ||
65 | { properties :: ViewerConfig | ||
66 | , tree :: GalleryItem | ||
67 | } deriving (Generic, Show, ToJSON) | ||
68 | |||
69 | |||
66 | writeJSON :: ToJSON a => FileName -> a -> IO () | 70 | writeJSON :: ToJSON a => FileName -> a -> IO () |
67 | writeJSON outputPath object = | 71 | writeJSON outputPath object = |
68 | do | 72 | do |
@@ -117,17 +121,13 @@ compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cle | |||
117 | resources <- galleryBuilder inputTree | 121 | resources <- galleryBuilder inputTree |
118 | 122 | ||
119 | when cleanOutput $ galleryCleanupResourceDir resources outputDirPath | 123 | when cleanOutput $ galleryCleanupResourceDir resources outputDirPath |
120 | writeJSON outputIndex resources | 124 | writeJSON (outputDirPath </> indexFile) $ GalleryIndex (viewerConfig config) resources |
121 | writeJSON outputViewerConf $ viewerConfig config | ||
122 | 125 | ||
123 | where | 126 | where |
124 | inputGalleryConf :: FilePath -> FilePath | 127 | inputGalleryConf :: FilePath -> FilePath |
125 | inputGalleryConf "" = inputDirPath </> defaultGalleryConf | 128 | inputGalleryConf "" = inputDirPath </> defaultGalleryConf |
126 | inputGalleryConf file = file | 129 | inputGalleryConf file = file |
127 | 130 | ||
128 | outputIndex = outputDirPath </> indexFile | ||
129 | outputViewerConf = outputDirPath </> viewerConfFile | ||
130 | |||
131 | itemProcessor config cache = | 131 | itemProcessor config cache = |
132 | itemFileProcessor | 132 | itemFileProcessor |
133 | (pictureMaxResolution config) cache | 133 | (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 | |||
234 | 234 | ||
235 | Items other than directories are displayed by this view, making use of most of the screen space to render the element. | 235 | Items other than directories are displayed by this view, making use of most of the screen space to render the element. |
236 | 236 | ||
237 | 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`. | 237 | 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`. |
238 | 238 | ||
239 | It should be possible to navigate between items of the same directory as the current one through a thumbnail reel and previous/next links. | 239 | 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 { | |||
22 | galleryRoot: string, | 22 | galleryRoot: string, |
23 | } | 23 | } |
24 | 24 | ||
25 | interface GalleryProperties { | ||
26 | // empty for now | ||
27 | } | ||
28 | interface Index { | ||
29 | properties: GalleryProperties, | ||
30 | tree: Item | ||
31 | } | ||
25 | interface Other extends Item { | 32 | interface Other extends Item { |
26 | properties: OtherProperties, | 33 | properties: OtherProperties, |
27 | } | 34 | } |
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 { | |||
77 | const root = this.config?.galleryRoot ?? ''; | 77 | const root = this.config?.galleryRoot ?? ''; |
78 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) | 78 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) |
79 | .then(response => response.json()) | 79 | .then(response => response.json()) |
80 | .then(index => index.tree) | ||
80 | .then(this.setGalleryItemsRoot) | 81 | .then(this.setGalleryItemsRoot) |
81 | .then(this.indexTags); | 82 | .then(this.indexTags); |
82 | } | 83 | } |