From 1319bbfe4ab3ddd321bcbb902bba7392ad868324 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Fri, 9 Nov 2012 16:34:45 +0100 Subject: Remove Resource type --- src/Hakyll/Web/CompressCss.hs | 3 +-- src/Hakyll/Web/Page.hs | 11 +++++------ src/Hakyll/Web/Page/Metadata.hs | 4 ++-- src/Hakyll/Web/Pandoc/Biblio.hs | 13 ++++++------- src/Hakyll/Web/Template.hs | 5 ++--- 5 files changed, 16 insertions(+), 20 deletions(-) (limited to 'src/Hakyll/Web') diff --git a/src/Hakyll/Web/CompressCss.hs b/src/Hakyll/Web/CompressCss.hs index 52b5396..d0ca8cd 100644 --- a/src/Hakyll/Web/CompressCss.hs +++ b/src/Hakyll/Web/CompressCss.hs @@ -11,12 +11,11 @@ import Data.List (isPrefixOf) import Control.Arrow ((>>^)) import Hakyll.Core.Compiler -import Hakyll.Core.Resource import Hakyll.Core.Util.String -- | Compiler form of 'compressCss' -- -compressCssCompiler :: Compiler Resource String +compressCssCompiler :: Compiler a String compressCssCompiler = getResourceString >>^ compressCss -- | Compress CSS to speed up your site. diff --git a/src/Hakyll/Web/Page.hs b/src/Hakyll/Web/Page.hs index e92bb14..7f2430f 100644 --- a/src/Hakyll/Web/Page.hs +++ b/src/Hakyll/Web/Page.hs @@ -72,7 +72,6 @@ import Text.Pandoc (Pandoc, ParserState, WriterOptions) import Hakyll.Core.Identifier import Hakyll.Core.Compiler -import Hakyll.Core.Resource import Hakyll.Web.Page.Internal import Hakyll.Web.Page.Read import Hakyll.Web.Page.Metadata @@ -87,12 +86,12 @@ fromBody = Page M.empty -- | Read a page (do not render it) -- -readPageCompiler :: Compiler Resource (Page String) +readPageCompiler :: Compiler () (Page String) readPageCompiler = getResourceString >>^ readPage -- | Read a page, add default fields, substitute fields and render using pandoc -- -pageCompiler :: Compiler Resource (Page String) +pageCompiler :: Compiler () (Page String) pageCompiler = pageCompilerWith defaultHakyllParserState defaultHakyllWriterOptions @@ -100,7 +99,7 @@ pageCompiler = -- options -- pageCompilerWith :: ParserState -> WriterOptions - -> Compiler Resource (Page String) + -> Compiler () (Page String) pageCompilerWith state options = pageCompilerWithPandoc state options id -- | An extension of 'pageCompilerWith' which allows you to specify a custom @@ -108,7 +107,7 @@ pageCompilerWith state options = pageCompilerWithPandoc state options id -- pageCompilerWithPandoc :: ParserState -> WriterOptions -> (Pandoc -> Pandoc) - -> Compiler Resource (Page String) + -> Compiler () (Page String) pageCompilerWithPandoc state options f = cached cacheName $ readPageCompiler >>> addDefaultFields >>> arr applySelf >>> pageReadPandocWith state @@ -124,7 +123,7 @@ pageCompilerWithPandoc state options f = cached cacheName $ pageCompilerWithFields :: ParserState -> WriterOptions -> (Pandoc -> Pandoc) -> Compiler (Page String) (Page String) - -> Compiler Resource (Page String) + -> Compiler () (Page String) pageCompilerWithFields state options f g = readPageCompiler >>> addDefaultFields >>> g >>> arr applySelf >>> pageReadPandocWith state diff --git a/src/Hakyll/Web/Page/Metadata.hs b/src/Hakyll/Web/Page/Metadata.hs index 764022a..742bf06 100644 --- a/src/Hakyll/Web/Page/Metadata.hs +++ b/src/Hakyll/Web/Page/Metadata.hs @@ -38,7 +38,7 @@ import Hakyll.Web.Page.Internal import Hakyll.Core.Util.String import Hakyll.Core.Identifier import Hakyll.Core.Compiler -import Hakyll.Core.Resource.Provider +import Hakyll.Core.ResourceProvider -- | Get a metadata field. If the field does not exist, the empty string is -- returned. @@ -208,7 +208,7 @@ renderModificationTimeWith :: TimeLocale -> Compiler (Page String) (Page String) -- ^ Resulting compiler renderModificationTimeWith locale key format = - id &&& (getResource >>> getResourceWith resourceModificationTime) >>> + id &&& (getResourceWith resourceModificationTime) >>> setFieldA key (arr (formatTime locale format)) -- | Copy the body of a page to a metadata field diff --git a/src/Hakyll/Web/Pandoc/Biblio.hs b/src/Hakyll/Web/Pandoc/Biblio.hs index 48f7982..64a702b 100644 --- a/src/Hakyll/Web/Pandoc/Biblio.hs +++ b/src/Hakyll/Web/Pandoc/Biblio.hs @@ -17,7 +17,7 @@ module Hakyll.Web.Pandoc.Biblio ) where import Control.Applicative ((<$>)) -import Control.Arrow (arr, returnA) +import Control.Arrow (arr, returnA, (>>>)) import Data.Typeable (Typeable) import Data.Binary (Binary (..)) @@ -27,7 +27,6 @@ import qualified Text.CSL as CSL import Hakyll.Core.Compiler import Hakyll.Core.Identifier -import Hakyll.Core.Resource import Hakyll.Core.Writable import Hakyll.Web.Page import Hakyll.Web.Pandoc @@ -35,8 +34,8 @@ import Hakyll.Web.Pandoc newtype CSL = CSL FilePath deriving (Binary, Show, Typeable, Writable) -cslCompiler :: Compiler Resource CSL -cslCompiler = arr (CSL . unResource) +cslCompiler :: Compiler () CSL +cslCompiler = getIdentifier >>> arr (CSL . toFilePath) newtype Biblio = Biblio [CSL.Reference] deriving (Show, Typeable) @@ -49,9 +48,9 @@ instance Binary Biblio where instance Writable Biblio where write _ _ = return () -biblioCompiler :: Compiler Resource Biblio -biblioCompiler = unsafeCompiler $ - fmap Biblio . CSL.readBiblioFile . unResource +biblioCompiler :: Compiler () Biblio +biblioCompiler = getIdentifier >>> + arr toFilePath >>> unsafeCompiler CSL.readBiblioFile >>> arr Biblio pageReadPandocBiblio :: ParserState -> Identifier CSL diff --git a/src/Hakyll/Web/Template.hs b/src/Hakyll/Web/Template.hs index b33d1f3..6b2f915 100644 --- a/src/Hakyll/Web/Template.hs +++ b/src/Hakyll/Web/Template.hs @@ -79,7 +79,6 @@ import Text.Hamlet (HamletSettings, defaultHamletSettings) import Hakyll.Core.Compiler import Hakyll.Core.Identifier -import Hakyll.Core.Resource import Hakyll.Web.Template.Internal import Hakyll.Web.Template.Read import Hakyll.Web.Page.Internal @@ -119,12 +118,12 @@ applySelf page = applyTemplate (readTemplate $ pageBody page) page -- @.hml@ or @.hamlet@, it will be considered as a Hamlet template, and parsed -- as such. -- -templateCompiler :: Compiler Resource Template +templateCompiler :: Compiler () Template templateCompiler = templateCompilerWith defaultHamletSettings -- | Version of 'templateCompiler' that enables custom settings. -- -templateCompilerWith :: HamletSettings -> Compiler Resource Template +templateCompilerWith :: HamletSettings -> Compiler () Template templateCompilerWith settings = cached "Hakyll.Web.Template.templateCompilerWith" $ getIdentifier &&& getResourceString >>^ uncurry read' -- cgit v1.2.3