diff options
Diffstat (limited to 'compiler/src/Compiler.hs')
-rw-r--r-- | compiler/src/Compiler.hs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs index 4f2093b..5d30a26 100644 --- a/compiler/src/Compiler.hs +++ b/compiler/src/Compiler.hs | |||
@@ -1,7 +1,7 @@ | |||
1 | -- ldgallery - A static generator which turns a collection of tagged | 1 | -- ldgallery - A static generator which turns a collection of tagged |
2 | -- pictures into a searchable web gallery. | 2 | -- pictures into a searchable web gallery. |
3 | -- | 3 | -- |
4 | -- Copyright (C) 2019 Pacien TRAN-GIRARD | 4 | -- Copyright (C) 2019-2020 Pacien TRAN-GIRARD |
5 | -- | 5 | -- |
6 | -- This program is free software: you can redistribute it and/or modify | 6 | -- This program is free software: you can redistribute it and/or modify |
7 | -- it under the terms of the GNU Affero General Public License as | 7 | -- it under the terms of the GNU Affero General Public License as |
@@ -20,6 +20,7 @@ | |||
20 | DuplicateRecordFields | 20 | DuplicateRecordFields |
21 | , DeriveGeneric | 21 | , DeriveGeneric |
22 | , DeriveAnyClass | 22 | , DeriveAnyClass |
23 | , NamedFieldPuns | ||
23 | #-} | 24 | #-} |
24 | 25 | ||
25 | module Compiler | 26 | module Compiler |
@@ -30,7 +31,7 @@ module Compiler | |||
30 | import Control.Monad (liftM2) | 31 | import Control.Monad (liftM2) |
31 | import Data.Function ((&)) | 32 | import Data.Function ((&)) |
32 | import Data.List (any) | 33 | import Data.List (any) |
33 | import Data.Maybe (isJust) | 34 | import Data.Maybe (isJust, fromMaybe) |
34 | import Text.Regex (Regex, mkRegex, matchRegex) | 35 | import Text.Regex (Regex, mkRegex, matchRegex) |
35 | import System.FilePath ((</>)) | 36 | import System.FilePath ((</>)) |
36 | 37 | ||
@@ -80,15 +81,15 @@ galleryDirFilter excludeRegex = | |||
80 | (&&&) = liftM2 (&&) | 81 | (&&&) = liftM2 (&&) |
81 | (|||) = liftM2 (||) | 82 | (|||) = liftM2 (||) |
82 | 83 | ||
83 | isConfigFile = (galleryConf ==) . nodeName | 84 | matchName :: (FileName -> Bool) -> FSNode -> Bool |
85 | matchName cond = maybe False cond . nodeName | ||
84 | 86 | ||
85 | isGalleryIndex = (indexFile ==) | 87 | isConfigFile = matchName (== galleryConf) |
86 | isViewerIndex = (viewerMainFile ==) | 88 | isGalleryIndex = matchName (== indexFile) |
87 | containsOutputGallery (File _) = False | 89 | isViewerIndex = matchName (== viewerMainFile) |
88 | containsOutputGallery (Dir _ items) = | 90 | containsOutputGallery File{} = False |
89 | any ((isGalleryIndex ||| isViewerIndex) . nodeName) items | 91 | containsOutputGallery Dir{items} = any (isGalleryIndex ||| isViewerIndex) items |
90 | 92 | excludedName = isJust . matchRegex excludeRegex . fromMaybe "" . nodeName | |
91 | excludedName = isJust . matchRegex excludeRegex . nodeName | ||
92 | 93 | ||
93 | 94 | ||
94 | compileGallery :: FilePath -> FilePath -> Bool -> IO () | 95 | compileGallery :: FilePath -> FilePath -> Bool -> IO () |