summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Util
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-30 21:18:55 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-12-30 21:18:55 +0100
commite49cd3b4b071c2e0cb3e553fe8272e7cd2843349 (patch)
tree544d8f29ca8082577426010b7f251185a209e3f4 /src/Hakyll/Web/Util
parentda12825066d16884bae2f884029102919dd9a558 (diff)
downloadhakyll-e49cd3b4b071c2e0cb3e553fe8272e7cd2843349.tar.gz
Cleanup, split up page module
Diffstat (limited to 'src/Hakyll/Web/Util')
-rw-r--r--src/Hakyll/Web/Util/String.hs12
1 files changed, 12 insertions, 0 deletions
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