on master help sign in
Docs
commitadc8cf8528e7c9d95e2a8406a02e69cce858f088 authorJasper Van der Jeugt <m@jaspervdj.be> dateFri 14 Dec 2012, 12:12 (14 years ago) parenta2620ee
2 files changed+28−61
src/Hakyll/Core/Identifier/Pattern.hs+14−21 web/tutorials/02-basics.markdown+14−40
src/Hakyll/Core/Identifier/Pattern.hs+14−21
@@ -1,40 +1,33 @@
11--------------------------------------------------------------------------------
2−-- | Module providing pattern matching and capturing on 'Identifier's.
3−-- 'Pattern's come in two kinds:
2+-- | As 'Identifier' is used to specify a single item, a 'Pattern' is used to
3+-- specify a list of items.
44--
5−-- * Simple glob patterns, like @foo\/*@;
5+-- In most cases, globs are used for patterns.
66--
7−-- * Custom, arbitrary predicates of the type @Identifier -> Bool@.
8−--
9−-- They both have advantages and disadvantages. By default, globs are used,
10−-- unless you construct your 'Pattern' using the 'predicate' function.
11−--
12−-- A very simple pattern could be, for example, @foo\/bar@. This pattern will
7+-- A very simple pattern of such a pattern is @\"foo\/bar\"@. This pattern will
138-- only match the exact @foo\/bar@ identifier.
149--
1510-- To match more than one identifier, there are different captures that one can
1611-- use:
1712--
18−-- * @*@: matches at most one element of an identifier;
13+-- * @\"*\"@: matches at most one element of an identifier;
1914--
20−-- * @**@: matches one or more elements of an identifier.
15+-- * @\"**\"@: matches one or more elements of an identifier.
2116--
2217-- Some examples:
2318--
24−-- * @foo\/*@ will match @foo\/bar@ and @foo\/foo@, but not @foo\/bar\/qux@;
19+-- * @\"foo\/*\"@ will match @\"foo\/bar\"@ and @\"foo\/foo\"@, but not
20+-- @\"foo\/bar\/qux\"@;
2521--
26−-- * @**@ will match any identifier;
22+-- * @\"**\"@ will match any identifier;
2723--
28−-- * @foo\/**@ will match @foo\/bar@ and @foo\/bar\/qux@, but not @bar\/foo@;
24+-- * @\"foo\/**\"@ will match @\"foo\/bar\"@ and @\"foo\/bar\/qux\"@, but not
25+-- @\"bar\/foo\"@;
2926--
30−-- * @foo\/*.html@ will match all HTML files in the @foo\/@ directory.
27+-- * @\"foo\/*.html\"@ will match all HTML files in the @\"foo\/\"@ directory.
3128--
3229-- The 'capture' function allows the user to get access to the elements captured
3330-- by the capture elements in the pattern.
34−--
35−-- Like an 'Identifier', a 'Pattern' also has a type parameter. This is simply
36−-- an extra layer of safety, and can be discarded using the 'castPattern'
37−-- function.
3831module Hakyll.Core.Identifier.Pattern
3932 ( -- * The pattern type
4033 Pattern
@@ -213,8 +206,8 @@ withVersion p v = optimize $ And p $ fromVersion $ Just v
213206
214207
215208--------------------------------------------------------------------------------
216−-- | Check if a pattern is a literal. @"*.markdown"@ is not a literal but
217−-- @"posts.markdown"@ is.
209+-- | Check if a pattern is a literal. @\"*.markdown\"@ is not a literal but
210+-- @\"posts.markdown\"@ is.
218211fromLiteral :: Pattern -> Maybe Identifier
219212fromLiteral pattern = case pattern of
220213 Glob p -> fmap fromFilePath $ foldr fromLiteral' (Just "") p
web/tutorials/02-basics.markdown+14−40
@@ -3,52 +3,26 @@ title: The basics
33author: Jasper Van der Jeugt
44---
55
6−## Let's get started!
6+Building and cleaning
7+---------------------
78
8−We're going to discuss a small brochure site to start with. You can find all
9−code and files necessary to build this site
10−[right here](http://github.com/jaspervdj/hakyll-examples/tree/master/brochure)
11−-- feel free to look at them as we go trough the tutorial. To fetch all examples
12−in order to play with them locally, use:
9+If you followed along with the previous tutorial, you should now have the
10+example site up and running. By running `./site build`, you created two
11+directories:
1312
14− git clone git://github.com/jaspervdj/hakyll-examples.git
13+- `_site`, with your site as HTML files, ready to be deployed;
14+- `_cache`, which Hakyll uses internally.
1515
16−or navigate to the download menu on GitHub.
16+`./site clean` removes these directories, and `./site rebuild` performs a
17+`clean` and then a `build`.
1718
18−Now, for this first tutorial, there's a number of files we will use:
19+In general, it's only necessary to use `rebuild` when you made changes to your
20+`site.hs`, and not when you just made changes to the contents of your website.
1921
20− about.rst A simple page written in RST format
21− code.lhs Another page with some code (which can be highlighted)
22− css Directory for CSS files
23− |- default.css The main CSS file
24− \- syntax.css CSS file for code syntax highlighting
25− hakyll.hs Our code to generate the site
26− images Directory for images
27− \- haskell-logo.png The logo of my favorite programming language
28− index.markdown A simple page in markdown format
29− templates Directory for templates
30− \- default.html The main template for the site
22+Basic rules
23+-----------
3124
32−By default, hakyll will compile everything to the `_site` directory. We can try
33−this like this:
34−
35− [jasper@phoenix] ghc --make hakyll.hs
36− [jasper@phoenix] ./hakyll build
37−
38−Instead of using `build`, we can also use `preview`, which will fire up a
39−webserver serving the `_site` directory, so have a look!
40−
41−All files have been compiled, and their output has been placed in the `_site`
42−directory as illustrated in this diagram:
43−
44−![Brochure files](/images/brochure-files.png)
45−
46−No magic is involved at all -- we will precisely study how and why our items are
47−compiled like that. All of this is specified in the `hakyll.hs` file. You can
48−view the full `hakyll.hs` file online [here][brochure-hakyll.hs], or you can
49−look in the directory you cloned or downloaded.
50−
51−[brochure-hakyll.hs]: http://github.com/jaspervdj/hakyll-examples/blob/master/brochure/hakyll.hs
25+TODO
5226
5327## Images
5428