on master help sign in
Document RelativizeUrls module
commit878ca8f3b02e99e736edaf5c7f0ba376ff3fe282 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSat 12 Feb 2011, 20:33 (16 years ago) parent1e0c875
3 files changed+31−5
examples/brochure/hakyll.hs+1−1 examples/hakyll/tutorial.markdown+14−4 src/Hakyll/Web/RelativizeUrls.hs+16
examples/brochure/hakyll.hs+1−1
@@ -14,5 +14,5 @@ main = hakyll $ do
1414 forM_ ["about.rst", "index.markdown", "code.lhs"] $ \page -> do
1515 route page $ setExtension "html"
1616 compile page $ defaultPageRead
17− >>> require "templates/default.html" (flip applyTemplate)
17+ >>> defaultApplyTemplate "templates/default.html"
1818 >>> defaultRelativizeUrls
examples/hakyll/tutorial.markdown+14−4
@@ -73,7 +73,7 @@ main = hakyll $ do
7373 forM_ ["about.rst", "index.markdown", "code.lhs"] $ \page -> do
7474 route page $ setExtension "html"
7575 compile page $ defaultPageRead
76− >>> require "templates/default.html" (flip applyTemplate)
76+ >>> defaultApplyTemplate "templates/default.html"
7777 >>> defaultRelativizeUrls
7878~~~~~
7979
@@ -133,7 +133,7 @@ Next, we're going to render some pages. We're going to style the results a
133133little, so we're going to need a [template]. We simply compile a template using
134134the `defaultTemplateRead` compiler, it's good enough in most cases.
135135
136−[template]: TODO: link
136+[template]: /reference/Hakyll-Web-Template.html
137137
138138We don't use a route for these templates, after all, we don't want to route them
139139anywhere, we just want to use them to style our pages a little.
@@ -142,6 +142,13 @@ anywhere, we just want to use them to style our pages a little.
142142compile "templates/*" defaultTemplateRead
143143~~~~~
144144
145+We can conclude that some rules do not *directly* add an output page on our
146+site. In this case, we compile the template so it is available to the compiler
147+later[^1].
148+
149+[^1]: Actually, since the rules DSL is declarative, we could also add the
150+ template compile rule at the bottom -- this would make no difference.
151+
145152Now, it's time to actually render our pages. We use the `forM_` monad combinator
146153so we can describe all files at once.
147154
@@ -162,10 +169,13 @@ DSL there.
162169### The Compiler DSL
163170
164171The gist of it is that the `Compiler a b` type has two parameters -- it is an
165−Arrow, and we can chain compilers using the `>>>` operator.
172+Arrow, and we can chain compilers using the `>>>` operator. The [compiler]
173+reference page has some more information on this subject.
174+
175+[compiler]: /reference/Hakyll-Core-Compiler.html
166176
167177~~~~~{.haskell}
168178compile page $ defaultPageRead
169− >>> require "templates/default.html" (flip applyTemplate)
179+ >>> defaultApplyTemplate "templates/default.html"
170180 >>> defaultRelativizeUrls
171181~~~~~
src/Hakyll/Web/RelativizeUrls.hs+16
@@ -1,3 +1,19 @@
1+-- | This module exposes a function which can relativize URL's on a webpage.
2+--
3+-- This means that one can deploy the resulting site on
4+-- @http:\/\/example.com\/@, but also on @http:\/\/example.com\/some-folder\/@
5+-- without having to change anything (simply copy over the files).
6+--
7+-- To use it, you should use absolute URL's from the site root everywhere. For
8+-- example, use
9+--
10+-- > <img src="/images/lolcat.png" alt="Funny zomgroflcopter" />
11+--
12+-- in a blogpost. When running this through the relativize URL's module, this
13+-- will result in (suppose your blogpost is located at @\/posts\/foo.html@:
14+--
15+-- > <img src="../images/lolcat.png" alt="Funny zomgroflcopter" />
16+--
117module Hakyll.Web.RelativizeUrls
218 ( relativizeUrls
319 ) where