on master help sign in
Added the hakyll homepage as an example itself.
4ef92fdJasper Van der Jeugt
examples/hakyll/about.markdownnew file+23
@@ -0,0 +1,23 @@
1+---
2+title: About
3+---
4+## Code
5+
6+The code for Hakyll is freely available on
7+[github](http://github.com/jaspervdj/Hakyll/). Patches and suggestions are
8+always very welcome.
9+
10+## Inspiration
11+
12+Hakyll is not the only static site generator out there. It was inspired by the
13+following awesome projects:
14+
15+- [yst](http://github.com/jgm/yst)
16+- [nanoc](http://nanoc.stoneship.org/)
17+- [Jekyll](http://jekyllrb.com/)
18+
19+## License
20+
21+Hakyll is available under a BSD license. Note, however, that pandoc is
22+released under a GPL license. Since you'll probably use Hakyll with pandoc,
23+you will have to license your code under a GPL-compatible license.
examples/hakyll/css/default.cssnew file+103
@@ -0,0 +1,103 @@
1+html {
2+ padding: 0px;
3+ margin: 0px;
4+ background-color: white;
5+ color: black;
6+ font-family: sans-serif;
7+}
8+
9+body {
10+ padding: 0px 0px 60px 0px;
11+ margin: 0px;
12+}
13+
14+div#header {
15+ height: 32px;
16+ padding: 20px 0px 20px 60px;
17+}
18+
19+div#header img {
20+ display: inline;
21+ vertical-align: middle;
22+}
23+
24+div#header h1 {
25+ padding-left: 10px;
26+ display: inline;
27+ text-transform: uppercase;
28+ vertical-align: middle;
29+}
30+
31+div#main {
32+ margin: 0px auto 0px auto;
33+ width: 760px;
34+}
35+
36+div#sidebar {
37+ margin-right: 30px;
38+ width: 160px;
39+ float: left;
40+ text-align: right;
41+}
42+
43+div#navigation a {
44+ display: block;
45+ font-size: 110%;
46+ text-decoration: none;
47+ margin-bottom: 10px;
48+ text-transform: uppercase;
49+}
50+
51+div#content {
52+ width: 570px;
53+ float: right;
54+}
55+
56+div#footer {
57+ padding-top: 30px;
58+ clear: both;
59+ font-size: 90%;
60+ text-align: center;
61+}
62+
63+a {
64+ color: black;
65+}
66+
67+h2 {
68+ font-size: 120%;
69+ text-transform: uppercase;
70+}
71+
72+h3 {
73+ font-size: 100%;
74+ text-transform: uppercase;
75+}
76+
77+div.column {
78+ width: 50%;
79+ float: left;
80+}
81+
82+div.column p {
83+ padding-right: 15px;
84+}
85+
86+ul {
87+ list-style-type: square;
88+ list-style-position: inside;
89+ padding-left: 0px;
90+}
91+
92+code {
93+ background-color: rgb(210, 210, 210);
94+ padding-left: 4px;
95+ padding-right: 4px;
96+}
97+
98+pre code {
99+ display: block;
100+ background-color: rgb(50, 50, 50);
101+ color: white;
102+ padding: 8px;
103+}
examples/hakyll/css/syntax.cssnew file+20
@@ -0,0 +1,20 @@
1+/* Generated by pandoc. */
2+table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre
3+{ margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; }
4+td.lineNumbers { border-right: 1px solid #555555; text-align: right; color: #555555; padding-right: 5px; padding-left: 5px; }
5+td.sourceCode { padding-left: 5px; }
6+pre.sourceCode { }
7+pre.sourceCode span.Normal { }
8+pre.sourceCode span.Keyword { color: #ff8fdf; font-weight: bold; }
9+pre.sourceCode span.DataType { color: #6fdfff; }
10+pre.sourceCode span.DecVal { color: #bf5f8f; }
11+pre.sourceCode span.BaseN { color: #bf5f8f; }
12+pre.sourceCode span.Float { color: #bf5f8f; }
13+pre.sourceCode span.Char { color: #bf8f5f; }
14+pre.sourceCode span.String { color: #bf8f5f; }
15+pre.sourceCode span.Comment { color: #9f5f4f; font-style: italic; }
16+pre.sourceCode span.Others { color: #ff8fdf; }
17+pre.sourceCode span.Alert { color: red; font-weight: bold; }
18+pre.sourceCode span.Function { color: #f9d781; }
19+pre.sourceCode span.RegionMarker { }
20+pre.sourceCode span.Error { color: red; font-weight: bold; }
examples/hakyll/examples/brochure.zipnew file

Binary file not shown.

examples/hakyll/hakyll.hsnew file+19
@@ -0,0 +1,19 @@
1+import Text.Hakyll
2+import Text.Hakyll.Render
3+import Text.Hakyll.Renderables
4+import Text.Hakyll.File
5+
6+import Control.Monad(mapM_)
7+
8+main = hakyll $ do
9+ directory css "css"
10+ directory static "images"
11+ directory static "examples"
12+
13+ mapM_ render' [ "about.markdown"
14+ , "index.markdown"
15+ , "tutorial1.markdown"
16+ , "tutorial2.markdown"
17+ ]
18+
19+ where render' = renderChain ["templates/default.html"] . createPagePath
examples/hakyll/images/lambda.pngnew file

Binary file not shown.

examples/hakyll/index.markdownnew file+29
@@ -0,0 +1,29 @@
1+---
2+title: Home
3+---
4+
5+## Overview
6+
7+Hakyll is a [Haskell](http://haskell.org) library for generating static sites.
8+It is written in a very configurable way and uses an
9+[xmonad](http://xmonad.org)-like DSL for configuration.
10+
11+## Why static site generators?
12+
13+- Static sites are extremely fast.
14+- You don't have to worry about security issues.
15+
16+## Features of Hakyll
17+
18+- Integration with [pandoc](http://johnmacfarlane.net/pandoc/) gives us markdown
19+ and TeX support, including syntax highlighting and other goodies.
20+- An easy templating system.
21+- Hakyll also features a simple http server for previewing your site.
22+
23+## Getting Started
24+
25+You can get the latest version from hackage using `cabal install hakyll`. A
26+look in the [tutorial](tutorial1.html) is highly recommended. There are a few
27+examples available in
28+[the github repo](http://github.com/jaspervdj/Hakyll/tree/master/examples/),
29+including this site.
examples/hakyll/templates/default.htmlnew file+44
@@ -0,0 +1,44 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5+ <head>
6+ <title>Hakyll - $title</title>
7+
8+ <!-- Stylesheets. -->
9+ <link rel="stylesheet" type="text/css" href="css/default.css" />
10+ <link rel="stylesheet" type="text/css" href="css/syntax.css" />
11+
12+ <!-- Metadata. -->
13+ <meta name="keywords" content="hakyll,static site generator,static,site,generator,haskell"/>
14+ <meta name="description" content="Hakyll - A Static Site Generator in Haskell."/>
15+ </head>
16+ <body>
17+ <div id="main">
18+ <div id="header">
19+ <img src="images/lambda.png" alt="lambda" />
20+ <h1>Hakyll - $title</h1>
21+ </div>
22+ <!-- Sidebar. -->
23+ <div id="sidebar">
24+ <h2>Navigation</h2>
25+ <div id="navigation">
26+ <a href="index.html">home</a>
27+ <a href="about.html">about</a>
28+ <a href="tutorial1.html">tutorial I</a>
29+ <a href="tutorial2.html">tutorial II</a>
30+ </div>
31+ </div>
32+
33+ <div id="content">
34+ $body
35+ </div>
36+
37+ <div id="footer">
38+ Site proudly generated by <a href="http://github.com/jaspervdj/hakyll">hakyll</a>.
39+ Hakyll and this site were written by <a href="http://jaspervdj.be/">Jasper Van der Jeugt</a>.
40+ </div>
41+ </div>
42+ </body>
43+
44+</html>
examples/hakyll/tutorial1.markdownnew file+202
@@ -0,0 +1,202 @@
1+---
2+title: Tutorial (Part I)
3+---
4+
5+## Getting started
6+
7+First, make sure you have Hakyll installed. The recommended way to do this is
8+through [hackage](http://hackage.haskell.org/) using
9+[cabal-install](http://www.haskell.org/haskellwiki/Cabal-Install). This
10+tutorial also assumes you have a basic knowledge of Haskell.
11+
12+~~~~~
13+[jasper@alice ~]$ cabal install hakyll
14+~~~~~
15+
16+## Building a simple static site
17+
18+As an example to get started with, we're going to develop a so called
19+"Brochure Site" for an imaginary company. The first step is to create
20+a directory for our new site.
21+
22+~~~~~
23+[jasper@alice Sites]$ mkdir brochure
24+[jasper@alice Sites]$ cd brochure/
25+[jasper@alice brochure]$
26+~~~~~
27+
28+I have a [zip file](examples/brochure.zip) with the files we need for this
29+tutorial available. Please unzip it in the brochure directory we just created.
30+We'll first have a look at what we're going to create (because we're curious
31+and all that).
32+
33+~~~~~
34+[jasper@alice brochure]$ ghc --make hakyll.hs
35+[1 of 1] Compiling Main ( hakyll.hs, hakyll.o )
36+Linking hakyll ...
37+[jasper@alice brochure]$ ./hakyll preview
38+Generating...
39+Starting hakyll server on port 8000...
40+~~~~~
41+
42+If you now point your browser at [localhost:8000](http://localhost:8000/) you
43+should see our simple brochure site.
44+
45+## hakyll.hs
46+
47+The main configuration file of a Hakyll site is traditionally called
48+`hakyll.hs`. It is nothing special, just a small Haskell program. There is no
49+magic going on.
50+
51+~~~~~{.haskell}
52+import Text.Hakyll (hakyll)
53+main = hakyll $ do
54+ putStrLn "I'm in your computer, generating your site!"
55+~~~~~
56+
57+Note how we wrap everyting in the `hakyll` function. This is useful because
58+it will generate a very nice main function.
59+
60+## Pages
61+
62+An important concept in Hakyll is Pages. Pages are text files that can be
63+written in markdown, html or TeX. Furthermore, they can also contain some
64+metadata. The metadata is placed in the file header and surrouded by `---`
65+lines. Each line should contain a `key: value` pair. Let's have a look at the
66+`about.markdown` page.
67+
68+~~~~~{.markdown}
69+---
70+title: About
71+---
72+Nullam imperdiet sodales orci vitae molestie.
73+Nunc quam orci, pharetra a rhoncus vitae,
74+eleifend id felis. Suspendisse potenti...
75+~~~~~
76+
77+This contains one `key: value` pair, namely `title: About`. The rest of the
78+file is treated as markdown by pandoc. If you want to know more about
79+markdown, I think [this](http://daringfireball.net/projects/markdown/syntax)
80+is a pretty good page.
81+
82+## Templates
83+
84+Another concept are the so-called templates. Templates are text files (usually
85+html files) containing a number of keys. The syntax for these keys is
86+`$identifier`. Our example site contains one template, namely
87+`templates/default.html`. Let's have a better look at that.
88+
89+~~~~~{.html}
90+<html>
91+ <head>
92+ <title>MyAweSomeCompany - $title</title>
93+ <link rel="stylesheet" type="text/css"
94+ href="css/default.css" />
95+ </head>
96+ <body>
97+ <h1>MyAweSomeCompany - $title</h1>
98+ <div id="navigation">
99+ <a href="index.html">Home</a>
100+ <a href="about.html">About</a>
101+ <a href="products.html">Products</a>
102+ </div>
103+
104+ $body
105+ </body>
106+</html>
107+~~~~~
108+
109+We can see how our `Page` would fit in. When we render the page we saw using
110+this template, `$title` would be replaced by `About`, and `$body` would be
111+replaced by the body of the about page. `body` is the traditional name for the
112+body of any page - that is the convention in Hakyll. Also note that in this
113+case, `$body` would be replaced by a chunk of html - the result of the
114+markdown-to-html conversion.
115+
116+## Putting it all together
117+
118+Now, we'll render the page using the `renderChain` function. This function
119+takes a list of templates and a renderable object. In our case, we only have
120+one template, and our renderable object is simply a `PagePath`.
121+
122+~~~~~{.haskell}
123+import Text.Hakyll (hakyll)
124+import Text.Render (renderChain)
125+import Text.Renderables (createPagePath)
126+main = hakyll $ do
127+ renderChain ["templates/default.html"]
128+ (createPagePath "about.markdown")
129+~~~~~
130+
131+Or, to render all our three pages:
132+
133+~~~~~{.haskell}
134+import Text.Hakyll (hakyll)
135+import Text.Render (renderChain)
136+import Text.Renderables (createPagePath)
137+main = hakyll $ do
138+ render "about.markdown"
139+ render "index.markdown"
140+ render "products.markdown"
141+ where render = renderChain ["templates/default.html"]
142+ . createPagePath
143+~~~~~
144+
145+This will create the following files:
146+
147+~~~~~
148+_site/about.html
149+_site/index.html
150+_site/products.html
151+~~~~~
152+
153+## CSS, images and other static files
154+
155+Now, we also have a css file we would like to have in the `_site` directory.
156+Static files can be rendered using the `static` function in Hakyll. We could
157+use:
158+
159+~~~~~{.haskell}
160+import Text.Hakyll (hakyll)
161+import Text.Render (static)
162+main = hakyll $ do
163+ static "css/default.css"
164+~~~~~
165+
166+This would work, but let's not forget that Hakyll also has css compression. If
167+we want to use that, we would use `css` instead of `static`.
168+
169+~~~~~{.haskell}
170+import Text.Hakyll (hakyll)
171+import Text.Render (css)
172+main = hakyll $ do
173+ css "css/default.css"
174+~~~~~
175+
176+If we were to create another css file, we would have to add a line to our
177+`hakyll.hs` configuration file. This is pretty stupid, because the whole
178+directory `css` contains only css files. That's why Hakyll has a `directory`
179+function, which will execute a given function on an entire directory. So,
180+our example would become:
181+
182+~~~~~{.haskell}
183+import Text.Hakyll (hakyll)
184+import Text.Render (css)
185+import Text.File (directory)
186+main = hakyll $ do
187+ directory css "css"
188+~~~~~
189+
190+## Deploying
191+
192+To setup your site, simply copy the contents of `_site` to your hosting provider
193+using your favorite piece of software.
194+
195+## That's it!
196+
197+Now you should fully understand our brochure site example. If you still have
198+questions, feel free to ask them on the
199+[google discussion group](http://groups.google.com/group/hakyll).
200+
201+If you feel comfortable with the basics, here is a next tutorial:
202+[building a simple blog](tutorial2.html).
examples/hakyll/tutorial2.markdownnew file+7
@@ -0,0 +1,7 @@
1+---
2+title: Tutorial (Part II)
3+---
4+
5+## Under construction
6+
7+Coming soon.