From 333c19d0c1d88ea35e3e811c2100b514ffe738c1 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Sat, 12 Dec 2009 14:48:36 +0100 Subject: Merged CustomPage and RenderableFilePath into one file. --- src/Text/Hakyll/CustomPage.hs | 29 ----------------------- src/Text/Hakyll/RenderableFilePath.hs | 16 ------------- src/Text/Hakyll/Renderables.hs | 44 +++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 45 deletions(-) delete mode 100644 src/Text/Hakyll/CustomPage.hs delete mode 100644 src/Text/Hakyll/RenderableFilePath.hs create mode 100644 src/Text/Hakyll/Renderables.hs (limited to 'src/Text') diff --git a/src/Text/Hakyll/CustomPage.hs b/src/Text/Hakyll/CustomPage.hs deleted file mode 100644 index c18bb2d..0000000 --- a/src/Text/Hakyll/CustomPage.hs +++ /dev/null @@ -1,29 +0,0 @@ -module Text.Hakyll.CustomPage - ( CustomPage, - createCustomPage - ) where - -import System.FilePath -import qualified Data.ByteString.Lazy.Char8 as B -import qualified Data.Map as M -import Control.Monad -import Text.Hakyll.Renderable - -data CustomPage = CustomPage { url :: String, - dependencies :: [FilePath], - mapping :: [(String, Either String (IO B.ByteString))] - } - -createCustomPage :: String - -> [FilePath] - -> [(String, Either String (IO B.ByteString))] - -> CustomPage -createCustomPage = CustomPage - -instance Renderable CustomPage where - getDependencies = dependencies - getURL = url - toContext page = do - values <- mapM (either (return . B.pack) (>>= return) . snd) (mapping page) - let keys = map (B.pack . fst) (mapping page) - return $ M.fromList $ (B.pack "url", B.pack $ url page) : zip keys values diff --git a/src/Text/Hakyll/RenderableFilePath.hs b/src/Text/Hakyll/RenderableFilePath.hs deleted file mode 100644 index f729a11..0000000 --- a/src/Text/Hakyll/RenderableFilePath.hs +++ /dev/null @@ -1,16 +0,0 @@ -module Text.Hakyll.RenderableFilePath - ( RenderableFilePath (..) - ) where - -import System.FilePath -import Text.Hakyll.Renderable -import Text.Hakyll.Util -import Text.Hakyll.Page - -newtype RenderableFilePath = RenderableFilePath FilePath - --- We can render filepaths -instance Renderable RenderableFilePath where - getDependencies (RenderableFilePath path) = return path - getURL (RenderableFilePath path) = toURL path - toContext (RenderableFilePath path) = readPage path >>= toContext diff --git a/src/Text/Hakyll/Renderables.hs b/src/Text/Hakyll/Renderables.hs new file mode 100644 index 0000000..17b987d --- /dev/null +++ b/src/Text/Hakyll/Renderables.hs @@ -0,0 +1,44 @@ +module Text.Hakyll.Renderables + ( CustomPage, + createCustomPage, + PagePath, + createPagePath + ) where + +import System.FilePath +import qualified Data.ByteString.Lazy.Char8 as B +import qualified Data.Map as M +import Control.Monad +import Text.Hakyll.Util +import Text.Hakyll.Page +import Text.Hakyll.Renderable + +data CustomPage = CustomPage { url :: String, + dependencies :: [FilePath], + mapping :: [(String, Either String (IO B.ByteString))] + } + +createCustomPage :: String + -> [FilePath] + -> [(String, Either String (IO B.ByteString))] + -> CustomPage +createCustomPage = CustomPage + +instance Renderable CustomPage where + getDependencies = dependencies + getURL = url + toContext page = do + values <- mapM (either (return . B.pack) (>>= return) . snd) (mapping page) + let keys = map (B.pack . fst) (mapping page) + return $ M.fromList $ (B.pack "url", B.pack $ url page) : zip keys values + +data PagePath = PagePath FilePath + +createPagePath :: FilePath -> PagePath +createPagePath = PagePath + +-- We can render filepaths +instance Renderable PagePath where + getDependencies (PagePath path) = return path + getURL (PagePath path) = toURL path + toContext (PagePath path) = readPage path >>= toContext -- cgit v1.2.3