on master help sign in
Small fixes
bc192a1Jasper Van der Jeugt
hakyll.cabal+1−1
@@ -120,7 +120,7 @@ Library
120 Hakyll.Web.Pandoc
120 Hakyll.Web.Pandoc
121 Hakyll.Web.Pandoc.Biblio
121 Hakyll.Web.Pandoc.Biblio
122 Hakyll.Web.Pandoc.FileType
122 Hakyll.Web.Pandoc.FileType
123− -- Hakyll.Web.Tags
123+ Hakyll.Web.Tags
124 Hakyll.Web.Template
124 Hakyll.Web.Template
125 Hakyll.Web.Template.Context
125 Hakyll.Web.Template.Context
126 Hakyll.Web.Template.List
126 Hakyll.Web.Template.List
src/Hakyll/Core/Identifier/Pattern.hs+5−3
@@ -68,6 +68,8 @@ import Data.Binary (Binary (..), getWord8, putWord8)
68import Data.List (inits, isPrefixOf, tails)
68import Data.List (inits, isPrefixOf, tails)
69import Data.Maybe (isJust)
69import Data.Maybe (isJust)
70import Data.Monoid (Monoid, mappend, mempty)
70import Data.Monoid (Monoid, mappend, mempty)
71+import Data.Set (Set)
72+import qualified Data.Set as S
71
73
72
74
73--------------------------------------------------------------------------------
75--------------------------------------------------------------------------------
@@ -108,7 +110,7 @@ data Pattern
108 | Complement Pattern
110 | Complement Pattern
109 | And Pattern Pattern
111 | And Pattern Pattern
110 | Glob [GlobComponent]
112 | Glob [GlobComponent]
111− | List [Identifier] -- TODO Maybe use a set here
113+ | List (Set Identifier)
112 | Regex String
114 | Regex String
113 | Version (Maybe String)
115 | Version (Maybe String)
114 deriving (Show)
116 deriving (Show)
@@ -162,7 +164,7 @@ fromGlob = Glob . parse'
162--------------------------------------------------------------------------------
164--------------------------------------------------------------------------------
163-- | Create a 'Pattern' from a list of 'Identifier's it should match
165-- | Create a 'Pattern' from a list of 'Identifier's it should match
164fromList :: [Identifier] -> Pattern
166fromList :: [Identifier] -> Pattern
165−fromList = List
167+fromList = List . S.fromList
166
168
167
169
168--------------------------------------------------------------------------------
170--------------------------------------------------------------------------------
@@ -205,7 +207,7 @@ matches Everything _ = True
205matches (Complement p) i = not $ matches p i
207matches (Complement p) i = not $ matches p i
206matches (And x y) i = matches x i && matches y i
208matches (And x y) i = matches x i && matches y i
207matches (Glob p) i = isJust $ capture (Glob p) i
209matches (Glob p) i = isJust $ capture (Glob p) i
208−matches (List l) i = i `elem` l
210+matches (List l) i = i `S.member` l
209matches (Regex r) i = toFilePath i =~ r
211matches (Regex r) i = toFilePath i =~ r
210matches (Version v) i = identifierVersion i == v
212matches (Version v) i = identifierVersion i == v
211
213
src/Hakyll/Web/Tags.hs+7−7
@@ -66,6 +66,7 @@ import qualified Text.Blaze.Html5.Attributes as A
66--------------------------------------------------------------------------------
66--------------------------------------------------------------------------------
67import Hakyll.Core.Compiler
67import Hakyll.Core.Compiler
68import Hakyll.Core.Identifier
68import Hakyll.Core.Identifier
69+import Hakyll.Core.Identifier.Pattern
69import Hakyll.Core.Item
70import Hakyll.Core.Item
70import Hakyll.Core.Metadata
71import Hakyll.Core.Metadata
71import Hakyll.Core.Util.String
72import Hakyll.Core.Util.String
@@ -102,10 +103,11 @@ getCategory = return . return . takeBaseName . takeDirectory . toFilePath
102
103
103
104
104--------------------------------------------------------------------------------
105--------------------------------------------------------------------------------
105−-- | Higher-level function to read tags
106+-- | Higher-order function to read tags
106buildTagsWith :: MonadMetadata m
107buildTagsWith :: MonadMetadata m
107− => (Identifier -> m [String]) -> [Identifier] -> m Tags
108+ => (Identifier -> m [String]) -> Pattern -> m Tags
108−buildTagsWith f ids = do
109+buildTagsWith f pattern = do
110+ ids <- getMatches pattern
109 tagMap <- foldM addTags M.empty ids
111 tagMap <- foldM addTags M.empty ids
110 return $ Tags $ M.toList tagMap
112 return $ Tags $ M.toList tagMap
111 where
113 where
@@ -117,15 +119,13 @@ buildTagsWith f ids = do
117
119
118--------------------------------------------------------------------------------
120--------------------------------------------------------------------------------
119-- | Read a tagmap using the @tags@ metadata field
121-- | Read a tagmap using the @tags@ metadata field
120−-- TODO: Should use pattern
121−buildTags :: MonadMetadata m => [Identifier] -> m Tags
122+buildTags :: MonadMetadata m => Pattern -> m Tags
122buildTags = buildTagsWith getTags
123buildTags = buildTagsWith getTags
123
124
124
125
125--------------------------------------------------------------------------------
126--------------------------------------------------------------------------------
126-- | Read a tagmap using the @category@ metadata field
127-- | Read a tagmap using the @category@ metadata field
127−-- TODO: Should use pattern
128−buildCategory :: MonadMetadata m => [Identifier] -> m Tags
128+buildCategory :: MonadMetadata m => Pattern -> m Tags
129buildCategory = buildTagsWith getCategory
129buildCategory = buildTagsWith getCategory
130
130
131
131
src/Hakyll/Web/Template/Context.hs+1−2
@@ -28,8 +28,7 @@ import qualified Data.Map as M
28import Data.Monoid (Monoid (..))
28import Data.Monoid (Monoid (..))
29import Data.Time.Clock (UTCTime (..))
29import Data.Time.Clock (UTCTime (..))
30import Data.Time.Format (formatTime, parseTime)
30import Data.Time.Format (formatTime, parseTime)
31−import System.FilePath (takeBaseName, takeDirectory,
31+import System.FilePath (takeBaseName, takeFileName)
32− takeFileName)
33import System.Locale (TimeLocale, defaultTimeLocale)
32import System.Locale (TimeLocale, defaultTimeLocale)
34
33
35
34