jekyll 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of jekyll might be problematic. Click here for more details.
- data/History.txt +4 -0
- data/README.textile +216 -35
- data/jekyll.gemspec +2 -2
- data/lib/jekyll.rb +1 -1
- data/lib/jekyll/post.rb +3 -4
- data/test/test_post.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/README.textile
CHANGED
@@ -1,46 +1,102 @@
|
|
1
1
|
h1. Jekyll
|
2
2
|
|
3
|
-
Jekyll is a simple, blog aware, static site generator. It takes a template
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
3
|
+
Jekyll is a simple, blog aware, static site generator. It takes a template
|
4
|
+
directory (representing the raw form of a website), runs it through Textile or
|
5
|
+
Markdown and Liquid converters, and spits out a complete, static website
|
6
|
+
suitable for serving with Apache or your favorite web server. Visit
|
7
|
+
"http://tom.preston-werner.com":http://tom.preston-werner.com to see an
|
8
|
+
example of a Jekyll generated blog.
|
9
|
+
|
10
|
+
To understand how this all works, open up my
|
11
|
+
"TPW":http://github.com/mojombo/tpw repo in a new browser window. I'll be
|
12
|
+
referencing the code there.
|
13
|
+
|
14
|
+
Take a look at
|
15
|
+
"index.html":http://github.com/mojombo/tpw/tree/master/index.html. This file
|
16
|
+
represents the homepage of the site. At the top of the file is a chunk of YAML
|
17
|
+
that contains metadata about the file. This data tells Jekyll what layout to
|
18
|
+
give the file, what the page's title should be, etc. In this case, I specify
|
19
|
+
that the "default" template should be used. You can find the layout files in
|
20
|
+
the "_layouts":http://github.com/mojombo/tpw/tree/master/_layouts directory.
|
21
|
+
If you open
|
22
|
+
"default.html":http://github.com/mojombo/tpw/tree/master/_layouts/default.html
|
23
|
+
you can see that the homepage is constructed by wrapping index.html with this
|
24
|
+
layout.
|
25
|
+
|
26
|
+
You'll also notice Liquid templating code in these files.
|
27
|
+
"Liquid":http://www.liquidmarkup.org/ is a simple, extensible templating
|
28
|
+
language that makes it easy to embed data in your templates. For my homepage I
|
29
|
+
wanted to have a list of all my blog posts. Jekyll hands me a Hash containing
|
30
|
+
various data about my site. A reverse chronological list of all my blog posts
|
31
|
+
can be found in <code>site.posts</code>. Each post, in turn, contains various
|
32
|
+
fields such as <code>title</code> and <code>date</code>.
|
33
|
+
|
34
|
+
Jekyll gets the list of blog posts by parsing the files in the
|
35
|
+
"_posts":http://github.com/mojombo/tpw/tree/master/_posts directory. Each
|
36
|
+
post's filename contains the publishing date and slug (what shows up in the
|
37
|
+
URL) that the final HTML file should have. Open up the file corresponding to a
|
38
|
+
blog post:
|
39
|
+
"2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
|
40
|
+
GitHub renders textile files by default, so to better understand the file,
|
41
|
+
click on the
|
42
|
+
"raw":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile?raw=true
|
43
|
+
view to see the original file. Here I've specified the <code>post</code>
|
44
|
+
layout. If you look at that file you'll see an example of a nested layout.
|
45
|
+
Layouts can contain other layouts allowing you a great deal of flexibility in
|
46
|
+
how pages are assembled. In my case I use a nested layout in order to show
|
47
|
+
related posts for each blog entry. The YAML also specifies the post's title
|
48
|
+
which is then embedded in the post's body via Liquid.
|
49
|
+
|
50
|
+
Posts are handled in a special way by Jekyll. The date you specify in the
|
51
|
+
filename is used to construct the URL in the generated site. The example post,
|
52
|
+
for instance, ends up at
|
53
|
+
<code>http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html</code>.
|
54
|
+
|
55
|
+
Files that do not reside in directories prefixed with an underscore are
|
56
|
+
mirrored into a corresponding directory structure in the generated site. If a
|
57
|
+
file does not have a YAML preface, it is not run through the Liquid
|
58
|
+
interpreter. Binary files are copied over unmodified.
|
59
|
+
|
60
|
+
Jekyll is still a very young project. I've only developed the exact
|
61
|
+
functionality that I've needed. As time goes on I'd like to see the project
|
62
|
+
mature and support additional features. If you end up using Jekyll for your
|
63
|
+
own blog, drop me a line and let me know what you'd like to see in future
|
64
|
+
versions. Better yet, fork the project over at GitHub and hack in the features
|
65
|
+
yourself!
|
22
66
|
|
23
67
|
h2. Example Proto-Site
|
24
68
|
|
25
69
|
My own personal site/blog is generated with Jekyll.
|
26
70
|
|
27
|
-
The proto-site repo
|
28
|
-
|
71
|
+
The proto-site repo
|
72
|
+
("http://github.com/mojombo/tpw":http://github.com/mojombo/tpw) is converted
|
73
|
+
into the actual site
|
74
|
+
("http://tom.preston-werner.com/":http://tom.preston-werner.com)
|
29
75
|
|
30
76
|
h2. Install
|
31
77
|
|
32
78
|
The best way to install Jekyll is via RubyGems:
|
33
79
|
|
34
|
-
$ sudo gem install jekyll
|
80
|
+
$ sudo gem install mojombo-jekyll -s http://gems.github.com/
|
35
81
|
|
36
82
|
h2. Run
|
37
83
|
|
38
84
|
$ cd /path/to/proto/site
|
39
85
|
$ jekyll
|
40
86
|
|
41
|
-
This will generate the site and place it in /path/to/proto/site/_site.
|
87
|
+
This will generate the site and place it in /path/to/proto/site/_site. If
|
88
|
+
you'd like the generated site placed somewhere else:
|
89
|
+
|
90
|
+
$ jekyll /path/to/place/generated/site
|
91
|
+
|
92
|
+
And if you don't want to be in the proto site root to run Jekyll:
|
93
|
+
|
94
|
+
$ jekyll /path/to/proto/site /path/to/place/generated/site
|
95
|
+
|
96
|
+
h2. Run Options
|
42
97
|
|
43
|
-
There is an autobuild feature that will regenerate your site if any of the
|
98
|
+
There is an autobuild feature that will regenerate your site if any of the
|
99
|
+
files change. The autobuild feature can be used on any of the invocations:
|
44
100
|
|
45
101
|
$ jekyll --auto
|
46
102
|
|
@@ -50,32 +106,157 @@ enable it (it may take some time to run if you have many posts):
|
|
50
106
|
|
51
107
|
$ jekyll --lsi
|
52
108
|
|
53
|
-
|
109
|
+
For static code highlighting, you can install Pygments (see below) and then
|
110
|
+
use that to make your code blocks look pretty. To activate Pygments support
|
111
|
+
during the conversion:
|
54
112
|
|
55
|
-
$ jekyll
|
113
|
+
$ jekyll --pygments
|
56
114
|
|
57
|
-
|
115
|
+
h2. Data
|
58
116
|
|
59
|
-
|
60
|
-
|
61
|
-
|
117
|
+
Jekyll traverses your site looking for files to process. Any files with YAML
|
118
|
+
front matter (see below) are subject to processing. For each of these files,
|
119
|
+
Jekyll makes a variety of data available to the pages via the Liquid
|
120
|
+
templating system. The following is a reference of the available data.
|
121
|
+
|
122
|
+
h3. Global
|
123
|
+
|
124
|
+
site
|
125
|
+
Sitewide information.
|
126
|
+
|
127
|
+
page
|
128
|
+
For Posts, this is the union of the data in the YAML front matter and the
|
129
|
+
computed data (such as URL and date). For regular pages, this is just the
|
130
|
+
YAML front matter.
|
131
|
+
|
132
|
+
content
|
133
|
+
In layout files, this contains the content of the subview(s). In Posts or
|
134
|
+
pages, this is undefined.
|
135
|
+
|
136
|
+
h3. Site
|
137
|
+
|
138
|
+
site.time
|
139
|
+
The current Time (when you run the jekyll command).
|
140
|
+
|
141
|
+
site.posts
|
142
|
+
A reverse chronological list of all Posts.
|
143
|
+
|
144
|
+
site.related_posts
|
145
|
+
If the page being processed is a Post, this contains a list of up to ten
|
146
|
+
related Posts. By default, these are low quality but fast to compute. For
|
147
|
+
high quality but slow to compute results, run the jekyll command with the
|
148
|
+
--lsi (latent semantic indexing) option.
|
149
|
+
|
150
|
+
h3. Post
|
151
|
+
|
152
|
+
post.title
|
153
|
+
The title of the Post.
|
154
|
+
|
155
|
+
post.url
|
156
|
+
The URL of the Post without the domain.
|
157
|
+
e.g. /2008/12/14/my-post.html
|
158
|
+
|
159
|
+
post.date
|
160
|
+
The Date assigned to the Post.
|
161
|
+
|
162
|
+
post.id
|
163
|
+
An identifier unique to the Post (useful in RSS feeds).
|
164
|
+
e.g. /2008/12/14/my-post
|
165
|
+
|
166
|
+
post.content
|
167
|
+
The content of the Post.
|
168
|
+
|
169
|
+
h2. YAML Front Matter
|
170
|
+
|
171
|
+
Any files that contain a YAML front matter block will be processed by Jekyll
|
172
|
+
as special files. The front matter must be the first thing in the file and
|
173
|
+
takes the form of:
|
174
|
+
|
175
|
+
<pre>
|
176
|
+
---
|
177
|
+
layout: post
|
178
|
+
title: Blogging Like a Hacker
|
179
|
+
---
|
180
|
+
</pre>
|
181
|
+
|
182
|
+
Between the triple-dashed lines, you can set predefined variables (see below
|
183
|
+
for a reference) or custom data of your own.
|
184
|
+
|
185
|
+
h3. Predefined Global Variables
|
186
|
+
|
187
|
+
layout
|
188
|
+
If set, this specifies the layout file to use. Use the layout file
|
189
|
+
name without file extension. Layout files must be placed in the
|
190
|
+
<code>_layouts</code> directory.
|
191
|
+
|
192
|
+
h3. Predefined Post Variables
|
193
|
+
|
194
|
+
permalink
|
195
|
+
If you need your processed URLs to be something other than the default
|
196
|
+
/year/month/day/title.html then you can set this variable and it will
|
197
|
+
be used as the final URL.
|
198
|
+
|
199
|
+
h3. Custom Variables
|
200
|
+
|
201
|
+
Any variables in the front matter that are not predefined are mixed into the
|
202
|
+
data that is sent to the Liquid templating engine during the conversion. For
|
203
|
+
instance, if you set a <code>title</code>, you can use that in your layout to
|
204
|
+
set the page title:
|
205
|
+
|
206
|
+
<pre>
|
207
|
+
<title>{{ page.title }}</title>
|
208
|
+
</pre>
|
62
209
|
|
63
210
|
h2. Filters, Tags, and Blocks
|
64
211
|
|
65
|
-
|
212
|
+
In addition to the built-in Liquid filters, tags, and blocks, Jekyll provides
|
213
|
+
some additional items that you can use in your site.
|
214
|
+
|
215
|
+
h3. Date to XML Schema (Filter)
|
216
|
+
|
217
|
+
Convert a Time into XML Schema format.
|
218
|
+
|
219
|
+
{{ site.time | date_to_xmlschema }}
|
220
|
+
|
221
|
+
becomes
|
222
|
+
|
223
|
+
2008-11-17T13:07:54-08:00
|
224
|
+
|
225
|
+
h3. XML Escape (Filter)
|
226
|
+
|
227
|
+
Escape some text for use in XML.
|
228
|
+
|
229
|
+
{{ post.content | xml_escape }}
|
230
|
+
|
231
|
+
h3. Number of Words (Filter)
|
232
|
+
|
233
|
+
Count the number of words in some text.
|
234
|
+
|
235
|
+
{{ post.content | number_of_words }}
|
236
|
+
|
237
|
+
becomes
|
238
|
+
|
239
|
+
1337
|
240
|
+
|
241
|
+
h3. Include (Tag)
|
66
242
|
|
67
243
|
If you have small page fragments that you wish to include in multiple places on your site, you can use the <code>include</code> tag.
|
68
244
|
|
69
245
|
<pre>{% include sig.textile %}</pre>
|
70
246
|
|
71
|
-
Jekyll expects all include files to be placed in an <code>_includes</code>
|
247
|
+
Jekyll expects all include files to be placed in an <code>_includes</code>
|
248
|
+
directory at the root of your source dir. So this will embed the contents of
|
249
|
+
<code>/path/to/proto/site/_includes/sig.textile</code> into the calling file.
|
72
250
|
|
73
|
-
h3. Code Highlighting Block
|
251
|
+
h3. Code Highlighting (Block)
|
74
252
|
|
75
253
|
Jekyll has built in support for syntax highlighting of over "100
|
76
254
|
languages":http://pygments.org/languages/ via "Pygments":http://pygments.org/.
|
77
|
-
In order to take advantage of this you'll need to have Pygments installed
|
78
|
-
the pygmentize binary must be in your path
|
255
|
+
In order to take advantage of this you'll need to have Pygments installed, and
|
256
|
+
the pygmentize binary must be in your path. When you run Jekyll, make sure you
|
257
|
+
run it with Pygments support:
|
258
|
+
|
259
|
+
$ jekyll --pygments
|
79
260
|
|
80
261
|
To denote a code block that should be highlighted:
|
81
262
|
|
data/jekyll.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{jekyll}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.2.0"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Tom Preston-Werner"]
|
7
|
-
s.date = %q{2008-12-
|
7
|
+
s.date = %q{2008-12-14}
|
8
8
|
s.default_executable = %q{jekyll}
|
9
9
|
s.email = ["tom@mojombo.com"]
|
10
10
|
s.executables = ["jekyll"]
|
data/lib/jekyll.rb
CHANGED
data/lib/jekyll/post.rb
CHANGED
@@ -74,8 +74,7 @@ module Jekyll
|
|
74
74
|
def permalink
|
75
75
|
self.data && self.data['permalink']
|
76
76
|
end
|
77
|
-
|
78
|
-
|
77
|
+
|
79
78
|
# The generated relative url of this post
|
80
79
|
# e.g. /2008/11/05/my-awesome-post.html
|
81
80
|
#
|
@@ -122,8 +121,8 @@ module Jekyll
|
|
122
121
|
def add_layout(layouts, site_payload)
|
123
122
|
# construct post payload
|
124
123
|
related = related_posts(site_payload["site"]["posts"])
|
125
|
-
payload = {"page" => self.to_liquid.merge(self.data)
|
126
|
-
do_layout(payload, layouts, site_payload)
|
124
|
+
payload = {"page" => self.to_liquid.merge(self.data)}
|
125
|
+
do_layout(payload, layouts, site_payload.merge({"site" => {"related_posts" => related}}))
|
127
126
|
end
|
128
127
|
|
129
128
|
# Write the generated post file to the destination directory.
|
data/test/test_post.rb
CHANGED
@@ -81,7 +81,7 @@ class TestPost < Test::Unit::TestCase
|
|
81
81
|
layouts = {"default" => Layout.new(File.join(File.dirname(__FILE__), *%w[source _layouts]), "simple.html")}
|
82
82
|
p.add_layout(layouts, {"site" => {"posts" => []}})
|
83
83
|
|
84
|
-
assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate:
|
84
|
+
assert_equal "<<< <p>url: /2008/11/21/complex.html<br />\ndate: #{Time.parse("2008-11-21")}<br />\nid: /2008/11/21/complex</p> >>>", p.output
|
85
85
|
end
|
86
86
|
|
87
87
|
def test_include
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-12-
|
12
|
+
date: 2008-12-14 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|