on master help sign in
Better naming scheme.
7afabf5Jasper Van der Jeugt
examples/categoryblog/hakyll.hs+3−3
@@ -26,7 +26,7 @@ main = hakyll $ do
26 renderPostList "posts.html" "All posts" renderablePosts
26 renderPostList "posts.html" "All posts" renderablePosts
27
27
28 -- Render post list per category
28 -- Render post list per category
29− mapM_ (\(category, posts) -> renderPostList (categoryToURL category) ("Posts about " ++ category) posts)
29+ mapM_ (\(category, posts) -> renderPostList (categoryToUrl category) ("Posts about " ++ category) posts)
30 (toList categoryMap)
30 (toList categoryMap)
31
31
32 -- Render index, including recent posts.
32 -- Render index, including recent posts.
@@ -51,12 +51,12 @@ main = hakyll $ do
51 where postManipulation :: ContextManipulation
51 where postManipulation :: ContextManipulation
52 postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
52 postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
53
53
54− categoryToURL category = "$root/categories/" ++ removeSpaces category ++ ".html"
54+ categoryToUrl category = "$root/categories/" ++ removeSpaces category ++ ".html"
55
55
56 categoryList :: TagMap -> String
56 categoryList :: TagMap -> String
57 categoryList = uncurry categoryListItem <=< toList
57 categoryList = uncurry categoryListItem <=< toList
58
58
59− categoryListItem category posts = "<li>" ++ link category (categoryToURL category)
59+ categoryListItem category posts = "<li>" ++ link category (categoryToUrl category)
60 ++ " - " ++ show (length posts) ++ " items.</li>"
60 ++ " - " ++ show (length posts) ++ " items.</li>"
61
61
62 renderPostList url title posts = do
62 renderPostList url title posts = do
examples/hakyll/tutorial2.markdown+1−1
@@ -80,7 +80,7 @@ Combining two `Renderable`s, but setting a different `url` is quite common, so
80there is another function that helps us here:
80there is another function that helps us here:
81
81
82~~~~~{.haskell}
82~~~~~{.haskell}
83−combineWithURL :: (Renderable a, Renderable b)
83+combineWithUrl :: (Renderable a, Renderable b)
84 => FilePath -> a -> b -> CombinedRenderable a b
84 => FilePath -> a -> b -> CombinedRenderable a b
85~~~~~
85~~~~~
86
86
examples/hakyll/tutorial5.markdown+4−4
@@ -130,7 +130,7 @@ clickable. We can again solve this with a `ContextManipulation`. We have a
130function that produces an url for a given tag:
130function that produces an url for a given tag:
131
131
132~~~~~{.haskell}
132~~~~~{.haskell}
133−tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
133+tagToUrl tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
134~~~~~
134~~~~~
135
135
136`removeSpaces` is an auxiliary function from `Text.Hakyll.File`. Now, there is
136`removeSpaces` is an auxiliary function from `Text.Hakyll.File`. Now, there is
@@ -142,7 +142,7 @@ for a given tag - the function we just wrote. Let's extend our
142~~~~~{.haskell}
142~~~~~{.haskell}
143postManipulation :: ContextManipulation
143postManipulation :: ContextManipulation
144postManipulation = renderDate "date" "%B %e, %Y" "Unknown date"
144postManipulation = renderDate "date" "%B %e, %Y" "Unknown date"
145− . renderTagLinks tagToURL
145+ . renderTagLinks tagToUrl
146~~~~~
146~~~~~
147
147
148So, the `renderTagLinks` function replaces the `$tags` value from
148So, the `renderTagLinks` function replaces the `$tags` value from
@@ -167,7 +167,7 @@ needs this so it can cache the tags.
167~~~~~{.haskell}
167~~~~~{.haskell}
168tagMap <- readTagMap "postTags" postPaths
168tagMap <- readTagMap "postTags" postPaths
169let renderListForTag (tag, posts) =
169let renderListForTag (tag, posts) =
170− renderPostList (tagToURL tag)
170+ renderPostList (tagToUrl tag)
171 ("Posts tagged " ++ tag)
171 ("Posts tagged " ++ tag)
172mapM_ renderListForTag (toList tagMap)
172mapM_ renderListForTag (toList tagMap)
173~~~~~
173~~~~~
@@ -193,7 +193,7 @@ Then, we give a minimum and a maximum font size in percent, and we get the
193tag cloud back. We can add this to our index:
193tag cloud back. We can add this to our index:
194
194
195~~~~~{.haskell}
195~~~~~{.haskell}
196−let tagCloud = renderTagCloud tagMap tagToURL 100 200
196+let tagCloud = renderTagCloud tagMap tagToUrl 100 200
197 index = createListingWith postManipulation "index.html"
197 index = createListingWith postManipulation "index.html"
198 "templates/postitem.html"
198 "templates/postitem.html"
199 (take 3 renderablePosts)
199 (take 3 renderablePosts)
examples/hakyll/tutorial6.markdown+1−1
@@ -65,7 +65,7 @@ a list item for one category:
65
65
66~~~~~{.haskell}
66~~~~~{.haskell}
67categoryListItem category posts =
67categoryListItem category posts =
68− "<li>" ++ link category (categoryToURL category)
68+ "<li>" ++ link category (categoryToUrl category)
69 ++ " - " ++ show (length posts) ++ " items.</li>"
69 ++ " - " ++ show (length posts) ++ " items.</li>"
70~~~~~
70~~~~~
71
71
examples/tagblog/hakyll.hs+4−4
@@ -26,11 +26,11 @@ main = hakyll $ do
26 renderPostList "posts.html" "All posts" renderablePosts
26 renderPostList "posts.html" "All posts" renderablePosts
27
27
28 -- Render post list per tag
28 -- Render post list per tag
29− mapM_ (\(tag, posts) -> renderPostList (tagToURL tag) ("Posts tagged " ++ tag) posts)
29+ mapM_ (\(tag, posts) -> renderPostList (tagToUrl tag) ("Posts tagged " ++ tag) posts)
30 (toList tagMap)
30 (toList tagMap)
31
31
32 -- Render index, including recent posts.
32 -- Render index, including recent posts.
33− let tagCloud = renderTagCloud tagMap tagToURL 100 200
33+ let tagCloud = renderTagCloud tagMap tagToUrl 100 200
34 index = createListingWith postManipulation "index.html"
34 index = createListingWith postManipulation "index.html"
35 "templates/postitem.html"
35 "templates/postitem.html"
36 (take 3 renderablePosts)
36 (take 3 renderablePosts)
@@ -51,9 +51,9 @@ main = hakyll $ do
51
51
52 where postManipulation :: ContextManipulation
52 where postManipulation :: ContextManipulation
53 postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
53 postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
54− . renderTagLinks tagToURL
54+ . renderTagLinks tagToUrl
55
55
56− tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
56+ tagToUrl tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
57
57
58 renderPostList url title posts = do
58 renderPostList url title posts = do
59 let list = createListingWith postManipulation url "templates/postitem.html" posts [("title", title)]
59 let list = createListingWith postManipulation url "templates/postitem.html" posts [("title", title)]
hakyll.cabal+1−1
@@ -49,6 +49,6 @@ library
49 Text.Hakyll.Util
49 Text.Hakyll.Util
50 Text.Hakyll.Tags
50 Text.Hakyll.Tags
51 Text.Hakyll.Internal.Cache
51 Text.Hakyll.Internal.Cache
52− Text.Hakyll.Internal.CompressCSS
52+ Text.Hakyll.Internal.CompressCss
53 Text.Hakyll.Internal.Render
53 Text.Hakyll.Internal.Render
54 Text.Hakyll.Internal.Template
54 Text.Hakyll.Internal.Template
src/Text/Hakyll/File.hs+3−3
@@ -3,7 +3,7 @@
3module Text.Hakyll.File
3module Text.Hakyll.File
4 ( toDestination
4 ( toDestination
5 , toCache
5 , toCache
6− , toURL
6+ , toUrl
7 , toRoot
7 , toRoot
8 , removeSpaces
8 , removeSpaces
9 , makeDirectories
9 , makeDirectories
@@ -46,8 +46,8 @@ toCache path = do dir <- askHakyll cacheDirectory
46 return $ dir </> removeLeadingSeparator path
46 return $ dir </> removeLeadingSeparator path
47
47
48-- | Get the url for a given page.
48-- | Get the url for a given page.
49−toURL :: FilePath -> FilePath
49+toUrl :: FilePath -> FilePath
50−toURL path = if takeExtension path `elem` [ ".markdown"
50+toUrl path = if takeExtension path `elem` [ ".markdown"
51 , ".md"
51 , ".md"
52 , ".mdn"
52 , ".mdn"
53 , ".mdwn"
53 , ".mdwn"
src/Text/Hakyll/Internal/CompressCSS.hs → src/Text/Hakyll/Internal/CompressCss.hsrenamed+4−4
@@ -1,7 +1,7 @@
1-- | Module used for CSS compression. The compression is currently in a simple
1-- | Module used for CSS compression. The compression is currently in a simple
2-- state, but would typically reduce the number of bytes by about 25%.
2-- state, but would typically reduce the number of bytes by about 25%.
3−module Text.Hakyll.Internal.CompressCSS
3+module Text.Hakyll.Internal.CompressCss
4− ( compressCSS
4+ ( compressCss
5 ) where
5 ) where
6
6
7import Data.List (isPrefixOf)
7import Data.List (isPrefixOf)
@@ -9,8 +9,8 @@ import Data.List (isPrefixOf)
9import Text.Hakyll.Regex (substituteRegex)
9import Text.Hakyll.Regex (substituteRegex)
10
10
11-- | Compress CSS to speed up your site.
11-- | Compress CSS to speed up your site.
12−compressCSS :: String -> String
12+compressCss :: String -> String
13−compressCSS = compressSeparators
13+compressCss = compressSeparators
14 . stripComments
14 . stripComments
15 . compressWhitespace
15 . compressWhitespace
16
16
src/Text/Hakyll/Internal/Render.hs+1−1
@@ -65,4 +65,4 @@ writePage page = do
65 liftIO $ writeFile destination $ finalSubstitute (fromString $ getBody page)
65 liftIO $ writeFile destination $ finalSubstitute (fromString $ getBody page)
66 context
66 context
67 where
67 where
68− url = getURL page
68+ url = getUrl page
src/Text/Hakyll/Page.hs+4−4
@@ -43,8 +43,8 @@ getValue str (Page page) = fromMaybe [] $ M.lookup str page
43
43
44-- | Get the URL for a certain page. This should always be defined. If
44-- | Get the URL for a certain page. This should always be defined. If
45-- not, it will error.
45-- not, it will error.
46−getPageURL :: Page -> String
46+getPageUrl :: Page -> String
47−getPageURL (Page page) = fromMaybe (error "No page url") $ M.lookup "url" page
47+getPageUrl (Page page) = fromMaybe (error "No page url") $ M.lookup "url" page
48
48
49-- | Get the original page path.
49-- | Get the original page path.
50getPagePath :: Page -> String
50getPagePath :: Page -> String
@@ -134,7 +134,7 @@ readPageFromFile path = do
134
134
135 return page
135 return page
136 where
136 where
137− url = toURL path
137+ url = toUrl path
138 category = let dirs = splitDirectories $ takeDirectory path
138 category = let dirs = splitDirectories $ takeDirectory path
139 in [("category", last dirs) | not (null dirs)]
139 in [("category", last dirs) | not (null dirs)]
140
140
@@ -153,7 +153,7 @@ readPage path = do
153-- Make pages renderable.
153-- Make pages renderable.
154instance Renderable Page where
154instance Renderable Page where
155 getDependencies = (:[]) . getPagePath
155 getDependencies = (:[]) . getPagePath
156− getURL = getPageURL
156+ getUrl = getPageUrl
157 toContext (Page page) = return page
157 toContext (Page page) = return page
158
158
159-- Make pages serializable.
159-- Make pages serializable.
src/Text/Hakyll/Render.hs+3−3
@@ -22,7 +22,7 @@ import Text.Hakyll.Page
22import Text.Hakyll.Renderable
22import Text.Hakyll.Renderable
23import Text.Hakyll.File
23import Text.Hakyll.File
24import Text.Hakyll.Internal.Template (readTemplate)
24import Text.Hakyll.Internal.Template (readTemplate)
25−import Text.Hakyll.Internal.CompressCSS
25+import Text.Hakyll.Internal.CompressCss
26import Text.Hakyll.Internal.Render
26import Text.Hakyll.Internal.Render
27
27
28-- | Execute an IO action only when the cache is invalid.
28-- | Execute an IO action only when the cache is invalid.
@@ -101,7 +101,7 @@ renderChain = renderChainWith id
101renderChainWith :: Renderable a
101renderChainWith :: Renderable a
102 => ContextManipulation -> [FilePath] -> a -> Hakyll ()
102 => ContextManipulation -> [FilePath] -> a -> Hakyll ()
103renderChainWith manipulation templatePaths renderable =
103renderChainWith manipulation templatePaths renderable =
104− depends (getURL renderable) dependencies render'
104+ depends (getUrl renderable) dependencies render'
105 where
105 where
106 dependencies = getDependencies renderable ++ templatePaths
106 dependencies = getDependencies renderable ++ templatePaths
107 render' = do
107 render' = do
@@ -126,4 +126,4 @@ css source = do destination <- toDestination source
126 where
126 where
127 css' destination = do contents <- liftIO $ readFile source
127 css' destination = do contents <- liftIO $ readFile source
128 makeDirectories destination
128 makeDirectories destination
129− liftIO $ writeFile destination (compressCSS contents)
129+ liftIO $ writeFile destination (compressCss contents)
src/Text/Hakyll/Renderable.hs+2−2
@@ -1,5 +1,5 @@
1module Text.Hakyll.Renderable
1module Text.Hakyll.Renderable
2− ( Renderable(toContext, getDependencies, getURL)
2+ ( Renderable(toContext, getDependencies, getUrl)
3 ) where
3 ) where
4
4
5import Text.Hakyll.Hakyll (Hakyll)
5import Text.Hakyll.Hakyll (Hakyll)
@@ -15,4 +15,4 @@ class Renderable a where
15 getDependencies :: a -> [FilePath]
15 getDependencies :: a -> [FilePath]
16
16
17 -- | Get the destination for the renderable.
17 -- | Get the destination for the renderable.
18− getURL :: a -> FilePath
18+ getUrl :: a -> FilePath
src/Text/Hakyll/Renderables.hs+12−12
@@ -7,7 +7,7 @@ module Text.Hakyll.Renderables
7 , createPagePath
7 , createPagePath
8 , CombinedRenderable
8 , CombinedRenderable
9 , combine
9 , combine
10− , combineWithURL
10+ , combineWithUrl
11 ) where
11 ) where
12
12
13import qualified Data.Map as M
13import qualified Data.Map as M
@@ -25,7 +25,7 @@ import Text.Hakyll.Render
25
25
26-- | A custom page.
26-- | A custom page.
27data CustomPage = CustomPage
27data CustomPage = CustomPage
28− { customPageURL :: String,
28+ { customPageUrl :: String,
29 customPageDependencies :: [FilePath],
29 customPageDependencies :: [FilePath],
30 customPageContext :: [(String, Either String (Hakyll String))]
30 customPageContext :: [(String, Either String (Hakyll String))]
31 }
31 }
@@ -85,11 +85,11 @@ createListingWith manipulation url template renderables additional =
85
85
86instance Renderable CustomPage where
86instance Renderable CustomPage where
87 getDependencies = customPageDependencies
87 getDependencies = customPageDependencies
88− getURL = customPageURL
88+ getUrl = customPageUrl
89 toContext page = do
89 toContext page = do
90 values <- mapM (either return id . snd) (customPageContext page)
90 values <- mapM (either return id . snd) (customPageContext page)
91 let pairs = zip (map fst $ customPageContext page) values
91 let pairs = zip (map fst $ customPageContext page) values
92− return $ M.fromList $ ("url", customPageURL page) : pairs
92+ return $ M.fromList $ ("url", customPageUrl page) : pairs
93
93
94-- | PagePath is a class that wraps a FilePath. This is used to render Pages
94-- | PagePath is a class that wraps a FilePath. This is used to render Pages
95-- without reading them first through use of caching.
95-- without reading them first through use of caching.
@@ -102,7 +102,7 @@ createPagePath = PagePath
102-- We can render filepaths
102-- We can render filepaths
103instance Renderable PagePath where
103instance Renderable PagePath where
104 getDependencies (PagePath path) = return path
104 getDependencies (PagePath path) = return path
105− getURL (PagePath path) = toURL path
105+ getUrl (PagePath path) = toUrl path
106 toContext (PagePath path) = readPage path >>= toContext
106 toContext (PagePath path) = readPage path >>= toContext
107
107
108-- We can serialize filepaths
108-- We can serialize filepaths
@@ -112,7 +112,7 @@ instance Binary PagePath where
112
112
113-- | A combination of two other renderables.
113-- | A combination of two other renderables.
114data CombinedRenderable a b = CombinedRenderable a b
114data CombinedRenderable a b = CombinedRenderable a b
115− | CombinedRenderableWithURL FilePath a b
115+ | CombinedRenderableWithUrl FilePath a b
116
116
117-- | Combine two renderables. The url will always be taken from the first
117-- | Combine two renderables. The url will always be taken from the first
118-- @Renderable@. Also, if a `$key` is present in both renderables, the
118-- @Renderable@. Also, if a `$key` is present in both renderables, the
@@ -125,12 +125,12 @@ combine = CombinedRenderable
125
125
126-- | Combine two renderables and set a custom URL. This behaves like @combine@,
126-- | Combine two renderables and set a custom URL. This behaves like @combine@,
127-- except that for the @url@ field, the given URL is always chosen.
127-- except that for the @url@ field, the given URL is always chosen.
128−combineWithURL :: (Renderable a, Renderable b)
128+combineWithUrl :: (Renderable a, Renderable b)
129 => FilePath
129 => FilePath
130 -> a
130 -> a
131 -> b
131 -> b
132 -> CombinedRenderable a b
132 -> CombinedRenderable a b
133−combineWithURL = CombinedRenderableWithURL
133+combineWithUrl = CombinedRenderableWithUrl
134
134
135-- Render combinations.
135-- Render combinations.
136instance (Renderable a, Renderable b)
136instance (Renderable a, Renderable b)
@@ -139,18 +139,18 @@ instance (Renderable a, Renderable b)
139 -- Add the dependencies.
139 -- Add the dependencies.
140 getDependencies (CombinedRenderable a b) =
140 getDependencies (CombinedRenderable a b) =
141 getDependencies a ++ getDependencies b
141 getDependencies a ++ getDependencies b
142− getDependencies (CombinedRenderableWithURL _ a b) =
142+ getDependencies (CombinedRenderableWithUrl _ a b) =
143 getDependencies a ++ getDependencies b
143 getDependencies a ++ getDependencies b
144
144
145 -- Take the url from the first renderable, or the specified URL.
145 -- Take the url from the first renderable, or the specified URL.
146− getURL (CombinedRenderable a _) = getURL a
146+ getUrl (CombinedRenderable a _) = getUrl a
147− getURL (CombinedRenderableWithURL url _ _) = url
147+ getUrl (CombinedRenderableWithUrl url _ _) = url
148
148
149 -- Take a union of the contexts.
149 -- Take a union of the contexts.
150 toContext (CombinedRenderable a b) = do
150 toContext (CombinedRenderable a b) = do
151 c1 <- toContext a
151 c1 <- toContext a
152 c2 <- toContext b
152 c2 <- toContext b
153 return $ c1 `M.union` c2
153 return $ c1 `M.union` c2
154− toContext (CombinedRenderableWithURL url a b) = do
154+ toContext (CombinedRenderableWithUrl url a b) = do
155 c <- toContext (CombinedRenderable a b)
155 c <- toContext (CombinedRenderable a b)
156 return $ M.singleton "url" url `M.union` c
156 return $ M.singleton "url" url `M.union` c
src/Text/Hakyll/Util.hs+5−5
@@ -1,7 +1,7 @@
1-- | Miscellaneous text manipulation functions.
1-- | Miscellaneous text manipulation functions.
2module Text.Hakyll.Util
2module Text.Hakyll.Util
3 ( trim
3 ( trim
4− , stripHTML
4+ , stripHtml
5 , link
5 , link
6 ) where
6 ) where
7
7
@@ -14,11 +14,11 @@ trim = reverse . trim' . reverse . trim'
14 trim' = dropWhile isSpace
14 trim' = dropWhile isSpace
15
15
16-- | Strip html tags from the given string.
16-- | Strip html tags from the given string.
17−stripHTML :: String -> String
17+stripHtml :: String -> String
18−stripHTML [] = []
18+stripHtml [] = []
19−stripHTML str = let (beforeTag, rest) = break (== '<') str
19+stripHtml str = let (beforeTag, rest) = break (== '<') str
20 (_, afterTag) = break (== '>') rest
20 (_, afterTag) = break (== '>') rest
21− in beforeTag ++ stripHTML (tail' afterTag)
21+ in beforeTag ++ stripHtml (tail' afterTag)
22 where
22 where
23 -- We need a failsafe tail function.
23 -- We need a failsafe tail function.
24 tail' [] = []
24 tail' [] = []