Module cleanup.

This commit is contained in:
Jasper Van der Jeugt 2010-01-24 16:40:09 +01:00
parent aef33d18da
commit 42bacee41a
6 changed files with 32 additions and 29 deletions

View file

@ -35,19 +35,19 @@ library
old-locale >= 1,
time >= 1,
binary >= 0.5
exposed-modules: Text.Hakyll
exposed-modules: Network.Hakyll.SimpleServer
Text.Hakyll
Text.Hakyll.Context
Text.Hakyll.File
Text.Hakyll.Hakyll
Text.Hakyll.Regex
Text.Hakyll.Render
Text.Hakyll.Renderable
Text.Hakyll.Renderables
Text.Hakyll.CompressCSS
Text.Hakyll.File
Text.Hakyll.Page
Text.Hakyll.Util
Text.Hakyll.Tags
Text.Hakyll.Context
Text.Hakyll.Regex
Text.Hakyll.Template
Network.Hakyll.SimpleServer
other-modules: Text.Hakyll.Render.Internal
Text.Hakyll.Internal.Cache
other-modules: Text.Hakyll.Internal.Cache
Text.Hakyll.Internal.CompressCSS
Text.Hakyll.Internal.Render
Text.Hakyll.Internal.Template

View file

@ -1,6 +1,6 @@
-- | Module used for CSS compression. The compression is currently in a simple
-- state, but would typically reduce the number of bytes by about 25%.
module Text.Hakyll.CompressCSS
module Text.Hakyll.Internal.CompressCSS
( compressCSS
) where

View file

@ -1,5 +1,5 @@
-- | Internal module do some low-level rendering.
module Text.Hakyll.Render.Internal
module Text.Hakyll.Internal.Render
( substitute
, regularSubstitute
, finalSubstitute
@ -14,20 +14,12 @@ import Control.Monad.Reader (liftIO)
import Data.List (foldl')
import Data.Maybe (fromMaybe)
import Text.Hakyll.Template (Template, substitute, fromString)
import Text.Hakyll.Context (Context, ContextManipulation)
import Text.Hakyll.Renderable
import Text.Hakyll.Page
import Text.Hakyll.File
import Text.Hakyll.Hakyll
-- | "substitute" for use during a chain.
regularSubstitute :: Template -> Context -> String
regularSubstitute = substitute "$$"
-- | "substitute" for the end of a chain (just before writing).
finalSubstitute :: Template -> Context -> String
finalSubstitute = substitute "$"
import Text.Hakyll.Internal.Template
-- | A pure render function.
pureRenderWith :: ContextManipulation -- ^ Manipulation to apply on the context.

View file

@ -1,8 +1,10 @@
module Text.Hakyll.Template
module Text.Hakyll.Internal.Template
( Template
, fromString
, readTemplate
, substitute
, regularSubstitute
, finalSubstitute
) where
import qualified Data.Map as M
@ -46,9 +48,9 @@ readTemplate path = do
where
fileName = "templates" </> path
-- | Substitutes @$identifiers@ in the given string by values from the given
-- "Context". When a key is not found, it is left as it is. You can here
-- specify the characters used to replace escaped dollars (@$$@).
-- | Substitutes @$identifiers@ in the given "Template" by values from the given
-- "Context". When a key is not found, it is left as it is. You can specify
-- the characters used to replace escaped dollars (@$$@) here.
substitute :: String -> Template -> Context -> String
substitute escaper (Chunk chunk template) context =
chunk ++ substitute escaper template context
@ -60,6 +62,16 @@ substitute escaper (EscapeCharacter template) context =
escaper ++ substitute escaper template context
substitute _ End _ = []
-- | "substitute" for use during a chain. This will leave escaped characters as
-- they are.
regularSubstitute :: Template -> Context -> String
regularSubstitute = substitute "$$"
-- | "substitute" for the end of a chain (just before writing). This renders
-- escaped characters.
finalSubstitute :: Template -> Context -> String
finalSubstitute = substitute "$"
instance Binary Template where
put (Chunk string template) = put (0 :: Word8) >> put string >> put template
put (Identifier key template) = put (1 :: Word8) >> put key >> put template

View file

@ -16,14 +16,14 @@ import Control.Monad (unless)
import Control.Monad.Reader (liftIO)
import System.Directory (copyFile)
import Text.Hakyll.Template (readTemplate)
import Text.Hakyll.Hakyll (Hakyll)
import Text.Hakyll.Context (ContextManipulation)
import Text.Hakyll.Page
import Text.Hakyll.Renderable
import Text.Hakyll.File
import Text.Hakyll.CompressCSS
import Text.Hakyll.Render.Internal
import Text.Hakyll.Internal.Template (readTemplate)
import Text.Hakyll.Internal.CompressCSS
import Text.Hakyll.Internal.Render
-- | Execute an IO action only when the cache is invalid.
depends :: FilePath -- ^ File to be rendered or created.

View file

@ -29,12 +29,11 @@ import System.FilePath ((</>))
import Text.Hakyll.Hakyll (Hakyll)
import Text.Hakyll.Context (ContextManipulation, changeValue)
import Text.Hakyll.Render.Internal (finalSubstitute)
import Text.Hakyll.Regex
import Text.Hakyll.Template
import Text.Hakyll.Util
import Text.Hakyll.Page
import Text.Hakyll.Internal.Cache
import Text.Hakyll.Internal.Template
-- | Read a tag map. This creates a map from tags to page paths.
--