diff options
| author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-30 21:18:55 +0100 |
|---|---|---|
| committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-12-30 21:18:55 +0100 |
| commit | e49cd3b4b071c2e0cb3e553fe8272e7cd2843349 (patch) | |
| tree | 544d8f29ca8082577426010b7f251185a209e3f4 /src/Hakyll/Web/Util | |
| parent | da12825066d16884bae2f884029102919dd9a558 (diff) | |
| download | hakyll-e49cd3b4b071c2e0cb3e553fe8272e7cd2843349.tar.gz | |
Cleanup, split up page module
Diffstat (limited to 'src/Hakyll/Web/Util')
| -rw-r--r-- | src/Hakyll/Web/Util/String.hs | 12 |
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 |
