From e49cd3b4b071c2e0cb3e553fe8272e7cd2843349 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 30 Dec 2010 21:18:55 +0100 Subject: Cleanup, split up page module --- src/Hakyll/Web/Util/String.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Hakyll/Web/Util') diff --git a/src/Hakyll/Web/Util/String.hs b/src/Hakyll/Web/Util/String.hs index 5a8c7c6..e48580b 100644 --- a/src/Hakyll/Web/Util/String.hs +++ b/src/Hakyll/Web/Util/String.hs @@ -2,13 +2,25 @@ -- module Hakyll.Web.Util.String ( trim + , toSiteRoot ) where import Data.Char (isSpace) +import System.FilePath (splitPath, takeDirectory, joinPath) + -- | Trim a string (drop spaces, tabs and newlines at both sides). -- trim :: String -> String trim = reverse . trim' . reverse . trim' where trim' = dropWhile isSpace + +-- | Get the relative url to the site root, for a given (absolute) url +-- +toSiteRoot :: FilePath -> FilePath +toSiteRoot = emptyException . joinPath . map parent . splitPath . takeDirectory + where + parent = const ".." + emptyException [] = "." + emptyException x = x -- cgit v1.2.3