aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorpacien2020-02-03 14:27:33 +0100
committerNotkea2020-02-03 14:35:29 +0100
commitc7c872291c2b053afc2c27f999f33b2cfb6c23f1 (patch)
tree399c43e2adc312553f49fab9f8d84fb841624610 /compiler
parent8dd664c23ba971362eb0c84438d40a55637dcc67 (diff)
downloadldgallery-c7c872291c2b053afc2c27f999f33b2cfb6c23f1.tar.gz
compiler: fix viewer output directory exclusion
GitHub: closes #87
Diffstat (limited to 'compiler')
-rw-r--r--compiler/app/Main.hs1
-rw-r--r--compiler/src/Compiler.hs20
2 files changed, 11 insertions, 10 deletions
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index e26055f..1864dee 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -103,6 +103,7 @@ main =
103 compileGallery 103 compileGallery
104 (inputDir opts) 104 (inputDir opts)
105 (galleryOutputDir opts) 105 (galleryOutputDir opts)
106 [outputDir opts]
106 (rebuilAll opts) 107 (rebuilAll opts)
107 (cleanOutput opts) 108 (cleanOutput opts)
108 109
diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs
index d392f74..adc4a5f 100644
--- a/compiler/src/Compiler.hs
+++ b/compiler/src/Compiler.hs
@@ -70,10 +70,10 @@ writeJSON outputPath object =
70 ensureParentDir JSON.encodeFile outputPath object 70 ensureParentDir JSON.encodeFile outputPath object
71 71
72 72
73galleryDirFilter :: CompilerConfig -> FilePath -> FSNode -> Bool 73galleryDirFilter :: CompilerConfig -> [FilePath] -> FSNode -> Bool
74galleryDirFilter config outputDir = 74galleryDirFilter config excludedCanonicalDirs =
75 (not . isHidden) 75 (not . isHidden)
76 &&& (not . isOutputGallery) 76 &&& (not . isExcludedDir)
77 &&& (not . matchesFile (== galleryConf)) 77 &&& (not . matchesFile (== galleryConf))
78 &&& ((matchesDir $ anyPattern $ includedDirectories config) ||| 78 &&& ((matchesDir $ anyPattern $ includedDirectories config) |||
79 (matchesFile $ anyPattern $ includedFiles config)) 79 (matchesFile $ anyPattern $ includedFiles config))
@@ -95,20 +95,20 @@ galleryDirFilter config outputDir =
95 anyPattern :: [String] -> FileName -> Bool 95 anyPattern :: [String] -> FileName -> Bool
96 anyPattern patterns filename = any (flip Glob.match filename) (map Glob.compile patterns) 96 anyPattern patterns filename = any (flip Glob.match filename) (map Glob.compile patterns)
97 97
98 isOutputGallery :: FSNode -> Bool 98 isExcludedDir :: FSNode -> Bool
99 isOutputGallery Dir{canonicalPath} = canonicalPath == outputDir 99 isExcludedDir Dir{canonicalPath} = any (canonicalPath ==) excludedCanonicalDirs
100 isOutputGallery File{} = False 100 isExcludedDir File{} = False
101 101
102 102
103compileGallery :: FilePath -> FilePath -> Bool -> Bool -> IO () 103compileGallery :: FilePath -> FilePath -> [FilePath] -> Bool -> Bool -> IO ()
104compileGallery inputDirPath outputDirPath rebuildAll cleanOutput = 104compileGallery inputDirPath outputDirPath excludedDirs rebuildAll cleanOutput =
105 do 105 do
106 fullConfig <- readConfig inputGalleryConf 106 fullConfig <- readConfig inputGalleryConf
107 let config = compiler fullConfig 107 let config = compiler fullConfig
108 108
109 inputDir <- readDirectory inputDirPath 109 inputDir <- readDirectory inputDirPath
110 canonicalOutPath <- canonicalizePath outputDirPath 110 excludedCanonicalDirs <- mapM canonicalizePath excludedDirs
111 let sourceFilter = galleryDirFilter config canonicalOutPath 111 let sourceFilter = galleryDirFilter config excludedCanonicalDirs
112 let sourceTree = filterDir sourceFilter inputDir 112 let sourceTree = filterDir sourceFilter inputDir
113 inputTree <- readInputTree sourceTree 113 inputTree <- readInputTree sourceTree
114 114