@@ -14,7 +14,7 @@
1414--
1515-- > <img src="../images/lolcat.png" alt="Funny zomgroflcopter" />
1616--
17−module Hakyll.Web.RelativizeUrls
17+module Hakyll.Web.Urls.Relativize
1818 ( relativizeUrlsCompiler
1919 , relativizeUrls
2020 ) where
@@ -23,13 +23,10 @@ import Prelude hiding (id)
2323import Control.Category (id)
2424import Control.Arrow ((&&&), (>>^))
2525import Data.List (isPrefixOf)
26−import qualified Data.Set as S
27−
28−import Text.HTML.TagSoup
2926
3027import Hakyll.Core.Compiler
3128import Hakyll.Web.Page
32−import Hakyll.Web.Util.Url
29+import Hakyll.Web.Urls
3330
3431-- | Compiler form of 'relativizeUrls' which automatically picks the right root
3532-- path
@@ -45,18 +42,6 @@ relativizeUrlsCompiler = getRoute &&& id >>^ uncurry relativize
4542relativizeUrls :: String -- ^ Path to the site root
4643 -> String -- ^ HTML to relativize
4744 -> String -- ^ Resulting HTML
48−relativizeUrls root = renderTags . map relativizeUrls' . parseTags
49− where
50− relativizeUrls' (TagOpen s a) = TagOpen s $ map (relativizeUrlsAttrs root) a
51− relativizeUrls' x = x
52−
53−-- | Relativize URL's in attributes
54−--
55−relativizeUrlsAttrs :: String -- ^ Path to the site root
56− -> Attribute String -- ^ Attribute to relativize
57− -> Attribute String -- ^ Resulting attribute
58−relativizeUrlsAttrs root (key, value)
59− | key `S.member` urls && "/" `isPrefixOf` value = (key, root ++ value)
60− | otherwise = (key, value)
45+relativizeUrls root = withUrls rel
6146 where
62− urls = S.fromList ["src", "href"]
47+ rel x = if "/" `isPrefixOf` x then root ++ x else x