on master help sign in
Module cleanup.
42baceeJasper Van der Jeugt
hakyll.cabal+9−9
@@ -35,19 +35,19 @@ library
35 old-locale >= 1,
35 old-locale >= 1,
36 time >= 1,
36 time >= 1,
37 binary >= 0.5
37 binary >= 0.5
38+ exposed-modules: Network.Hakyll.SimpleServer
38− exposed-modules: Text.Hakyll
39+ Text.Hakyll
40+ Text.Hakyll.Context
41+ Text.Hakyll.File
39 Text.Hakyll.Hakyll
42 Text.Hakyll.Hakyll
43+ Text.Hakyll.Regex
40 Text.Hakyll.Render
44 Text.Hakyll.Render
41 Text.Hakyll.Renderable
45 Text.Hakyll.Renderable
42 Text.Hakyll.Renderables
46 Text.Hakyll.Renderables
43− Text.Hakyll.CompressCSS
44− Text.Hakyll.File
45 Text.Hakyll.Page
47 Text.Hakyll.Page
46 Text.Hakyll.Util
48 Text.Hakyll.Util
47 Text.Hakyll.Tags
49 Text.Hakyll.Tags
48− Text.Hakyll.Context
49− Text.Hakyll.Regex
50− Text.Hakyll.Template
51− Network.Hakyll.SimpleServer
52− other-modules: Text.Hakyll.Render.Internal
50+ other-modules: Text.Hakyll.Internal.Cache
53− Text.Hakyll.Internal.Cache
51+ Text.Hakyll.Internal.CompressCSS
52+ Text.Hakyll.Internal.Render
53+ Text.Hakyll.Internal.Template
src/Text/Hakyll/CompressCSS.hs → src/Text/Hakyll/Internal/CompressCSS.hsrenamed+1−1
@@ -1,6 +1,6 @@
1-- | Module used for CSS compression. The compression is currently in a simple
1-- | Module used for CSS compression. The compression is currently in a simple
2-- state, but would typically reduce the number of bytes by about 25%.
2-- state, but would typically reduce the number of bytes by about 25%.
3−module Text.Hakyll.CompressCSS
3+module Text.Hakyll.Internal.CompressCSS
4 ( compressCSS
4 ( compressCSS
5 ) where
5 ) where
6
6
src/Text/Hakyll/Render/Internal.hs → src/Text/Hakyll/Internal/Render.hsrenamed+2−10
@@ -1,5 +1,5 @@
1-- | Internal module do some low-level rendering.
1-- | Internal module do some low-level rendering.
2−module Text.Hakyll.Render.Internal
2+module Text.Hakyll.Internal.Render
3 ( substitute
3 ( substitute
4 , regularSubstitute
4 , regularSubstitute
5 , finalSubstitute
5 , finalSubstitute
@@ -14,20 +14,12 @@ import Control.Monad.Reader (liftIO)
14import Data.List (foldl')
14import Data.List (foldl')
15import Data.Maybe (fromMaybe)
15import Data.Maybe (fromMaybe)
16
16
17−import Text.Hakyll.Template (Template, substitute, fromString)
18import Text.Hakyll.Context (Context, ContextManipulation)
17import Text.Hakyll.Context (Context, ContextManipulation)
19import Text.Hakyll.Renderable
18import Text.Hakyll.Renderable
20import Text.Hakyll.Page
19import Text.Hakyll.Page
21import Text.Hakyll.File
20import Text.Hakyll.File
22import Text.Hakyll.Hakyll
21import Text.Hakyll.Hakyll
23−
22+import Text.Hakyll.Internal.Template
24−-- | "substitute" for use during a chain.
25−regularSubstitute :: Template -> Context -> String
26−regularSubstitute = substitute "$$"
27−
28−-- | "substitute" for the end of a chain (just before writing).
29−finalSubstitute :: Template -> Context -> String
30−finalSubstitute = substitute "$"
31
23
32-- | A pure render function.
24-- | A pure render function.
33pureRenderWith :: ContextManipulation -- ^ Manipulation to apply on the context.
25pureRenderWith :: ContextManipulation -- ^ Manipulation to apply on the context.
src/Text/Hakyll/Template.hs → src/Text/Hakyll/Internal/Template.hsrenamed+16−4
@@ -1,8 +1,10 @@
1−module Text.Hakyll.Template
1+module Text.Hakyll.Internal.Template
2 ( Template
2 ( Template
3 , fromString
3 , fromString
4 , readTemplate
4 , readTemplate
5 , substitute
5 , substitute
6+ , regularSubstitute
7+ , finalSubstitute
6 ) where
8 ) where
7
9
8import qualified Data.Map as M
10import qualified Data.Map as M
@@ -46,9 +48,9 @@ readTemplate path = do
46 where
48 where
47 fileName = "templates" </> path
49 fileName = "templates" </> path
48
50
49−-- | Substitutes @$identifiers@ in the given string by values from the given
51+-- | Substitutes @$identifiers@ in the given "Template" by values from the given
50−-- "Context". When a key is not found, it is left as it is. You can here
52+-- "Context". When a key is not found, it is left as it is. You can specify
51−-- specify the characters used to replace escaped dollars (@$$@).
53+-- the characters used to replace escaped dollars (@$$@) here.
52substitute :: String -> Template -> Context -> String
54substitute :: String -> Template -> Context -> String
53substitute escaper (Chunk chunk template) context =
55substitute escaper (Chunk chunk template) context =
54 chunk ++ substitute escaper template context
56 chunk ++ substitute escaper template context
@@ -59,6 +61,16 @@ substitute escaper (Identifier key template) context =
59substitute escaper (EscapeCharacter template) context =
61substitute escaper (EscapeCharacter template) context =
60 escaper ++ substitute escaper template context
62 escaper ++ substitute escaper template context
61substitute _ End _ = []
63substitute _ End _ = []
64+
65+-- | "substitute" for use during a chain. This will leave escaped characters as
66+-- they are.
67+regularSubstitute :: Template -> Context -> String
68+regularSubstitute = substitute "$$"
69+
70+-- | "substitute" for the end of a chain (just before writing). This renders
71+-- escaped characters.
72+finalSubstitute :: Template -> Context -> String
73+finalSubstitute = substitute "$"
62
74
63instance Binary Template where
75instance Binary Template where
64 put (Chunk string template) = put (0 :: Word8) >> put string >> put template
76 put (Chunk string template) = put (0 :: Word8) >> put string >> put template
src/Text/Hakyll/Render.hs+3−3
@@ -16,14 +16,14 @@ import Control.Monad (unless)
16import Control.Monad.Reader (liftIO)
16import Control.Monad.Reader (liftIO)
17import System.Directory (copyFile)
17import System.Directory (copyFile)
18
18
19−import Text.Hakyll.Template (readTemplate)
20import Text.Hakyll.Hakyll (Hakyll)
19import Text.Hakyll.Hakyll (Hakyll)
21import Text.Hakyll.Context (ContextManipulation)
20import Text.Hakyll.Context (ContextManipulation)
22import Text.Hakyll.Page
21import Text.Hakyll.Page
23import Text.Hakyll.Renderable
22import Text.Hakyll.Renderable
24import Text.Hakyll.File
23import Text.Hakyll.File
25−import Text.Hakyll.CompressCSS
24+import Text.Hakyll.Internal.Template (readTemplate)
25+import Text.Hakyll.Internal.CompressCSS
26−import Text.Hakyll.Render.Internal
26+import Text.Hakyll.Internal.Render
27
27
28-- | Execute an IO action only when the cache is invalid.
28-- | Execute an IO action only when the cache is invalid.
29depends :: FilePath -- ^ File to be rendered or created.
29depends :: FilePath -- ^ File to be rendered or created.
src/Text/Hakyll/Tags.hs+1−2
@@ -29,12 +29,11 @@ import System.FilePath ((</>))
29
29
30import Text.Hakyll.Hakyll (Hakyll)
30import Text.Hakyll.Hakyll (Hakyll)
31import Text.Hakyll.Context (ContextManipulation, changeValue)
31import Text.Hakyll.Context (ContextManipulation, changeValue)
32−import Text.Hakyll.Render.Internal (finalSubstitute)
33import Text.Hakyll.Regex
32import Text.Hakyll.Regex
34−import Text.Hakyll.Template
35import Text.Hakyll.Util
33import Text.Hakyll.Util
36import Text.Hakyll.Page
34import Text.Hakyll.Page
37import Text.Hakyll.Internal.Cache
35import Text.Hakyll.Internal.Cache
36+import Text.Hakyll.Internal.Template
38
37
39-- | Read a tag map. This creates a map from tags to page paths.
38-- | Read a tag map. This creates a map from tags to page paths.
40--
39--