From 699bd0011e9771cd5c03c65aec0ec79656c475a1 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 8 Jan 2010 12:41:58 +0100 Subject: Added tagblog example (tutorial coming up). --- src/Text/Hakyll/File.hs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/Text/Hakyll/File.hs') diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs index 0c803e1..400d156 100644 --- a/src/Text/Hakyll/File.hs +++ b/src/Text/Hakyll/File.hs @@ -4,6 +4,7 @@ module Text.Hakyll.File ( toDestination , toCache , toURL + , removeSpaces , makeDirectories , getRecursiveContents , havingExtension @@ -15,18 +16,31 @@ import System.Directory import System.FilePath import Control.Monad +-- | Auxiliary function to remove pathSeparators form the start. We don't deal +-- with absolute paths here. +removeLeadingSeparator :: FilePath -> FilePath +removeLeadingSeparator [] = [] +removeLeadingSeparator p@(x:xs) | x `elem` pathSeparators = xs + | otherwise = p + -- | Convert a relative filepath to a filepath in the destination (_site). toDestination :: FilePath -> FilePath -toDestination path = "_site" path +toDestination path = "_site" (removeLeadingSeparator path) -- | Convert a relative filepath to a filepath in the cache (_cache). toCache :: FilePath -> FilePath -toCache path = "_cache" path +toCache path = "_cache" (removeLeadingSeparator path) -- | Get the url for a given page. toURL :: FilePath -> FilePath toURL = flip addExtension ".html" . dropExtension +-- | Swaps spaces for '-'. +removeSpaces :: FilePath -> FilePath +removeSpaces = map swap + where swap ' ' = '-' + swap x = x + -- | Given a path to a file, try to make the path writable by making -- all directories on the path. makeDirectories :: FilePath -> IO () -- cgit v1.2.3