on master help sign in
Better naming scheme.
commit7afabf5c098efc2f0df482ab66d9091d7aa3bd23 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 31 Jan 2010, 11:19 (17 years ago) parent73d6b1d
14 files changed+48−48
examples/categoryblog/hakyll.hs+3−3 examples/hakyll/tutorial2.markdown+1−1 examples/hakyll/tutorial5.markdown+4−4 examples/hakyll/tutorial6.markdown+1−1 examples/tagblog/hakyll.hs+4−4 hakyll.cabal+1−1 src/Text/Hakyll/File.hs+3−3 src/Text/Hakyll/Internal/CompressCSS.hs → src/Text/Hakyll/Internal/CompressCss.hs+4−4 src/Text/Hakyll/Internal/Render.hs+1−1 src/Text/Hakyll/Page.hs+4−4 src/Text/Hakyll/Render.hs+3−3 src/Text/Hakyll/Renderable.hs+2−2 src/Text/Hakyll/Renderables.hs+12−12 src/Text/Hakyll/Util.hs+5−5
examples/categoryblog/hakyll.hs+3−3
@@ -26,7 +26,7 @@ main = hakyll $ do
2626 renderPostList "posts.html" "All posts" renderablePosts
2727
2828 -- 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)
3030 (toList categoryMap)
3131
3232 -- Render index, including recent posts.
@@ -51,12 +51,12 @@ main = hakyll $ do
5151 where postManipulation :: ContextManipulation
5252 postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
5353
54− categoryToURL category = "$root/categories/" ++ removeSpaces category ++ ".html"
54+ categoryToUrl category = "$root/categories/" ++ removeSpaces category ++ ".html"
5555
5656 categoryList :: TagMap -> String
5757 categoryList = uncurry categoryListItem <=< toList
5858
59− categoryListItem category posts = "<li>" ++ link category (categoryToURL category)
59+ categoryListItem category posts = "<li>" ++ link category (categoryToUrl category)
6060 ++ " - " ++ show (length posts) ++ " items.</li>"
6161
6262 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
8080there is another function that helps us here:
8181
8282~~~~~{.haskell}
83−combineWithURL :: (Renderable a, Renderable b)
83+combineWithUrl :: (Renderable a, Renderable b)
8484 => FilePath -> a -> b -> CombinedRenderable a b
8585~~~~~
8686
examples/hakyll/tutorial5.markdown+4−4
@@ -130,7 +130,7 @@ clickable. We can again solve this with a `ContextManipulation`. We have a
130130function that produces an url for a given tag:
131131
132132~~~~~{.haskell}
133−tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
133+tagToUrl tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
134134~~~~~
135135
136136`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
142142~~~~~{.haskell}
143143postManipulation :: ContextManipulation
144144postManipulation = renderDate "date" "%B %e, %Y" "Unknown date"
145− . renderTagLinks tagToURL
145+ . renderTagLinks tagToUrl
146146~~~~~
147147
148148So, the `renderTagLinks` function replaces the `$tags` value from
@@ -167,7 +167,7 @@ needs this so it can cache the tags.
167167~~~~~{.haskell}
168168tagMap <- readTagMap "postTags" postPaths
169169let renderListForTag (tag, posts) =
170− renderPostList (tagToURL tag)
170+ renderPostList (tagToUrl tag)
171171 ("Posts tagged " ++ tag)
172172mapM_ renderListForTag (toList tagMap)
173173~~~~~
@@ -193,7 +193,7 @@ Then, we give a minimum and a maximum font size in percent, and we get the
193193tag cloud back. We can add this to our index:
194194
195195~~~~~{.haskell}
196−let tagCloud = renderTagCloud tagMap tagToURL 100 200
196+let tagCloud = renderTagCloud tagMap tagToUrl 100 200
197197 index = createListingWith postManipulation "index.html"
198198 "templates/postitem.html"
199199 (take 3 renderablePosts)
examples/hakyll/tutorial6.markdown+1−1
@@ -65,7 +65,7 @@ a list item for one category:
6565
6666~~~~~{.haskell}
6767categoryListItem category posts =
68− "<li>" ++ link category (categoryToURL category)
68+ "<li>" ++ link category (categoryToUrl category)
6969 ++ " - " ++ show (length posts) ++ " items.</li>"
7070~~~~~
7171
examples/tagblog/hakyll.hs+4−4
@@ -26,11 +26,11 @@ main = hakyll $ do
2626 renderPostList "posts.html" "All posts" renderablePosts
2727
2828 -- 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)
3030 (toList tagMap)
3131
3232 -- Render index, including recent posts.
33− let tagCloud = renderTagCloud tagMap tagToURL 100 200
33+ let tagCloud = renderTagCloud tagMap tagToUrl 100 200
3434 index = createListingWith postManipulation "index.html"
3535 "templates/postitem.html"
3636 (take 3 renderablePosts)
@@ -51,9 +51,9 @@ main = hakyll $ do
5151
5252 where postManipulation :: ContextManipulation
5353 postManipulation = renderDate "date" "%B %e, %Y" "Date unknown"
54− . renderTagLinks tagToURL
54+ . renderTagLinks tagToUrl
5555
56− tagToURL tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
56+ tagToUrl tag = "$root/tags/" ++ removeSpaces tag ++ ".html"
5757
5858 renderPostList url title posts = do
5959 let list = createListingWith postManipulation url "templates/postitem.html" posts [("title", title)]
hakyll.cabal+1−1
@@ -49,6 +49,6 @@ library
4949 Text.Hakyll.Util
5050 Text.Hakyll.Tags
5151 Text.Hakyll.Internal.Cache
52− Text.Hakyll.Internal.CompressCSS
52+ Text.Hakyll.Internal.CompressCss
5353 Text.Hakyll.Internal.Render
5454 Text.Hakyll.Internal.Template
src/Text/Hakyll/File.hs+3−3
@@ -3,7 +3,7 @@
33module Text.Hakyll.File
44 ( toDestination
55 , toCache
6− , toURL
6+ , toUrl
77 , toRoot
88 , removeSpaces
99 , makeDirectories
@@ -46,8 +46,8 @@ toCache path = do dir <- askHakyll cacheDirectory
4646 return $ dir </> removeLeadingSeparator path
4747
4848-- | Get the url for a given page.
49−toURL :: FilePath -> FilePath
50−toURL path = if takeExtension path `elem` [ ".markdown"
49+toUrl :: FilePath -> FilePath
50+toUrl path = if takeExtension path `elem` [ ".markdown"
5151 , ".md"
5252 , ".mdn"
5353 , ".mdwn"
src/Text/Hakyll/Internal/CompressCSS.hs → src/Text/Hakyll/Internal/CompressCss.hsrenamed+4−4
@@ -1,7 +1,7 @@
11-- | Module used for CSS compression. The compression is currently in a simple
22-- state, but would typically reduce the number of bytes by about 25%.
3−module Text.Hakyll.Internal.CompressCSS
4− ( compressCSS
3+module Text.Hakyll.Internal.CompressCss
4+ ( compressCss
55 ) where
66
77import Data.List (isPrefixOf)
@@ -9,8 +9,8 @@ import Data.List (isPrefixOf)
99import Text.Hakyll.Regex (substituteRegex)
1010
1111-- | Compress CSS to speed up your site.
12−compressCSS :: String -> String
13−compressCSS = compressSeparators
12+compressCss :: String -> String
13+compressCss = compressSeparators
1414 . stripComments
1515 . compressWhitespace
1616
src/Text/Hakyll/Internal/Render.hs+1−1
@@ -65,4 +65,4 @@ writePage page = do
6565 liftIO $ writeFile destination $ finalSubstitute (fromString $ getBody page)
6666 context
6767 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
4343
4444-- | Get the URL for a certain page. This should always be defined. If
4545-- not, it will error.
46−getPageURL :: Page -> String
47−getPageURL (Page page) = fromMaybe (error "No page url") $ M.lookup "url" page
46+getPageUrl :: Page -> String
47+getPageUrl (Page page) = fromMaybe (error "No page url") $ M.lookup "url" page
4848
4949-- | Get the original page path.
5050getPagePath :: Page -> String
@@ -134,7 +134,7 @@ readPageFromFile path = do
134134
135135 return page
136136 where
137− url = toURL path
137+ url = toUrl path
138138 category = let dirs = splitDirectories $ takeDirectory path
139139 in [("category", last dirs) | not (null dirs)]
140140
@@ -153,7 +153,7 @@ readPage path = do
153153-- Make pages renderable.
154154instance Renderable Page where
155155 getDependencies = (:[]) . getPagePath
156− getURL = getPageURL
156+ getUrl = getPageUrl
157157 toContext (Page page) = return page
158158
159159-- Make pages serializable.
src/Text/Hakyll/Render.hs+3−3
@@ -22,7 +22,7 @@ import Text.Hakyll.Page
2222import Text.Hakyll.Renderable
2323import Text.Hakyll.File
2424import Text.Hakyll.Internal.Template (readTemplate)
25−import Text.Hakyll.Internal.CompressCSS
25+import Text.Hakyll.Internal.CompressCss
2626import Text.Hakyll.Internal.Render
2727
2828-- | Execute an IO action only when the cache is invalid.
@@ -101,7 +101,7 @@ renderChain = renderChainWith id
101101renderChainWith :: Renderable a
102102 => ContextManipulation -> [FilePath] -> a -> Hakyll ()
103103renderChainWith manipulation templatePaths renderable =
104− depends (getURL renderable) dependencies render'
104+ depends (getUrl renderable) dependencies render'
105105 where
106106 dependencies = getDependencies renderable ++ templatePaths
107107 render' = do
@@ -126,4 +126,4 @@ css source = do destination <- toDestination source
126126 where
127127 css' destination = do contents <- liftIO $ readFile source
128128 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 @@
11module Text.Hakyll.Renderable
2− ( Renderable(toContext, getDependencies, getURL)
2+ ( Renderable(toContext, getDependencies, getUrl)
33 ) where
44
55import Text.Hakyll.Hakyll (Hakyll)
@@ -15,4 +15,4 @@ class Renderable a where
1515 getDependencies :: a -> [FilePath]
1616
1717 -- | 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
77 , createPagePath
88 , CombinedRenderable
99 , combine
10− , combineWithURL
10+ , combineWithUrl
1111 ) where
1212
1313import qualified Data.Map as M
@@ -25,7 +25,7 @@ import Text.Hakyll.Render
2525
2626-- | A custom page.
2727data CustomPage = CustomPage
28− { customPageURL :: String,
28+ { customPageUrl :: String,
2929 customPageDependencies :: [FilePath],
3030 customPageContext :: [(String, Either String (Hakyll String))]
3131 }
@@ -85,11 +85,11 @@ createListingWith manipulation url template renderables additional =
8585
8686instance Renderable CustomPage where
8787 getDependencies = customPageDependencies
88− getURL = customPageURL
88+ getUrl = customPageUrl
8989 toContext page = do
9090 values <- mapM (either return id . snd) (customPageContext page)
9191 let pairs = zip (map fst $ customPageContext page) values
92− return $ M.fromList $ ("url", customPageURL page) : pairs
92+ return $ M.fromList $ ("url", customPageUrl page) : pairs
9393
9494-- | PagePath is a class that wraps a FilePath. This is used to render Pages
9595-- without reading them first through use of caching.
@@ -102,7 +102,7 @@ createPagePath = PagePath
102102-- We can render filepaths
103103instance Renderable PagePath where
104104 getDependencies (PagePath path) = return path
105− getURL (PagePath path) = toURL path
105+ getUrl (PagePath path) = toUrl path
106106 toContext (PagePath path) = readPage path >>= toContext
107107
108108-- We can serialize filepaths
@@ -112,7 +112,7 @@ instance Binary PagePath where
112112
113113-- | A combination of two other renderables.
114114data CombinedRenderable a b = CombinedRenderable a b
115− | CombinedRenderableWithURL FilePath a b
115+ | CombinedRenderableWithUrl FilePath a b
116116
117117-- | Combine two renderables. The url will always be taken from the first
118118-- @Renderable@. Also, if a `$key` is present in both renderables, the
@@ -125,12 +125,12 @@ combine = CombinedRenderable
125125
126126-- | Combine two renderables and set a custom URL. This behaves like @combine@,
127127-- except that for the @url@ field, the given URL is always chosen.
128−combineWithURL :: (Renderable a, Renderable b)
128+combineWithUrl :: (Renderable a, Renderable b)
129129 => FilePath
130130 -> a
131131 -> b
132132 -> CombinedRenderable a b
133−combineWithURL = CombinedRenderableWithURL
133+combineWithUrl = CombinedRenderableWithUrl
134134
135135-- Render combinations.
136136instance (Renderable a, Renderable b)
@@ -139,18 +139,18 @@ instance (Renderable a, Renderable b)
139139 -- Add the dependencies.
140140 getDependencies (CombinedRenderable a b) =
141141 getDependencies a ++ getDependencies b
142− getDependencies (CombinedRenderableWithURL _ a b) =
142+ getDependencies (CombinedRenderableWithUrl _ a b) =
143143 getDependencies a ++ getDependencies b
144144
145145 -- Take the url from the first renderable, or the specified URL.
146− getURL (CombinedRenderable a _) = getURL a
147− getURL (CombinedRenderableWithURL url _ _) = url
146+ getUrl (CombinedRenderable a _) = getUrl a
147+ getUrl (CombinedRenderableWithUrl url _ _) = url
148148
149149 -- Take a union of the contexts.
150150 toContext (CombinedRenderable a b) = do
151151 c1 <- toContext a
152152 c2 <- toContext b
153153 return $ c1 `M.union` c2
154− toContext (CombinedRenderableWithURL url a b) = do
154+ toContext (CombinedRenderableWithUrl url a b) = do
155155 c <- toContext (CombinedRenderable a b)
156156 return $ M.singleton "url" url `M.union` c
src/Text/Hakyll/Util.hs+5−5
@@ -1,7 +1,7 @@
11-- | Miscellaneous text manipulation functions.
22module Text.Hakyll.Util
33 ( trim
4− , stripHTML
4+ , stripHtml
55 , link
66 ) where
77
@@ -14,11 +14,11 @@ trim = reverse . trim' . reverse . trim'
1414 trim' = dropWhile isSpace
1515
1616-- | Strip html tags from the given string.
17−stripHTML :: String -> String
18−stripHTML [] = []
19−stripHTML str = let (beforeTag, rest) = break (== '<') str
17+stripHtml :: String -> String
18+stripHtml [] = []
19+stripHtml str = let (beforeTag, rest) = break (== '<') str
2020 (_, afterTag) = break (== '>') rest
21− in beforeTag ++ stripHTML (tail' afterTag)
21+ in beforeTag ++ stripHtml (tail' afterTag)
2222 where
2323 -- We need a failsafe tail function.
2424 tail' [] = []