@@ -27,6 +27,7 @@
27-- @readTagMap@ or @readCategoryMap@ function, you also have to give a unique
27-- @readTagMap@ or @readCategoryMap@ function, you also have to give a unique
28-- identifier to it. This identifier is simply for caching reasons, so Hakyll
28-- identifier to it. This identifier is simply for caching reasons, so Hakyll
29-- can tell different maps apart; it has no other use.
29-- can tell different maps apart; it has no other use.
30module Text.Hakyll.Tags
31module Text.Hakyll.Tags
32 , readTagMap
33 , readTagMap
@@ -40,9 +41,15 @@ import qualified Data.Map as M
40import Data.List (intercalate)
41import Data.List (intercalate)
41import Data.Maybe (fromMaybe, maybeToList)
42import Data.Maybe (fromMaybe, maybeToList)
42import Control.Arrow (second, (>>>))
43import Control.Arrow (second, (>>>))
44+import Data.Monoid (mappend)
43import Control.Applicative ((<$>))
45import Control.Applicative ((<$>))
44import System.FilePath
46import System.FilePath
48+import Text.Blaze.Renderer.String (renderHtml)
49+import Text.Blaze.Html5 ((!), string, stringValue)
50+import qualified Text.Blaze.Html5 as H
51+import qualified Text.Blaze.Html5.Attributes as A
46import Text.Hakyll.Context (Context (..))
53import Text.Hakyll.Context (Context (..))
47import Text.Hakyll.ContextManipulations (changeValue)
54import Text.Hakyll.ContextManipulations (changeValue)
48import Text.Hakyll.CreateContext (createPage)
55import Text.Hakyll.CreateContext (createPage)
@@ -130,16 +137,11 @@ renderTagCloud urlFunction minSize maxSize = createHakyllAction renderTagCloud'
130 renderTagCloud' tagMap =
137 renderTagCloud' tagMap =
131 return $ intercalate " " $ map (renderTag tagMap) (tagCount tagMap)
138 return $ intercalate " " $ map (renderTag tagMap) (tagCount tagMap)
133− renderTag tagMap (tag, count) =
140+ renderTag tagMap (tag, count) = renderHtml $
134− finalSubstitute linkTemplate $ Context $ M.fromList
141+ H.a ! A.style (stringValue $ "font-size: " ++ sizeTag tagMap count)
135− [ ("size", sizeTag tagMap count)
142+ ! A.href (stringValue $ urlFunction tag)
136− , ("url", urlFunction tag)
143+ $ string tag
141− fromString "<a style=\"font-size: $size\" href=\"$url\">$tag</a>"
143 sizeTag tagMap count = show (size' :: Int) ++ "%"
145 sizeTag tagMap count = show (size' :: Int) ++ "%"
145 size' = floor $ minSize + relative tagMap count * (maxSize - minSize)
147 size' = floor $ minSize + relative tagMap count * (maxSize - minSize)