From 141e761ce11d4d4ae9e9b86201249dbd549e2924 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 10 Nov 2012 18:11:46 +0100 Subject: Deprecate things, basics now work --- src/Hakyll/Web/Urls/Relativize.hs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'src/Hakyll/Web/Urls') 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@: -- -- > 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 -- cgit v1.2.3