aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Compiler.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/Compiler.hs')
-rw-r--r--compiler/src/Compiler.hs21
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
25module Compiler 26module Compiler
@@ -30,7 +31,7 @@ module Compiler
30import Control.Monad (liftM2) 31import Control.Monad (liftM2)
31import Data.Function ((&)) 32import Data.Function ((&))
32import Data.List (any) 33import Data.List (any)
33import Data.Maybe (isJust) 34import Data.Maybe (isJust, fromMaybe)
34import Text.Regex (Regex, mkRegex, matchRegex) 35import Text.Regex (Regex, mkRegex, matchRegex)
35import System.FilePath ((</>)) 36import 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
94compileGallery :: FilePath -> FilePath -> Bool -> IO () 95compileGallery :: FilePath -> FilePath -> Bool -> IO ()