aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
authorpacien2020-02-25 20:19:54 +0100
committerNotkea2020-02-27 14:35:01 +0100
commit74e4a83ac7511086f45d2fa9880b7ae5728020bd (patch)
treef4d07bea56ea09de0f7aadee84cd426907714056 /compiler/src
parentdd1e092af09cc3d780ed546aadf9fc9baa799371 (diff)
downloadldgallery-74e4a83ac7511086f45d2fa9880b7ae5728020bd.tar.gz
compiler: add cli arg for output gallery index
GitHub: closes #143
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/Compiler.hs14
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
51defaultGalleryConf :: String 51defaultGalleryConf :: String
52defaultGalleryConf = "gallery.yaml" 52defaultGalleryConf = "gallery.yaml"
53 53
54indexFile :: String 54defaultIndexFile :: String
55indexFile = "index.json" 55defaultIndexFile = "index.json"
56 56
57itemsDir :: String 57itemsDir :: String
58itemsDir = "items" 58itemsDir = "items"
@@ -103,8 +103,8 @@ galleryDirFilter config excludedCanonicalDirs =
103 isExcludedDir File{} = False 103 isExcludedDir File{} = False
104 104
105 105
106compileGallery :: FilePath -> FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO () 106compileGallery :: FilePath -> FilePath -> FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO ()
107compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput = 107compileGallery 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