From ce0b7ec230703d239b3d77e09352c0b1d515d8f5 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 21 Feb 2020 15:39:01 +0100 Subject: compiler: add gallery config file CLI argument GitHub: closes #136 --- compiler/src/Compiler.hs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'compiler/src') diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index bfefa63..bb0ee97 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs @@ -47,8 +47,8 @@ import Processors , skipCached, withCached ) -galleryConf :: String -galleryConf = "gallery.yaml" +defaultGalleryConf :: String +defaultGalleryConf = "gallery.yaml" indexFile :: String indexFile = "index.json" @@ -74,7 +74,6 @@ galleryDirFilter :: CompilerConfig -> [FilePath] -> FSNode -> Bool galleryDirFilter config excludedCanonicalDirs = (not . isHidden) &&& (not . isExcludedDir) - &&& (not . matchesFile (== galleryConf)) &&& ((matchesDir $ anyPattern $ includedDirectories config) ||| (matchesFile $ anyPattern $ includedFiles config)) &&& (not . ((matchesDir $ anyPattern $ excludedDirectories config) ||| @@ -100,10 +99,10 @@ galleryDirFilter config excludedCanonicalDirs = isExcludedDir File{} = False -compileGallery :: FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO () -compileGallery inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput = +compileGallery :: FilePath -> FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO () +compileGallery configPath inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput = do - fullConfig <- readConfig inputGalleryConf + fullConfig <- readConfig $ inputGalleryConf configPath let config = compiler fullConfig inputDir <- readDirectory inputDirPath @@ -123,7 +122,10 @@ compileGallery inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput = writeJSON outputViewerConf $ viewer fullConfig where - inputGalleryConf = inputDirPath galleryConf + inputGalleryConf :: FilePath -> FilePath + inputGalleryConf "" = inputDirPath defaultGalleryConf + inputGalleryConf file = file + outputIndex = outputDirPath indexFile outputViewerConf = outputDirPath viewerConfFile -- cgit v1.2.3