codeslinger-jekyll 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -1
- data/README.textile +75 -5
- data/Rakefile +91 -0
- data/VERSION.yml +2 -2
- data/bin/jekyll +60 -56
- data/lib/jekyll.rb +48 -32
- data/lib/jekyll/albino.rb +9 -5
- data/lib/jekyll/converters/mephisto.rb +8 -8
- data/lib/jekyll/converters/mt.rb +8 -8
- data/lib/jekyll/converters/textpattern.rb +4 -4
- data/lib/jekyll/converters/typo.rb +8 -8
- data/lib/jekyll/converters/wordpress.rb +1 -2
- data/lib/jekyll/convertible.rb +33 -22
- data/lib/jekyll/core_ext.rb +5 -5
- data/lib/jekyll/filters.rb +10 -6
- data/lib/jekyll/layout.rb +9 -6
- data/lib/jekyll/page.rb +13 -10
- data/lib/jekyll/post.rb +58 -27
- data/lib/jekyll/site.rb +121 -50
- data/lib/jekyll/tags/highlight.rb +12 -9
- data/lib/jekyll/tags/include.rb +5 -5
- data/test/helper.rb +17 -6
- 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/2009-01-27-array-categories.textile +10 -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/test_filters.rb +31 -27
- data/test/test_generated_site.rb +32 -16
- data/test/test_post.rb +134 -102
- data/test/test_site.rb +52 -28
- data/test/test_tags.rb +17 -13
- metadata +19 -67
- data/test/test_jekyll.rb +0 -0
data/History.txt
CHANGED
@@ -1,4 +1,22 @@
|
|
1
|
-
==
|
1
|
+
== 0.5.0 / 2009-04-07
|
2
|
+
* Minor Enhancements
|
3
|
+
* Ability to set post categories via YAML [github.com/qrush]
|
4
|
+
* Ability to set prevent a post from publishing via YAML [github.com/qrush]
|
5
|
+
* Add textilize filter [github.com/willcodeforfoo]
|
6
|
+
* Add 'pretty' permalink style for wordpress-like urls [github.com/dysinger]
|
7
|
+
* Made it possible to enter categories from YAML as an array [github.com/Chrononaut]
|
8
|
+
* Ignore Emacs autosave files [github.com/Chrononaut]
|
9
|
+
* Bug Fixes
|
10
|
+
* Use block syntax of popen4 to ensure that subprocesses are properly disposed [github.com/jqr]
|
11
|
+
* Close open4 streams to prevent zombies [github.com/rtomayko]
|
12
|
+
* Only query required fields from the WP Database [github.com/ariejan]
|
13
|
+
* Prevent _posts from being copied to the destination directory [github.com/bdimcheff]
|
14
|
+
* Refactors
|
15
|
+
* Factored the filtering code into a method [github.com/Chrononaut]
|
16
|
+
* Fix tests and convert to Shoulda [github.com/qrush, github.com/technicalpickles]
|
17
|
+
* Add Cucumber acceptance test suite [github.com/qrush, github.com/technicalpickles]
|
18
|
+
|
19
|
+
== 0.4.1
|
2
20
|
* Minor Enhancements
|
3
21
|
* Changed date format on wordpress converter (zeropadding) [github.com/dysinger]
|
4
22
|
* Bug Fixes
|
data/README.textile
CHANGED
@@ -113,30 +113,40 @@ And if you don't want to be in the proto site root to run Jekyll:
|
|
113
113
|
|
114
114
|
h2. Run Options
|
115
115
|
|
116
|
+
h3. Autobuild
|
117
|
+
|
116
118
|
There is an autobuild feature that will regenerate your site if any of the
|
117
119
|
files change. The autobuild feature can be used on any of the invocations:
|
118
120
|
|
119
121
|
$ jekyll --auto
|
120
122
|
|
123
|
+
h3. Related Posts
|
124
|
+
|
121
125
|
By default, the "related posts" functionality will produce crappy results.
|
122
126
|
In order to get high quality results with a true LSI algorithm, you must
|
123
127
|
enable it (it may take some time to run if you have many posts):
|
124
128
|
|
125
129
|
$ jekyll --lsi
|
126
130
|
|
131
|
+
h3. Code Highlighting
|
132
|
+
|
127
133
|
For static code highlighting, you can install Pygments (see below) and then
|
128
134
|
use that to make your code blocks look pretty. To activate Pygments support
|
129
135
|
during the conversion:
|
130
136
|
|
131
137
|
$ jekyll --pygments
|
132
138
|
|
139
|
+
h3. Markdown Processor
|
140
|
+
|
133
141
|
By default, Jekyll uses "Maruku":http://maruku.rubyforge.org (pure Ruby) for
|
134
142
|
Markdown support. If you'd like to use RDiscount (faster, but requires
|
135
143
|
compilation), you must install it (gem install rdiscount) and then you can
|
136
144
|
have it used instead:
|
137
145
|
|
138
146
|
$ jekyll --rdiscount
|
139
|
-
|
147
|
+
|
148
|
+
h3. Local Server
|
149
|
+
|
140
150
|
When previewing complex sites locally, simply opening the site in a web
|
141
151
|
browser (using file://) can cause problems with links that are relative to
|
142
152
|
the site root (e.g., "/stylesheets/style.css"). To get around this, Jekyll
|
@@ -145,16 +155,61 @@ Default port is 4000:
|
|
145
155
|
|
146
156
|
$ jekyll --server [PORT]
|
147
157
|
|
158
|
+
h3. Permalink Style
|
159
|
+
|
148
160
|
By default, the permalink for each post begins with its date in 'YYYY/MM/DD'
|
149
|
-
format.
|
161
|
+
format.
|
162
|
+
|
163
|
+
If you do not wish to have the date appear in the URL of each post,
|
150
164
|
you can change the permalink style to 'none' so that only the 'slug' part of
|
151
165
|
the filename is used. For example, with the permalink style set to 'none' the
|
152
166
|
file '2009-01-01-happy-new-year.markdown' will have a permalink like
|
153
167
|
'http://yoursite.com/happy-new-year.html'. The date of the post will still be
|
154
168
|
read from the filename (and is required!) to be used elsewhere in Jekyll.
|
155
|
-
Example usage:
|
156
169
|
|
157
|
-
|
170
|
+
If you want WordPress-style pretty URLs that leave off the .html, you can
|
171
|
+
change the permalink style to 'pretty' and directories corresponding to the
|
172
|
+
date parts and post name will be made and an index.html will be placed in the
|
173
|
+
leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/.
|
174
|
+
|
175
|
+
$ jekyll --permalink [date|none|pretty]
|
176
|
+
|
177
|
+
h2. Configuration File
|
178
|
+
|
179
|
+
All of the options listed above can be specified on a site-by-site basis in
|
180
|
+
a '_config.yml' file at the root of the site's source. As the filename
|
181
|
+
suggests, the configuration is given in "YAML":http://www.yaml.org/. As
|
182
|
+
well as all of the options discussed in the last section, there are a few
|
183
|
+
additional options:
|
184
|
+
|
185
|
+
destination: [PATH] # Specify where the site should be rendered
|
186
|
+
markdown: [maruku|rdiscount] # Which markdown renderer to use?
|
187
|
+
|
188
|
+
maruku: # This is a YAML hash for Maruku settings
|
189
|
+
use_divs: [BOOLEAN] # Use the div element Maruku extension
|
190
|
+
use_tex: [BOOLEAN] # Use the LaTeX extension to Maruku
|
191
|
+
png_dir: [PATH] # Where should the math PNGs be stored?
|
192
|
+
png_url: [URL] # A relative URL for the PNGs
|
193
|
+
|
194
|
+
The default configuration is shown below as in YAML format:
|
195
|
+
|
196
|
+
destination: ./_site
|
197
|
+
auto: false
|
198
|
+
lsi: false
|
199
|
+
server_port: 4000
|
200
|
+
pygments: false
|
201
|
+
markdown: maruku
|
202
|
+
permalink: date
|
203
|
+
|
204
|
+
maruku:
|
205
|
+
use_tex: false
|
206
|
+
use_divs: false
|
207
|
+
png_dir: images/latex
|
208
|
+
png_url: /images/latex
|
209
|
+
|
210
|
+
Parameters set in a configuration file override the default values. Parameters
|
211
|
+
set using command line options override both the default values and those set
|
212
|
+
in a configuration file.
|
158
213
|
|
159
214
|
h2. Data
|
160
215
|
|
@@ -255,6 +310,15 @@ h3. Predefined Post Variables
|
|
255
310
|
/year/month/day/title.html then you can set this variable and it will
|
256
311
|
be used as the final URL.
|
257
312
|
|
313
|
+
published
|
314
|
+
Set to false if you don't want a post to show up when the site is
|
315
|
+
generated.
|
316
|
+
|
317
|
+
category/categories
|
318
|
+
Instead of placing posts inside of folders, you can specify one or more
|
319
|
+
categories that the post belongs to. When the site is generated the post
|
320
|
+
will act as though it had been set with these categories normally.
|
321
|
+
|
258
322
|
h3. Custom Variables
|
259
323
|
|
260
324
|
Any variables in the front matter that are not predefined are mixed into the
|
@@ -306,6 +370,12 @@ Convert an array into a sentence.
|
|
306
370
|
becomes
|
307
371
|
|
308
372
|
foo, bar, and baz
|
373
|
+
|
374
|
+
h3. Textilize
|
375
|
+
|
376
|
+
Convert a Textile-formatted string into HTML, formatted via RedCloth
|
377
|
+
|
378
|
+
{{ page.excerpt | textilize }}
|
309
379
|
|
310
380
|
h3. Include (Tag)
|
311
381
|
|
@@ -372,7 +442,7 @@ within a Liquid template as follows:
|
|
372
442
|
|
373
443
|
<pre>
|
374
444
|
{% for post in site.categories.foo %}
|
375
|
-
|
445
|
+
<li><span>{{ post.date | date_to_string }}</span> - {{ post.title }}</li>
|
376
446
|
{% endfor %}
|
377
447
|
</pre>
|
378
448
|
|
data/Rakefile
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
begin
|
6
|
+
gem 'jeweler', '>= 0.11.0'
|
7
|
+
require 'jeweler'
|
8
|
+
Jeweler::Tasks.new do |s|
|
9
|
+
s.name = "jekyll"
|
10
|
+
s.summary = %Q{Jekyll is a simple, blog aware, static site generator.}
|
11
|
+
s.email = "tom@mojombo.com"
|
12
|
+
s.homepage = "http://github.com/mojombo/jekyll"
|
13
|
+
s.description = "Jekyll is a simple, blog aware, static site generator."
|
14
|
+
s.authors = ["Tom Preston-Werner"]
|
15
|
+
s.rubyforge_project = "jekyll"
|
16
|
+
s.files.exclude 'test/dest'
|
17
|
+
s.test_files.exclude 'test/dest'
|
18
|
+
s.add_dependency('RedCloth', '>= 4.0.4')
|
19
|
+
s.add_dependency('liquid', '>= 1.9.0')
|
20
|
+
s.add_dependency('classifier', '>= 1.3.1')
|
21
|
+
s.add_dependency('maruku', '>= 0.5.9')
|
22
|
+
s.add_dependency('directory_watcher', '>= 1.1.1')
|
23
|
+
s.add_dependency('open4', '>= 0.9.6')
|
24
|
+
end
|
25
|
+
rescue LoadError
|
26
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler --version '>= 0.11.0'"
|
27
|
+
exit(1)
|
28
|
+
end
|
29
|
+
|
30
|
+
Rake::TestTask.new do |t|
|
31
|
+
t.libs << 'lib'
|
32
|
+
t.pattern = 'test/**/test_*.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
Rake::RDocTask.new do |rdoc|
|
37
|
+
rdoc.rdoc_dir = 'rdoc'
|
38
|
+
rdoc.title = 'jekyll'
|
39
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
40
|
+
rdoc.rdoc_files.include('README*')
|
41
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
42
|
+
end
|
43
|
+
|
44
|
+
begin
|
45
|
+
require 'rcov/rcovtask'
|
46
|
+
Rcov::RcovTask.new do |t|
|
47
|
+
t.libs << 'test'
|
48
|
+
t.test_files = FileList['test/**/test_*.rb']
|
49
|
+
t.verbose = true
|
50
|
+
end
|
51
|
+
rescue LoadError
|
52
|
+
end
|
53
|
+
|
54
|
+
task :default => [:test, :features]
|
55
|
+
|
56
|
+
# console
|
57
|
+
|
58
|
+
desc "Open an irb session preloaded with this library"
|
59
|
+
task :console do
|
60
|
+
sh "irb -rubygems -I lib -r jekyll.rb"
|
61
|
+
end
|
62
|
+
|
63
|
+
# converters
|
64
|
+
|
65
|
+
namespace :convert do
|
66
|
+
desc "Migrate from mephisto in the current directory"
|
67
|
+
task :mephisto do
|
68
|
+
sh %q(ruby -r './lib/jekyll/converters/mephisto' -e 'Jekyll::Mephisto.postgres(:database => "#{ENV["DB"]}")')
|
69
|
+
end
|
70
|
+
desc "Migrate from Movable Type in the current directory"
|
71
|
+
task :mt do
|
72
|
+
sh %q(ruby -r './lib/jekyll/converters/mt' -e 'Jekyll::MT.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
|
73
|
+
end
|
74
|
+
desc "Migrate from Typo in the current directory"
|
75
|
+
task :typo do
|
76
|
+
sh %q(ruby -r './lib/jekyll/converters/typo' -e 'Jekyll::Typo.process("#{ENV["DB"]}", "#{ENV["USER"]}", "#{ENV["PASS"]}")')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
begin
|
81
|
+
require 'cucumber/rake/task'
|
82
|
+
|
83
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
84
|
+
t.cucumber_opts = "--format pretty"
|
85
|
+
end
|
86
|
+
rescue LoadError
|
87
|
+
desc 'Cucumber rake task not available'
|
88
|
+
task :features do
|
89
|
+
abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
|
90
|
+
end
|
91
|
+
end
|
data/VERSION.yml
CHANGED
data/bin/jekyll
CHANGED
@@ -9,62 +9,78 @@ Basic Command Line Usage:
|
|
9
9
|
jekyll # . -> ./_site
|
10
10
|
jekyll <path to write generated site> # . -> <path>
|
11
11
|
jekyll <path to source> <path to write generated site> # <path> -> <path>
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
Configuration is read from '<source>/_config.yaml' but can be overriden
|
14
|
+
using the following options:
|
15
|
+
|
14
16
|
HELP
|
15
17
|
|
16
18
|
require 'optparse'
|
17
19
|
require 'jekyll'
|
18
20
|
|
21
|
+
exec = {}
|
19
22
|
options = {}
|
20
|
-
|
21
23
|
opts = OptionParser.new do |opts|
|
22
24
|
opts.banner = help
|
23
25
|
|
24
26
|
opts.on("--auto", "Auto-regenerate") do
|
25
|
-
options[
|
27
|
+
options['auto'] = true
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on("--no-auto", "No auto-regenerate") do
|
31
|
+
options['auto'] = false
|
26
32
|
end
|
27
|
-
|
33
|
+
|
28
34
|
opts.on("--server [PORT]", "Start web server (default port 4000)") do |port|
|
29
|
-
options[
|
30
|
-
options[
|
35
|
+
options['server'] = true
|
36
|
+
options['server_port'] = port unless port.nil?
|
31
37
|
end
|
32
|
-
|
38
|
+
|
33
39
|
opts.on("--lsi", "Use LSI for better related posts") do
|
34
|
-
|
40
|
+
options['lsi'] = true
|
35
41
|
end
|
36
|
-
|
42
|
+
|
37
43
|
opts.on("--pygments", "Use pygments to highlight code") do
|
38
|
-
|
44
|
+
options['pygments'] = true
|
39
45
|
end
|
40
|
-
|
46
|
+
|
41
47
|
opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
|
42
|
-
|
43
|
-
require 'rdiscount'
|
44
|
-
Jekyll.markdown_proc = Proc.new { |x| RDiscount.new(x).to_html }
|
45
|
-
puts 'Using rdiscount for Markdown'
|
46
|
-
rescue LoadError
|
47
|
-
puts 'You must have the rdiscount gem installed first'
|
48
|
-
end
|
48
|
+
options['markdown'] = 'rdiscount'
|
49
49
|
end
|
50
|
-
|
51
|
-
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
52
|
-
|
50
|
+
|
51
|
+
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
52
|
+
options['permalink'] = style unless style.nil?
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
opts.on("--version", "Display current version") do
|
56
56
|
puts "Jekyll " + Jekyll.version
|
57
57
|
exit 0
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
# Read command line options into `options` hash
|
61
62
|
opts.parse!
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
# Get source and destintation from command line
|
65
|
+
case ARGV.size
|
66
|
+
when 0
|
67
|
+
when 1
|
68
|
+
options['destination'] = ARGV[0]
|
69
|
+
when 2
|
70
|
+
options['source'] = ARGV[0]
|
71
|
+
options['destination'] = ARGV[1]
|
72
|
+
else
|
73
|
+
puts "Invalid options. Run `jekyll --help` for assistance."
|
74
|
+
exit(1)
|
66
75
|
end
|
67
76
|
|
77
|
+
options = Jekyll.configuration(options)
|
78
|
+
|
79
|
+
# Get source and destination directories (possibly set by config file)
|
80
|
+
source = options['source']
|
81
|
+
destination = options['destination']
|
82
|
+
|
83
|
+
# Files to watch
|
68
84
|
def globs(source)
|
69
85
|
Dir.chdir(source) do
|
70
86
|
dirs = Dir['*'].select { |x| File.directory?(x) }
|
@@ -74,63 +90,51 @@ def globs(source)
|
|
74
90
|
end
|
75
91
|
end
|
76
92
|
|
77
|
-
|
78
|
-
|
93
|
+
# Create the Site
|
94
|
+
site = Jekyll::Site.new(options)
|
79
95
|
|
80
|
-
|
81
|
-
|
82
|
-
source = '.'
|
83
|
-
destination = File.join('.', '_site')
|
84
|
-
when 1
|
85
|
-
source = '.'
|
86
|
-
destination = ARGV[0]
|
87
|
-
when 2
|
88
|
-
source = ARGV[0]
|
89
|
-
destination = ARGV[1]
|
90
|
-
else
|
91
|
-
puts "Invalid options. Run `jekyll --help` for assistance."
|
92
|
-
exit(1)
|
93
|
-
end
|
94
|
-
|
95
|
-
if options[:auto]
|
96
|
+
# Run the directory watcher for auto-generation, if required
|
97
|
+
if options['auto']
|
96
98
|
require 'directory_watcher'
|
97
99
|
|
98
100
|
puts "Auto-regenerating enabled: #{source} -> #{destination}"
|
99
|
-
|
101
|
+
|
100
102
|
dw = DirectoryWatcher.new(source)
|
101
103
|
dw.interval = 1
|
102
104
|
dw.glob = globs(source)
|
103
|
-
|
105
|
+
|
104
106
|
dw.add_observer do |*args|
|
105
107
|
t = Time.now.strftime("%Y-%m-%d %H:%M:%S")
|
106
108
|
puts "[#{t}] regeneration: #{args.size} files changed"
|
107
|
-
|
109
|
+
site.process
|
108
110
|
end
|
109
|
-
|
111
|
+
|
110
112
|
dw.start
|
111
|
-
|
112
|
-
unless options[
|
113
|
+
|
114
|
+
unless options['server']
|
113
115
|
loop { sleep 1000 }
|
114
116
|
end
|
115
117
|
else
|
116
|
-
|
117
|
-
|
118
|
+
puts "Building site: #{source} -> #{destination}"
|
119
|
+
site.process
|
120
|
+
puts "Successfully generated site: #{source} -> #{destination}"
|
118
121
|
end
|
119
122
|
|
120
|
-
if
|
123
|
+
# Run the server on the specified port, if required
|
124
|
+
if options['server']
|
121
125
|
require 'webrick'
|
122
126
|
include WEBrick
|
123
|
-
|
127
|
+
|
124
128
|
FileUtils.mkdir_p(destination)
|
125
129
|
|
126
130
|
s = HTTPServer.new(
|
127
|
-
:Port => options[
|
131
|
+
:Port => options['server_port'],
|
128
132
|
:DocumentRoot => destination
|
129
133
|
)
|
130
134
|
t = Thread.new {
|
131
135
|
s.start
|
132
136
|
}
|
133
|
-
|
137
|
+
|
134
138
|
trap("INT") { s.shutdown }
|
135
139
|
t.join()
|
136
140
|
end
|