summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-11-15 16:00:28 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-11-15 16:00:28 +0100
commit8da7d5b653ecd3157be10e6373e47f771df9472f (patch)
treea043c851156ba8ad3a7f54257c0ddaa370af6239 /src/Text
parent1b5a0220f99742586e8c2c498f8ad878cddd30dd (diff)
downloadhakyll-8da7d5b653ecd3157be10e6373e47f771df9472f.tar.gz
One implementation for toDestination and toCache
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Hakyll/File.hs30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs
index 57571e4..167ece7 100644
--- a/src/Text/Hakyll/File.hs
+++ b/src/Text/Hakyll/File.hs
@@ -40,24 +40,32 @@ removeLeadingSeparator path
path' = if "$root" `isPrefixOf` path then drop 5 path
else path
--- | Convert a relative filepath to a filepath in the destination
+-- | Convert a relative URL to a filepath in the destination
-- (default: @_site@).
toDestination :: FilePath -> Hakyll FilePath
toDestination url = do dir <- askHakyll siteDirectory
- enableIndexUrl' <- askHakyll enableIndexUrl
- let destination = if enableIndexUrl' && separatorEnd
- then dir </> noSeparator </> "index.html"
- else dir </> noSeparator
- return destination
- where
- noSeparator = removeLeadingSeparator url
- separatorEnd = not (null url) && last url == '/'
+ toFilePath dir url
--- | Convert a relative filepath to a filepath in the cache
+-- | Convert a relative URL to a filepath in the cache
-- (default: @_cache@).
toCache :: FilePath -> Hakyll FilePath
toCache path = do dir <- askHakyll cacheDirectory
- return $ dir </> removeLeadingSeparator path
+ toFilePath dir path
+
+-- | Implementation of toDestination/toCache
+--
+toFilePath :: String -- ^ Directory (site or cache)
+ -> String -- ^ URL
+ -> Hakyll FilePath -- ^ Resulting file path
+toFilePath dir url = do
+ enableIndexUrl' <- askHakyll enableIndexUrl
+ let destination = if enableIndexUrl' && separatorEnd
+ then dir </> noSeparator </> "index.html"
+ else dir </> noSeparator
+ return destination
+ where
+ noSeparator = removeLeadingSeparator url
+ separatorEnd = not (null url) && last url == '/'
-- | Get the url for a given page. For most extensions, this would be the path
-- itself. It's only for rendered extensions (@.markdown@, @.rst@, @.lhs@ this