diff options
author | pacien | 2020-02-25 20:19:54 +0100 |
---|---|---|
committer | Notkea | 2020-02-27 14:35:01 +0100 |
commit | 74e4a83ac7511086f45d2fa9880b7ae5728020bd (patch) | |
tree | f4d07bea56ea09de0f7aadee84cd426907714056 /compiler/src/Compiler.hs | |
parent | dd1e092af09cc3d780ed546aadf9fc9baa799371 (diff) | |
download | ldgallery-74e4a83ac7511086f45d2fa9880b7ae5728020bd.tar.gz |
compiler: add cli arg for output gallery index
GitHub: closes #143
Diffstat (limited to 'compiler/src/Compiler.hs')
-rw-r--r-- | compiler/src/Compiler.hs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index 2970102..51f5065 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs | |||
@@ -51,8 +51,8 @@ import Processors | |||
51 | defaultGalleryConf :: String | 51 | defaultGalleryConf :: String |
52 | defaultGalleryConf = "gallery.yaml" | 52 | defaultGalleryConf = "gallery.yaml" |
53 | 53 | ||
54 | indexFile :: String | 54 | defaultIndexFile :: String |
55 | indexFile = "index.json" | 55 | defaultIndexFile = "index.json" |
56 | 56 | ||
57 | itemsDir :: String | 57 | itemsDir :: String |
58 | itemsDir = "items" | 58 | itemsDir = "items" |
@@ -103,8 +103,8 @@ galleryDirFilter config excludedCanonicalDirs = | |||
103 | isExcludedDir File{} = False | 103 | isExcludedDir File{} = False |
104 | 104 | ||
105 | 105 | ||
106 | compileGallery :: FilePath -> FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO () | 106 | compileGallery :: FilePath -> FilePath -> FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO () |
107 | compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput = | 107 | compileGallery configPath inputDirPath outputDirPath outputIndexPath excludedDirs rebuildAll cleanOutput = |
108 | do | 108 | do |
109 | config <- readConfig $ inputGalleryConf configPath | 109 | config <- readConfig $ inputGalleryConf configPath |
110 | 110 | ||
@@ -121,13 +121,17 @@ compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cle | |||
121 | resources <- galleryBuilder inputTree | 121 | resources <- galleryBuilder inputTree |
122 | 122 | ||
123 | when cleanOutput $ galleryCleanupResourceDir resources outputDirPath | 123 | when cleanOutput $ galleryCleanupResourceDir resources outputDirPath |
124 | writeJSON (outputDirPath </> indexFile) $ GalleryIndex (viewerConfig config) resources | 124 | writeJSON (outputGalleryIndex outputIndexPath) $ GalleryIndex (viewerConfig config) resources |
125 | 125 | ||
126 | where | 126 | where |
127 | inputGalleryConf :: FilePath -> FilePath | 127 | inputGalleryConf :: FilePath -> FilePath |
128 | inputGalleryConf "" = inputDirPath </> defaultGalleryConf | 128 | inputGalleryConf "" = inputDirPath </> defaultGalleryConf |
129 | inputGalleryConf file = file | 129 | inputGalleryConf file = file |
130 | 130 | ||
131 | outputGalleryIndex :: FilePath -> FilePath | ||
132 | outputGalleryIndex "" = outputDirPath </> defaultIndexFile | ||
133 | outputGalleryIndex file = file | ||
134 | |||
131 | itemProcessor config cache = | 135 | itemProcessor config cache = |
132 | itemFileProcessor | 136 | itemFileProcessor |
133 | (pictureMaxResolution config) cache | 137 | (pictureMaxResolution config) cache |