diff options
Diffstat (limited to 'compiler/src')
-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 |