summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Urls
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-11-10 18:11:46 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-11-10 18:11:46 +0100
commit141e761ce11d4d4ae9e9b86201249dbd549e2924 (patch)
tree0d0ba398331bceb9326c58392680fb81361fb6c3 /src/Hakyll/Web/Urls
parent260e4e2e8936f756d2f3a2e6e788f05ca28e4324 (diff)
downloadhakyll-141e761ce11d4d4ae9e9b86201249dbd549e2924.tar.gz
Deprecate things, basics now work
Diffstat (limited to 'src/Hakyll/Web/Urls')
-rw-r--r--src/Hakyll/Web/Urls/Relativize.hs36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/Hakyll/Web/Urls/Relativize.hs b/src/Hakyll/Web/Urls/Relativize.hs
index 0f833fc..0251cfe 100644
--- a/src/Hakyll/Web/Urls/Relativize.hs
+++ b/src/Hakyll/Web/Urls/Relativize.hs
@@ -1,3 +1,4 @@
+--------------------------------------------------------------------------------
-- | This module exposes a function which can relativize URL's on a webpage.
--
-- This means that one can deploy the resulting site on
@@ -13,36 +14,41 @@
-- will result in (suppose your blogpost is located at @\/posts\/foo.html@:
--
-- > <img src="../images/lolcat.png" alt="Funny zomgroflcopter" />
---
module Hakyll.Web.Urls.Relativize
( relativizeUrlsCompiler
, relativizeUrls
) where
-import Prelude hiding (id)
-import Control.Category (id)
-import Control.Arrow ((&&&), (>>^))
-import Data.List (isPrefixOf)
-import Hakyll.Core.Compiler
-import Hakyll.Web.Page
-import Hakyll.Web.Urls
+--------------------------------------------------------------------------------
+import Control.Arrow ((&&&), (>>^))
+import Control.Category (id)
+import Data.List (isPrefixOf)
+import Prelude hiding (id)
+
+
+--------------------------------------------------------------------------------
+import Hakyll.Core.Compiler
+import Hakyll.Web.Page
+import Hakyll.Web.Urls
+
+--------------------------------------------------------------------------------
-- | Compiler form of 'relativizeUrls' which automatically picks the right root
-- path
---
-relativizeUrlsCompiler :: Compiler (Page String) (Page String)
+relativizeUrlsCompiler :: Compiler Page Page
relativizeUrlsCompiler = getRoute &&& id >>^ uncurry relativize
where
relativize Nothing = id
- relativize (Just r) = fmap (relativizeUrls $ toSiteRoot r)
+ relativize (Just r) = relativizeUrls $ toSiteRoot r
+
+--------------------------------------------------------------------------------
-- | Relativize URL's in HTML
---
relativizeUrls :: String -- ^ Path to the site root
- -> String -- ^ HTML to relativize
- -> String -- ^ Resulting HTML
+ -> Page -- ^ HTML to relativize
+ -> Page -- ^ Resulting HTML
relativizeUrls root = withUrls rel
where
isRel x = "/" `isPrefixOf` x && not ("//" `isPrefixOf` x)
- rel x = if isRel x then root ++ x else x
+ rel x = if isRel x then root ++ x else x