mattmatt-jekyll 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +91 -0
- data/README.textile +494 -0
- data/Rakefile +76 -0
- data/TODO +3 -0
- data/VERSION.yml +4 -0
- data/bin/jekyll +142 -0
- data/lib/jekyll.rb +64 -0
- data/lib/jekyll/albino.rb +116 -0
- data/lib/jekyll/converters/csv.rb +26 -0
- data/lib/jekyll/converters/mephisto.rb +79 -0
- data/lib/jekyll/converters/mt.rb +59 -0
- data/lib/jekyll/converters/textpattern.rb +50 -0
- data/lib/jekyll/converters/typo.rb +49 -0
- data/lib/jekyll/converters/wordpress.rb +54 -0
- data/lib/jekyll/convertible.rb +71 -0
- data/lib/jekyll/core_ext.rb +22 -0
- data/lib/jekyll/filters.rb +39 -0
- data/lib/jekyll/layout.rb +33 -0
- data/lib/jekyll/page.rb +64 -0
- data/lib/jekyll/post.rb +194 -0
- data/lib/jekyll/site.rb +173 -0
- data/lib/jekyll/tags/highlight.rb +53 -0
- data/lib/jekyll/tags/include.rb +31 -0
- data/test/helper.rb +14 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/simple.html +1 -0
- data/test/source/_posts/2008-02-02-not-published.textile +8 -0
- data/test/source/_posts/2008-02-02-published.textile +8 -0
- data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
- data/test/source/_posts/2008-11-21-complex.textile +8 -0
- data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
- data/test/source/_posts/2008-12-13-include.markdown +8 -0
- data/test/source/_posts/2009-01-27-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-category.textile +7 -0
- data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
- data/test/source/index.html +22 -0
- data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
- data/test/suite.rb +9 -0
- data/test/test_filters.rb +37 -0
- data/test/test_generated_site.rb +32 -0
- data/test/test_jekyll.rb +0 -0
- data/test/test_post.rb +144 -0
- data/test/test_site.rb +36 -0
- data/test/test_tags.rb +31 -0
- metadata +230 -0
data/History.txt
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
== 0.4.0 / 2009-02-03
|
2
|
+
* Major Enhancements
|
3
|
+
* Switch to Jeweler for packaging tasks
|
4
|
+
* Minor Enhancements
|
5
|
+
* Type importer [github.com/codeslinger]
|
6
|
+
* site.topics accessor [github.com/baz]
|
7
|
+
* Add array_to_sentence_string filter [github.com/mchung]
|
8
|
+
* Add a converter for textpattern [github.com/PerfectlyNormal]
|
9
|
+
* Add a working Mephisto / MySQL converter [github.com/ivey]
|
10
|
+
* Allowing .htaccess files to be copied over into the generated site [github.com/briandoll]
|
11
|
+
* Add option to not put file date in permalink URL [github.com/mreid]
|
12
|
+
* Add line number capabilities to highlight blocks [github.com/jcon]
|
13
|
+
* Bug Fixes
|
14
|
+
* Fix permalink behavior [github.com/cavalle]
|
15
|
+
* Fixed an issue with pygments, markdown, and newlines [github.com/zpinter]
|
16
|
+
* Ampersands need to be escaped [github.com/pufuwozu, github.com/ap]
|
17
|
+
* Test and fix the site.categories hash [github.com/zzot]
|
18
|
+
* Fix site payload available to files [github.com/matrix9180]
|
19
|
+
|
20
|
+
== 0.3.0 / 2008-12-24
|
21
|
+
* Major Enhancements
|
22
|
+
* Added --server option to start a simple WEBrick server on destination directory [github.com/johnreilly and github.com/mchung]
|
23
|
+
* Minor Enhancements
|
24
|
+
* Added post categories based on directories containing _posts [github.com/mreid]
|
25
|
+
* Added post topics based on directories underneath _posts
|
26
|
+
* Added new date filter that shows the full month name [github.com/mreid]
|
27
|
+
* Merge Post's YAML front matter into its to_liquid payload [github.com/remi]
|
28
|
+
* Restrict includes to regular files underneath _includes
|
29
|
+
* Bug Fixes
|
30
|
+
* Change YAML delimiter matcher so as to not chew up 2nd level markdown headers [github.com/mreid]
|
31
|
+
* Fix bug that meant page data (such as the date) was not available in templates [github.com/mreid]
|
32
|
+
* Properly reject directories in _layouts
|
33
|
+
|
34
|
+
== 0.2.1 / 2008-12-15
|
35
|
+
* Major Changes
|
36
|
+
* Use Maruku (pure Ruby) for Markdown by default [github.com/mreid]
|
37
|
+
* Allow use of RDiscount with --rdiscount flag
|
38
|
+
* Minor Enhancements
|
39
|
+
* Don't load directory_watcher unless it's needed [github.com/pjhyett]
|
40
|
+
|
41
|
+
== 0.2.0 / 2008-12-14
|
42
|
+
* Major Changes
|
43
|
+
* related_posts is now found in site.related_posts
|
44
|
+
|
45
|
+
== 0.1.6 / 2008-12-13
|
46
|
+
* Major Features
|
47
|
+
* Include files in _includes with {% include x.textile %}
|
48
|
+
|
49
|
+
== 0.1.5 / 2008-12-12
|
50
|
+
* Major Features
|
51
|
+
* Code highlighting with Pygments if --pygments is specified
|
52
|
+
* Disable true LSI by default, enable with --lsi
|
53
|
+
* Minor Enhancements
|
54
|
+
* Output informative message if RDiscount is not available [github.com/JackDanger]
|
55
|
+
* Bug Fixes
|
56
|
+
* Prevent Jekyll from picking up the output directory as a source [github.com/JackDanger]
|
57
|
+
* Skip related_posts when there is only one post [github.com/JackDanger]
|
58
|
+
|
59
|
+
== 0.1.4 / 2008-12-08
|
60
|
+
* Bug Fixes
|
61
|
+
* DATA does not work properly with rubygems
|
62
|
+
|
63
|
+
== 0.1.3 / 2008-12-06
|
64
|
+
* Major Features
|
65
|
+
* Markdown support [github.com/vanpelt]
|
66
|
+
* Mephisto and CSV converters [github.com/vanpelt]
|
67
|
+
* Code hilighting [github.com/vanpelt]
|
68
|
+
* Autobuild
|
69
|
+
* Bug Fixes
|
70
|
+
* Accept both \r\n and \n in YAML header [github.com/vanpelt]
|
71
|
+
|
72
|
+
== 0.1.2 / 2008-11-22
|
73
|
+
* Major Features
|
74
|
+
* Add a real "related posts" implementation using Classifier
|
75
|
+
* Command Line Changes
|
76
|
+
* Allow cli to be called with 0, 1, or 2 args intuiting dir paths
|
77
|
+
if they are omitted
|
78
|
+
|
79
|
+
== 0.1.1 / 2008-11-22
|
80
|
+
* Minor Additions
|
81
|
+
* Posts now support introspectional data e.g. {{ page.url }}
|
82
|
+
|
83
|
+
== 0.1.0 / 2008-11-05
|
84
|
+
* First release
|
85
|
+
* Converts posts written in Textile
|
86
|
+
* Converts regular site pages
|
87
|
+
* Simple copy of binary files
|
88
|
+
|
89
|
+
== 0.0.0 / 2008-10-19
|
90
|
+
* Birthday!
|
91
|
+
|
data/README.textile
ADDED
@@ -0,0 +1,494 @@
|
|
1
|
+
h1. Jekyll LOL
|
2
|
+
|
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
|
+
Some more changes...
|
11
|
+
|
12
|
+
To understand how this all works, open up my
|
13
|
+
"TPW":http://github.com/mojombo/tpw repo in a new browser window. I'll be
|
14
|
+
referencing the code there.
|
15
|
+
|
16
|
+
Take a look at
|
17
|
+
"index.html":http://github.com/mojombo/tpw/tree/master/index.html. This file
|
18
|
+
represents the homepage of the site. At the top of the file is a chunk of YAML
|
19
|
+
that contains metadata about the file. This data tells Jekyll what layout to
|
20
|
+
give the file, what the page's title should be, etc. In this case, I specify
|
21
|
+
that the "default" template should be used. You can find the layout files in
|
22
|
+
the "_layouts":http://github.com/mojombo/tpw/tree/master/_layouts directory.
|
23
|
+
If you open
|
24
|
+
"default.html":http://github.com/mojombo/tpw/tree/master/_layouts/default.html
|
25
|
+
you can see that the homepage is constructed by wrapping index.html with this
|
26
|
+
layout.
|
27
|
+
|
28
|
+
You'll also notice Liquid templating code in these files.
|
29
|
+
"Liquid":http://www.liquidmarkup.org/ is a simple, extensible templating
|
30
|
+
language that makes it easy to embed data in your templates. For my homepage I
|
31
|
+
wanted to have a list of all my blog posts. Jekyll hands me a Hash containing
|
32
|
+
various data about my site. A reverse chronological list of all my blog posts
|
33
|
+
can be found in <code>site.posts</code>. Each post, in turn, contains various
|
34
|
+
fields such as <code>title</code> and <code>date</code>.
|
35
|
+
|
36
|
+
Jekyll gets the list of blog posts by parsing the files in any
|
37
|
+
"_posts":http://github.com/mojombo/tpw/tree/master/_posts directory found in
|
38
|
+
subdirectories below the root.
|
39
|
+
Each post's filename contains (by default) the publishing date and slug (what shows up in the
|
40
|
+
URL) that the final HTML file should have. Open up the file corresponding to a
|
41
|
+
blog post:
|
42
|
+
"2008-11-17-blogging-like-a-hacker.textile":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile.
|
43
|
+
GitHub renders textile files by default, so to better understand the file,
|
44
|
+
click on the
|
45
|
+
"raw":http://github.com/mojombo/tpw/tree/master/_posts/2008-11-17-blogging-like-a-hacker.textile?raw=true
|
46
|
+
view to see the original file. Here I've specified the <code>post</code>
|
47
|
+
layout. If you look at that file you'll see an example of a nested layout.
|
48
|
+
Layouts can contain other layouts allowing you a great deal of flexibility in
|
49
|
+
how pages are assembled. In my case I use a nested layout in order to show
|
50
|
+
related posts for each blog entry. The YAML also specifies the post's title
|
51
|
+
which is then embedded in the post's body via Liquid.
|
52
|
+
|
53
|
+
Posts are handled in a special way by Jekyll. The date you specify in the
|
54
|
+
filename is used to construct the URL in the generated site. The example post,
|
55
|
+
for instance, ends up at
|
56
|
+
<code>http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html</code>.
|
57
|
+
|
58
|
+
Categories for posts are derived from the directory structure the posts were
|
59
|
+
found within. A post that appears in the directory foo/bar/_posts is placed in
|
60
|
+
the categories 'foo' and 'bar'. By selecting posts from particular categories
|
61
|
+
in your Liquid templates, you will be able to host multiple blogs within a
|
62
|
+
site.
|
63
|
+
|
64
|
+
Files that do not reside in directories prefixed with an underscore are
|
65
|
+
mirrored into a corresponding directory structure in the generated site. If a
|
66
|
+
file does not have a YAML preface, it is not run through the Liquid
|
67
|
+
interpreter. Binary files are copied over unmodified.
|
68
|
+
|
69
|
+
Jekyll is still a very young project. I've only developed the exact
|
70
|
+
functionality that I've needed. As time goes on I'd like to see the project
|
71
|
+
mature and support additional features. If you end up using Jekyll for your
|
72
|
+
own blog, drop me a line and let me know what you'd like to see in future
|
73
|
+
versions. Better yet, fork the project over at GitHub and hack in the features
|
74
|
+
yourself!
|
75
|
+
|
76
|
+
h2. Example Proto-Site
|
77
|
+
|
78
|
+
My own personal site/blog is generated with Jekyll.
|
79
|
+
|
80
|
+
The proto-site repo
|
81
|
+
("http://github.com/mojombo/tpw":http://github.com/mojombo/tpw) is converted
|
82
|
+
into the actual site
|
83
|
+
("http://tom.preston-werner.com/":http://tom.preston-werner.com)
|
84
|
+
|
85
|
+
h2. Install
|
86
|
+
|
87
|
+
The best way to install Jekyll is via RubyGems:
|
88
|
+
|
89
|
+
$ sudo gem install mojombo-jekyll -s http://gems.github.com/
|
90
|
+
|
91
|
+
Jekyll requires the gems `directory_watcher`, `liquid`, `open4`,
|
92
|
+
and `maruku` (for markdown support). These are automatically
|
93
|
+
installed by the gem install command.
|
94
|
+
|
95
|
+
Maruku comes with optional support for LaTeX to PNG rendering via
|
96
|
+
"blahtex":http://gva.noekeon.org/blahtexml/ (Version 0.6) which must be in
|
97
|
+
your $PATH along with `dvips`.
|
98
|
+
|
99
|
+
(NOTE: the version of maruku I am using is `remi-maruku` on GitHub as it
|
100
|
+
does not assume a fixed location for `dvips`.)
|
101
|
+
|
102
|
+
h2. Run
|
103
|
+
|
104
|
+
$ cd /path/to/proto/site
|
105
|
+
$ jekyll
|
106
|
+
|
107
|
+
This will generate the site and place it in /path/to/proto/site/_site. If
|
108
|
+
you'd like the generated site placed somewhere else:
|
109
|
+
|
110
|
+
$ jekyll /path/to/place/generated/site
|
111
|
+
|
112
|
+
And if you don't want to be in the proto site root to run Jekyll:
|
113
|
+
|
114
|
+
$ jekyll /path/to/proto/site /path/to/place/generated/site
|
115
|
+
|
116
|
+
h2. Run Options
|
117
|
+
|
118
|
+
There is an autobuild feature that will regenerate your site if any of the
|
119
|
+
files change. The autobuild feature can be used on any of the invocations:
|
120
|
+
|
121
|
+
$ jekyll --auto
|
122
|
+
|
123
|
+
By default, the "related posts" functionality will produce crappy results.
|
124
|
+
In order to get high quality results with a true LSI algorithm, you must
|
125
|
+
enable it (it may take some time to run if you have many posts):
|
126
|
+
|
127
|
+
$ jekyll --lsi
|
128
|
+
|
129
|
+
For static code highlighting, you can install Pygments (see below) and then
|
130
|
+
use that to make your code blocks look pretty. To activate Pygments support
|
131
|
+
during the conversion:
|
132
|
+
|
133
|
+
$ jekyll --pygments
|
134
|
+
|
135
|
+
By default, Jekyll uses "Maruku":http://maruku.rubyforge.org (pure Ruby) for
|
136
|
+
Markdown support. If you'd like to use RDiscount (faster, but requires
|
137
|
+
compilation), you must install it (gem install rdiscount) and then you can
|
138
|
+
have it used instead:
|
139
|
+
|
140
|
+
$ jekyll --rdiscount
|
141
|
+
|
142
|
+
As another alternative, just because to make it a hat trick, you can also
|
143
|
+
use BlueCloth (gem install bluecloth).
|
144
|
+
|
145
|
+
$ jekyll --bluecloth
|
146
|
+
|
147
|
+
When previewing complex sites locally, simply opening the site in a web
|
148
|
+
browser (using file://) can cause problems with links that are relative to
|
149
|
+
the site root (e.g., "/stylesheets/style.css"). To get around this, Jekyll
|
150
|
+
can launch a simple WEBrick server (works well in conjunction with --auto).
|
151
|
+
Default port is 4000:
|
152
|
+
|
153
|
+
$ jekyll --server [PORT]
|
154
|
+
|
155
|
+
By default, the permalink for each post begins with its date in 'YYYY/MM/DD'
|
156
|
+
format. If you do not wish to have the date appear in the URL of each post,
|
157
|
+
you can change the permalink style to 'none' so that only the 'slug' part of
|
158
|
+
the filename is used. For example, with the permalink style set to 'none' the
|
159
|
+
file '2009-01-01-happy-new-year.markdown' will have a permalink like
|
160
|
+
'http://yoursite.com/happy-new-year.html'. The date of the post will still be
|
161
|
+
read from the filename (and is required!) to be used elsewhere in Jekyll.
|
162
|
+
Also supported is the permalink format shortdate, which will use the YYYY/M/D
|
163
|
+
for days and months < 10.
|
164
|
+
Example usage:
|
165
|
+
|
166
|
+
$ jekyll --permalink none
|
167
|
+
|
168
|
+
h2. Data
|
169
|
+
|
170
|
+
Jekyll traverses your site looking for files to process. Any files with YAML
|
171
|
+
front matter (see below) are subject to processing. For each of these files,
|
172
|
+
Jekyll makes a variety of data available to the pages via the Liquid
|
173
|
+
templating system. The following is a reference of the available data.
|
174
|
+
|
175
|
+
h3. Global
|
176
|
+
|
177
|
+
site
|
178
|
+
Sitewide information.
|
179
|
+
|
180
|
+
page
|
181
|
+
For Posts, this is the union of the data in the YAML front matter and the
|
182
|
+
computed data (such as URL and date). For regular pages, this is just the
|
183
|
+
YAML front matter.
|
184
|
+
|
185
|
+
content
|
186
|
+
In layout files, this contains the content of the subview(s). In Posts or
|
187
|
+
Pages, this is undefined.
|
188
|
+
|
189
|
+
h3. Site
|
190
|
+
|
191
|
+
site.time
|
192
|
+
The current Time (when you run the jekyll command).
|
193
|
+
|
194
|
+
site.posts
|
195
|
+
A reverse chronological list of all Posts.
|
196
|
+
|
197
|
+
site.related_posts
|
198
|
+
If the page being processed is a Post, this contains a list of up to ten
|
199
|
+
related Posts. By default, these are low quality but fast to compute. For
|
200
|
+
high quality but slow to compute results, run the jekyll command with the
|
201
|
+
--lsi (latent semantic indexing) option.
|
202
|
+
|
203
|
+
site.categories.CATEGORY
|
204
|
+
The list of all Posts in category CATEGORY.
|
205
|
+
|
206
|
+
h3. Post
|
207
|
+
|
208
|
+
post.title
|
209
|
+
The title of the Post.
|
210
|
+
|
211
|
+
post.url
|
212
|
+
The URL of the Post without the domain.
|
213
|
+
e.g. /2008/12/14/my-post.html
|
214
|
+
|
215
|
+
post.date
|
216
|
+
The Date assigned to the Post.
|
217
|
+
|
218
|
+
post.id
|
219
|
+
An identifier unique to the Post (useful in RSS feeds).
|
220
|
+
e.g. /2008/12/14/my-post
|
221
|
+
|
222
|
+
post.categories
|
223
|
+
The list of categories to which this post belongs. Categories are
|
224
|
+
derived from the directory structure above the _posts directory. For
|
225
|
+
example, a post at /work/code/_posts/2008-12-24-closures.textile
|
226
|
+
would have this field set to ['work', 'code'].
|
227
|
+
|
228
|
+
post.topics
|
229
|
+
The list of topics for this Post. Topics are derived from the directory
|
230
|
+
structure beneath the _posts directory. For example, a post at
|
231
|
+
/_posts/music/metal/2008-12-24-metalocalypse.textile would have this field
|
232
|
+
set to ['music', 'metal'].
|
233
|
+
|
234
|
+
post.content
|
235
|
+
The content of the Post.
|
236
|
+
|
237
|
+
h2. YAML Front Matter
|
238
|
+
|
239
|
+
Any files that contain a YAML front matter block will be processed by Jekyll
|
240
|
+
as special files. The front matter must be the first thing in the file and
|
241
|
+
takes the form of:
|
242
|
+
|
243
|
+
<pre>
|
244
|
+
---
|
245
|
+
layout: post
|
246
|
+
title: Blogging Like a Hacker
|
247
|
+
---
|
248
|
+
</pre>
|
249
|
+
|
250
|
+
Between the triple-dashed lines, you can set predefined variables (see below
|
251
|
+
for a reference) or custom data of your own.
|
252
|
+
|
253
|
+
h3. Predefined Global Variables
|
254
|
+
|
255
|
+
layout
|
256
|
+
If set, this specifies the layout file to use. Use the layout file
|
257
|
+
name without file extension. Layout files must be placed in the
|
258
|
+
<code>_layouts</code> directory.
|
259
|
+
|
260
|
+
h3. Predefined Post Variables
|
261
|
+
|
262
|
+
permalink
|
263
|
+
If you need your processed URLs to be something other than the default
|
264
|
+
/year/month/day/title.html then you can set this variable and it will
|
265
|
+
be used as the final URL.
|
266
|
+
|
267
|
+
category/categories
|
268
|
+
Don't want to use the directory structure for categories, but you still
|
269
|
+
want to publish with categories? No problem, just add a category or
|
270
|
+
categories option in and it will get processed as if it was in a folder
|
271
|
+
for a category.
|
272
|
+
|
273
|
+
published
|
274
|
+
Set this to false if you don't want the post to show up in the _site
|
275
|
+
directory when jekyll runs.
|
276
|
+
|
277
|
+
h3. Custom Variables
|
278
|
+
|
279
|
+
Any variables in the front matter that are not predefined are mixed into the
|
280
|
+
data that is sent to the Liquid templating engine during the conversion. For
|
281
|
+
instance, if you set a <code>title</code>, you can use that in your layout to
|
282
|
+
set the page title:
|
283
|
+
|
284
|
+
<pre>
|
285
|
+
<title>{{ page.title }}</title>
|
286
|
+
</pre>
|
287
|
+
|
288
|
+
h2. Filters, Tags, and Blocks
|
289
|
+
|
290
|
+
In addition to the built-in Liquid filters, tags, and blocks, Jekyll provides
|
291
|
+
some additional items that you can use in your site.
|
292
|
+
|
293
|
+
h3. Date to XML Schema (Filter)
|
294
|
+
|
295
|
+
Convert a Time into XML Schema format.
|
296
|
+
|
297
|
+
{{ site.time | date_to_xmlschema }}
|
298
|
+
|
299
|
+
becomes
|
300
|
+
|
301
|
+
2008-11-17T13:07:54-08:00
|
302
|
+
|
303
|
+
h3. XML Escape (Filter)
|
304
|
+
|
305
|
+
Escape some text for use in XML.
|
306
|
+
|
307
|
+
{{ post.content | xml_escape }}
|
308
|
+
|
309
|
+
h3. Number of Words (Filter)
|
310
|
+
|
311
|
+
Count the number of words in some text.
|
312
|
+
|
313
|
+
{{ post.content | number_of_words }}
|
314
|
+
|
315
|
+
becomes
|
316
|
+
|
317
|
+
1337
|
318
|
+
|
319
|
+
h3. Array to Sentence String
|
320
|
+
|
321
|
+
Convert an array into a sentence.
|
322
|
+
|
323
|
+
{{ page.tags | array_to_sentence_string }}
|
324
|
+
|
325
|
+
becomes
|
326
|
+
|
327
|
+
foo, bar, and baz
|
328
|
+
|
329
|
+
h3. Include (Tag)
|
330
|
+
|
331
|
+
If you have small page fragments that you wish to include in multiple places
|
332
|
+
on your site, you can use the <code>include</code> tag.
|
333
|
+
|
334
|
+
<pre>{% include sig.textile %}</pre>
|
335
|
+
|
336
|
+
Jekyll expects all include files to be placed in an <code>_includes</code>
|
337
|
+
directory at the root of your source dir. So this will embed the contents of
|
338
|
+
<code>/path/to/proto/site/_includes/sig.textile</code> into the calling file.
|
339
|
+
|
340
|
+
h3. Code Highlighting (Block)
|
341
|
+
|
342
|
+
Jekyll has built in support for syntax highlighting of over "100
|
343
|
+
languages":http://pygments.org/languages/ via "Pygments":http://pygments.org/.
|
344
|
+
In order to take advantage of this you'll need to have Pygments installed, and
|
345
|
+
the pygmentize binary must be in your path. When you run Jekyll, make sure you
|
346
|
+
run it with Pygments support:
|
347
|
+
|
348
|
+
$ jekyll --pygments
|
349
|
+
|
350
|
+
To denote a code block that should be highlighted:
|
351
|
+
|
352
|
+
<pre>
|
353
|
+
{% highlight ruby %}
|
354
|
+
def foo
|
355
|
+
puts 'foo'
|
356
|
+
end
|
357
|
+
{% endhighlight %}
|
358
|
+
</pre>
|
359
|
+
|
360
|
+
The argument to <code>highlight</code> is the language identifier. To find the
|
361
|
+
appropriate identifier to use for your favorite language, look for the "short
|
362
|
+
name" on the "Lexers":http://pygments.org/docs/lexers/ page.
|
363
|
+
|
364
|
+
There is a second argument to <code>highlight</code> called
|
365
|
+
<code>linenos</code> that is optional. Including the <code>linenos</code>
|
366
|
+
argument will force the highlighted code to include line numbers. For
|
367
|
+
instance, the following code block would include line numbers next to each
|
368
|
+
line:
|
369
|
+
|
370
|
+
<pre>
|
371
|
+
{% highlight ruby linenos %}
|
372
|
+
def foo
|
373
|
+
puts 'foo'
|
374
|
+
end
|
375
|
+
{% endhighlight %}
|
376
|
+
</pre>
|
377
|
+
|
378
|
+
In order for the highlighting to show up, you'll need to include a
|
379
|
+
highlighting stylesheet. For an example stylesheet you can look at
|
380
|
+
"syntax.css":http://github.com/mojombo/tpw/tree/master/css/syntax.css. These
|
381
|
+
are the same styles as used by GitHub and you are free to use them for your
|
382
|
+
own site. If you use linenos, you might want to include an additional CSS
|
383
|
+
class definition for <code>lineno</code> in syntax.css to distinguish the line
|
384
|
+
numbers from the highlighted code.
|
385
|
+
|
386
|
+
h2. Categories
|
387
|
+
|
388
|
+
Posts are placed into categories based on the directory structure they are
|
389
|
+
found within (see above for an example). The categories can be accessed from
|
390
|
+
within a Liquid template as follows:
|
391
|
+
|
392
|
+
<pre>
|
393
|
+
{% for post in site.categories.foo %}
|
394
|
+
<li><span>{{ post.date | date_to_string }}</span> - {{ post.title }}</li>
|
395
|
+
{% endfor %}
|
396
|
+
</pre>
|
397
|
+
|
398
|
+
This would list all the posts in the category 'foo' by date and title.
|
399
|
+
|
400
|
+
The posts within each category are sorted in reverse chronological order.
|
401
|
+
|
402
|
+
h2. Blog migrations
|
403
|
+
|
404
|
+
h3. Movable Type
|
405
|
+
|
406
|
+
To migrate your MT blog into Jekyll, you'll need read access to the database.
|
407
|
+
The lib/jekyll/converters/mt.rb module provides a simple convert to create
|
408
|
+
.markdown files in a _posts directory based on the entries contained therein.
|
409
|
+
|
410
|
+
$ export DB=my_mtdb
|
411
|
+
$ export USER=dbuser
|
412
|
+
$ export PASS=dbpass
|
413
|
+
$ ruby -r './lib/jekyll/converters/mt' -e 'Jekyll::MT.process( \
|
414
|
+
"#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'
|
415
|
+
|
416
|
+
You may need to adjust the SQL query used to retrieve MT entries. Left alone,
|
417
|
+
it will attempt to pull all entries across all blogs regardless of status.
|
418
|
+
Please check the results and verify the posts before publishing.
|
419
|
+
|
420
|
+
h3. Typo 4+
|
421
|
+
|
422
|
+
To migrate your Typo blog into Jekyll, you'll need read access to the MySQL
|
423
|
+
database. The lib/jekyll/converters/typo.rb module provides a simple convert
|
424
|
+
to create .html, .textile, or .markdown files in a _posts directory based on
|
425
|
+
the entries contained therein.
|
426
|
+
|
427
|
+
$ export DB=my_typo_db
|
428
|
+
$ export USER=dbuser
|
429
|
+
$ export PASS=dbpass
|
430
|
+
$ ruby -r './lib/jekyll/converters/typo' -e 'Jekyll::Typo.process( \
|
431
|
+
"#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")'
|
432
|
+
|
433
|
+
You may need to adjust the code used to filter Typo entries. Left alone,
|
434
|
+
it will attempt to pull all entries across all blogs that were published.
|
435
|
+
This code also has only been tested with Typo version 4+. Previous versions
|
436
|
+
of Typo may not convert correctly. Please check the results and verify the
|
437
|
+
posts before publishing.
|
438
|
+
|
439
|
+
h3. TextPattern 4
|
440
|
+
|
441
|
+
To migrate your TextPattern blog into Jekyll, you'll need read access to the MySQL
|
442
|
+
database. The lib/jekyll/converters/textpattern.rb module provides a simple convert to create .textile files in a _posts directory based on
|
443
|
+
the entries contained therein.
|
444
|
+
|
445
|
+
$ ruby -r './lib/jekyll/converters/textpattern' -e 'Jekyll::TextPattern.process( \
|
446
|
+
"database_name", "username", "password", "hostname")'
|
447
|
+
|
448
|
+
The hostname defaults to _localhost_, all other variables are needed
|
449
|
+
You may need to adjust the code used to filter entries. Left alone,
|
450
|
+
it will attempt to pull all entries that are live or sticky.
|
451
|
+
|
452
|
+
h2. Contribute
|
453
|
+
|
454
|
+
If you'd like to hack on Jekyll, start by forking my repo on GitHub:
|
455
|
+
|
456
|
+
http://github.com/mojombo/jekyll
|
457
|
+
|
458
|
+
To get all of the dependencies, install the gem first. The best way to get
|
459
|
+
your changes merged back into core is as follows:
|
460
|
+
|
461
|
+
# Clone down your fork
|
462
|
+
# Create a topic branch to contain your change
|
463
|
+
# Hack away
|
464
|
+
# Add tests and make sure everything still passes by running `rake`
|
465
|
+
# If you are adding new functionality, document it in README.textile
|
466
|
+
# Do not change the version number, I will do that on my end
|
467
|
+
# If necessary, rebase your commits into logical chunks, without errors
|
468
|
+
# Push the branch up to GitHub
|
469
|
+
# Send me (mojombo) a pull request for your branch
|
470
|
+
|
471
|
+
h2. License
|
472
|
+
|
473
|
+
(The MIT License)
|
474
|
+
|
475
|
+
Copyright (c) 2008 Tom Preston-Werner
|
476
|
+
|
477
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
478
|
+
a copy of this software and associated documentation files (the
|
479
|
+
'Software'), to deal in the Software without restriction, including
|
480
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
481
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
482
|
+
permit persons to whom the Software is furnished to do so, subject to
|
483
|
+
the following conditions:
|
484
|
+
|
485
|
+
The above copyright notice and this permission notice shall be
|
486
|
+
included in all copies or substantial portions of the Software.
|
487
|
+
|
488
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
489
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
490
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
491
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
492
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
493
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
494
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|