aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/app/Main.hs8
-rw-r--r--compiler/ldgallery.1.md5
-rw-r--r--compiler/src/Compiler.hs14
3 files changed, 22 insertions, 5 deletions
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 404de4b..a4b6ae2 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -39,6 +39,7 @@ data ViewerConfig = ViewerConfig
39data Options = Options 39data Options = Options
40 { inputDir :: FilePath 40 { inputDir :: FilePath
41 , outputDir :: FilePath 41 , outputDir :: FilePath
42 , outputIndex :: FilePath
42 , galleryConfig :: FilePath 43 , galleryConfig :: FilePath
43 , rebuilAll :: Bool 44 , rebuilAll :: Bool
44 , cleanOutput :: Bool 45 , cleanOutput :: Bool
@@ -59,6 +60,12 @@ options = Options
59 &= name "output-dir" 60 &= name "output-dir"
60 &= explicit 61 &= explicit
61 &= help "Generated gallery output path (default=./out)" 62 &= help "Generated gallery output path (default=./out)"
63 , outputIndex = ""
64 &= typFile
65 &= name "x"
66 &= name "output-index"
67 &= explicit
68 &= help "Generated gallery index output path (default=$output-dir/index.json)"
62 , galleryConfig = "" 69 , galleryConfig = ""
63 &= typFile 70 &= typFile
64 &= name "g" 71 &= name "g"
@@ -110,6 +117,7 @@ main =
110 (galleryConfig opts) 117 (galleryConfig opts)
111 (inputDir opts) 118 (inputDir opts)
112 (galleryOutputDir opts) 119 (galleryOutputDir opts)
120 (outputIndex opts)
113 [outputDir opts] 121 [outputDir opts]
114 (rebuilAll opts) 122 (rebuilAll opts)
115 (cleanOutput opts) 123 (cleanOutput opts)
diff --git a/compiler/ldgallery.1.md b/compiler/ldgallery.1.md
index 5524409..fd0355b 100644
--- a/compiler/ldgallery.1.md
+++ b/compiler/ldgallery.1.md
@@ -33,6 +33,10 @@ Available options are:
33 Must be distinct from the source directory. 33 Must be distinct from the source directory.
34 Defaults to ./out. 34 Defaults to ./out.
35 35
36-x, \--output-index _FILE_
37: Generated gallery index output path.
38 Defaults to $output-dir/index.json.
39
36-g, \--gallery-config _FILE_ 40-g, \--gallery-config _FILE_
37: Gallery configuration file. 41: Gallery configuration file.
38 Defaults to $input-dir/gallery.yaml. 42 Defaults to $input-dir/gallery.yaml.
@@ -45,6 +49,7 @@ Available options are:
45 49
46-w, \--with-viewer 50-w, \--with-viewer
47: Include the static web viewer in the output. 51: Include the static web viewer in the output.
52 The compiled gallery itself is then placed in $output-dir/gallery.
48 53
49-h, \--help 54-h, \--help
50: Display help message. 55: Display help message.
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