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 /compiler | |
parent | 9f5b07ccde8f54bb4d1905c8d51e69f762aed057 (diff) | |
download | ldgallery-2766f5f9a491c5f7ebf1eeac1c970daec3656be2.tar.gz |
transverse: combine item tree and gallery-wide properties
GitHub: closes #142
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/src/Compiler.hs | 18 |
1 files changed, 9 insertions, 9 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 |