henrik-jekyll 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +27 -16
- data/bin/jekyll +5 -5
- data/lib/jekyll.rb +2 -2
- data/lib/jekyll/albino.rb +3 -1
- data/lib/jekyll/convertible.rb +24 -5
- data/lib/jekyll/core_ext.rb +8 -1
- data/lib/jekyll/filters.rb +1 -26
- data/lib/jekyll/layout.rb +1 -0
- data/lib/jekyll/post.rb +72 -19
- data/lib/jekyll/site.rb +6 -7
- data/test/test_generated_site.rb +1 -1
- data/test/test_post.rb +119 -2
- data/test/test_tags.rb +35 -19
- metadata +2 -2
data/README.textile
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
h1. Jekyll
|
2
2
|
|
3
|
+
By Tom Preston-Werner, Nick Quaranto, and many awesome contributors!
|
4
|
+
|
5
|
+
h2. Description
|
6
|
+
|
3
7
|
Jekyll is a simple, blog aware, static site generator. It takes a template
|
4
8
|
directory (representing the raw form of a website), runs it through Textile or
|
5
9
|
Markdown and Liquid converters, and spits out a complete, static website
|
@@ -172,11 +176,23 @@ To transform ".haml":http://github.com/nex3/haml/tree/master files to HTML
|
|
172
176
|
|
173
177
|
$ jekyll --haml
|
174
178
|
|
175
|
-
Note that
|
176
|
-
|
179
|
+
Note that pages and posts must have a YAML metadata block at the top to be
|
180
|
+
converted. Layouts don't need to.
|
177
181
|
|
178
182
|
Haml content is intentionally not filtered, so you can use any Ruby code.
|
179
183
|
|
184
|
+
If you want to define methods you can call from your Haml files, create
|
185
|
+
a _helpers.rb file in the root of your blog and put the methods there,
|
186
|
+
inside a module named Helpers.
|
187
|
+
|
188
|
+
Jekyll provides some helpers out of the box:
|
189
|
+
|
190
|
+
h(string)
|
191
|
+
HTML entity-escapes the input string.
|
192
|
+
|
193
|
+
link_to(text, url)
|
194
|
+
Creates a link to the URL with the linked text (or markup).
|
195
|
+
|
180
196
|
h3. Local Server
|
181
197
|
|
182
198
|
When previewing complex sites locally, simply opening the site in a web
|
@@ -205,19 +221,15 @@ date parts and post name will be made and an index.html will be placed in the
|
|
205
221
|
leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/.
|
206
222
|
|
207
223
|
$ jekyll --permalink [date|none|pretty]
|
208
|
-
|
209
|
-
h3. Permalink Date Format
|
210
224
|
|
211
|
-
|
212
|
-
|
225
|
+
Another way to leave off the .html is to configure Apache with 'Options +MultiViews'.
|
226
|
+
Just link to pages without the extension (and without a trailing slash, like '/about').
|
227
|
+
Then tell Jekyll not to add '.html' when linking to blog posts, like so:
|
213
228
|
|
214
|
-
|
215
|
-
|
216
|
-
$ jekyll --permalink-date [format string]
|
229
|
+
$ jekyll --multiviews
|
217
230
|
|
218
|
-
|
219
|
-
|
220
|
-
$ jekyll --permalink-date %Y/%m
|
231
|
+
Note that this has no effect with '--permalink pretty' since that makes an index.html
|
232
|
+
file in a directory.
|
221
233
|
|
222
234
|
h2. Configuration File
|
223
235
|
|
@@ -269,9 +281,8 @@ h2. Data
|
|
269
281
|
|
270
282
|
Jekyll traverses your site looking for files to process. Any files with YAML
|
271
283
|
front matter (see below) are subject to processing. For each of these files,
|
272
|
-
Jekyll makes a variety of data available to the pages via Haml
|
273
|
-
|
274
|
-
available data.
|
284
|
+
Jekyll makes a variety of data available to the pages via Haml or the Liquid
|
285
|
+
Liquid templating system. The following is a reference of the available data.
|
275
286
|
|
276
287
|
h3. Global
|
277
288
|
|
@@ -610,7 +621,7 @@ your changes merged back into core is as follows:
|
|
610
621
|
# Do not change the version number, I will do that on my end
|
611
622
|
# If necessary, rebase your commits into logical chunks, without errors
|
612
623
|
# Push the branch up to GitHub
|
613
|
-
#
|
624
|
+
# Create an issue on mojombo/grit with a description and link to your branch
|
614
625
|
|
615
626
|
h2. License
|
616
627
|
|
data/bin/jekyll
CHANGED
@@ -10,7 +10,7 @@ Basic Command Line Usage:
|
|
10
10
|
jekyll <path to write generated site> # . -> <path>
|
11
11
|
jekyll <path to source> <path to write generated site> # <path> -> <path>
|
12
12
|
|
13
|
-
Configuration is read from '<source>/_config.
|
13
|
+
Configuration is read from '<source>/_config.yml' but can be overriden
|
14
14
|
using the following options:
|
15
15
|
|
16
16
|
HELP
|
@@ -55,9 +55,9 @@ opts = OptionParser.new do |opts|
|
|
55
55
|
opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
|
56
56
|
options['permalink'] = style unless style.nil?
|
57
57
|
end
|
58
|
-
|
59
|
-
opts.on("--
|
60
|
-
options['
|
58
|
+
|
59
|
+
opts.on("--multiviews", "Don't use .html in links since Apache has 'Options +MultiViews'") do |style|
|
60
|
+
options['multiviews'] = true
|
61
61
|
end
|
62
62
|
|
63
63
|
opts.on("--sass", "Use Sass from haml gem for CSS generation") do
|
@@ -153,4 +153,4 @@ if options['server']
|
|
153
153
|
|
154
154
|
trap("INT") { s.shutdown }
|
155
155
|
t.join()
|
156
|
-
end
|
156
|
+
end
|
data/lib/jekyll.rb
CHANGED
@@ -27,7 +27,7 @@ require 'jekyll/tags/include'
|
|
27
27
|
require 'jekyll/albino'
|
28
28
|
|
29
29
|
module Jekyll
|
30
|
-
# Default options. Overriden by values in _config.
|
30
|
+
# Default options. Overriden by values in _config.yml or command-line opts.
|
31
31
|
# Strings are used instead of symbols for YAML compatibility.
|
32
32
|
DEFAULTS = {
|
33
33
|
'auto' => false,
|
@@ -62,7 +62,7 @@ module Jekyll
|
|
62
62
|
# then, we need to know where to look for _config.yml
|
63
63
|
source = override['source'] || Jekyll::DEFAULTS['source']
|
64
64
|
|
65
|
-
# Get configuration from <source>/_config.
|
65
|
+
# Get configuration from <source>/_config.yml
|
66
66
|
config = {}
|
67
67
|
config_file = File.join(source, '_config.yml')
|
68
68
|
begin
|
data/lib/jekyll/albino.rb
CHANGED
@@ -71,7 +71,9 @@ class Albino
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def colorize(options = {})
|
74
|
-
execute
|
74
|
+
html = execute(@@bin + convert_options(options))
|
75
|
+
# Work around an RDiscount bug: http://gist.github.com/97682
|
76
|
+
html.to_s.sub(%r{</pre></div>\Z}, "</pre>\n</div>")
|
75
77
|
end
|
76
78
|
alias_method :to_s, :colorize
|
77
79
|
|
data/lib/jekyll/convertible.rb
CHANGED
@@ -59,6 +59,18 @@ module Jekyll
|
|
59
59
|
end
|
60
60
|
return 'unknown'
|
61
61
|
end
|
62
|
+
|
63
|
+
# Sets up a context for Haml and renders in it. The context has accessors
|
64
|
+
# matching the passed-in hash, e.g. "site", "page" and "content", and has
|
65
|
+
# helper modules mixed in.
|
66
|
+
#
|
67
|
+
# Returns String.
|
68
|
+
def render_haml_in_context(haml_engine, params={})
|
69
|
+
context = ClosedStruct.new(params)
|
70
|
+
context.extend(HamlHelpers)
|
71
|
+
context.extend(::Helpers) if defined?(::Helpers)
|
72
|
+
haml_engine.render(context)
|
73
|
+
end
|
62
74
|
|
63
75
|
# Add any necessary layouts to this convertible document
|
64
76
|
# +layouts+ is a Hash of {"name" => "layout"}
|
@@ -72,11 +84,10 @@ module Jekyll
|
|
72
84
|
payload["content_type"] = self.content_type
|
73
85
|
|
74
86
|
if self.content_type == "haml"
|
75
|
-
context = OpenStruct.new(:site => self.site, :page => OpenStruct.new(payload["page"]))
|
76
|
-
context.extend(HamlHelpers)
|
77
|
-
|
78
87
|
self.transform
|
79
|
-
self.content = self.content
|
88
|
+
self.content = render_haml_in_context(self.content,
|
89
|
+
:site => self.site,
|
90
|
+
:page => ClosedStruct.new(payload["page"]))
|
80
91
|
else
|
81
92
|
self.content = Liquid::Template.parse(self.content).render(payload, info)
|
82
93
|
self.transform
|
@@ -89,7 +100,15 @@ module Jekyll
|
|
89
100
|
layout = layouts[self.data["layout"]]
|
90
101
|
while layout
|
91
102
|
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
92
|
-
|
103
|
+
|
104
|
+
if site.config['haml'] && layout.content.is_a?(Haml::Engine)
|
105
|
+
self.output = render_haml_in_context(layout.content,
|
106
|
+
:site => ClosedStruct.new(payload["site"]),
|
107
|
+
:page => ClosedStruct.new(payload["page"]),
|
108
|
+
:content => payload["content"])
|
109
|
+
else
|
110
|
+
self.output = Liquid::Template.parse(layout.content).render(payload, info)
|
111
|
+
end
|
93
112
|
|
94
113
|
layout = layouts[layout.data["layout"]]
|
95
114
|
end
|
data/lib/jekyll/core_ext.rb
CHANGED
data/lib/jekyll/filters.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
|
3
1
|
module Jekyll
|
4
2
|
|
5
3
|
module Filters
|
@@ -19,41 +17,18 @@ module Jekyll
|
|
19
17
|
date.xmlschema
|
20
18
|
end
|
21
19
|
|
22
|
-
def time_to_string(date)
|
23
|
-
date.strftime("%d %b %Y, %H:%M")
|
24
|
-
end
|
25
|
-
|
26
20
|
def date_to_utc(date)
|
27
21
|
date.utc
|
28
22
|
end
|
29
23
|
|
30
|
-
def url_escape(input)
|
31
|
-
CGI.escape(input)
|
32
|
-
end
|
33
|
-
|
34
24
|
def xml_escape(input)
|
35
|
-
|
25
|
+
input.gsub("&", "&").gsub("<", "<").gsub(">", ">")
|
36
26
|
end
|
37
27
|
|
38
28
|
def number_of_words(input)
|
39
29
|
input.split.length
|
40
30
|
end
|
41
31
|
|
42
|
-
# Example:
|
43
|
-
#
|
44
|
-
# Posted in <span class="tags">{{ page.tags | tag_links: "example.com" }}</span>.
|
45
|
-
#
|
46
|
-
# Then style '.tags span { display: none; }' so the "tag:" bits don't show.
|
47
|
-
# You can provide 'tags' as a YAML array in the post's front matter.
|
48
|
-
def tag_links(array, domain)
|
49
|
-
links = array.map { |tag|
|
50
|
-
qs = %{site:#{domain} "tag: #{tag}"}
|
51
|
-
url = "http://www.google.com/search?q=#{url_escape qs}"
|
52
|
-
%{<a href="#{xml_escape url}"><span>tag:</span> #{xml_escape tag}</a>}
|
53
|
-
}
|
54
|
-
array_to_sentence_string(links)
|
55
|
-
end
|
56
|
-
|
57
32
|
def array_to_sentence_string(array)
|
58
33
|
connector = "and"
|
59
34
|
case array.length
|
data/lib/jekyll/layout.rb
CHANGED
data/lib/jekyll/post.rb
CHANGED
@@ -20,9 +20,12 @@ module Jekyll
|
|
20
20
|
name =~ MATCHER
|
21
21
|
end
|
22
22
|
|
23
|
-
attr_accessor :site
|
24
|
-
|
25
|
-
|
23
|
+
attr_accessor :site, :date, :slug, :ext, :topics, :tags, :published, :data, :content, :output
|
24
|
+
attr_writer :categories
|
25
|
+
|
26
|
+
def categories
|
27
|
+
@categories ||= []
|
28
|
+
end
|
26
29
|
|
27
30
|
# Initialize this Post instance.
|
28
31
|
# +site+ is the Site
|
@@ -97,16 +100,7 @@ module Jekyll
|
|
97
100
|
#
|
98
101
|
# Returns <String>
|
99
102
|
def dir
|
100
|
-
|
101
|
-
permalink.to_s.split("/")[0..-2].join("/") + '/'
|
102
|
-
else
|
103
|
-
prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
|
104
|
-
if [:date, :pretty].include?(self.site.permalink_style)
|
105
|
-
prefix + date.strftime(self.site.permalink_date || "/%Y/%m/%d/")
|
106
|
-
else
|
107
|
-
prefix + '/'
|
108
|
-
end
|
109
|
-
end
|
103
|
+
File.dirname(generated_path)
|
110
104
|
end
|
111
105
|
|
112
106
|
# The full path and filename of the post.
|
@@ -118,13 +112,43 @@ module Jekyll
|
|
118
112
|
self.data && self.data['permalink']
|
119
113
|
end
|
120
114
|
|
121
|
-
|
115
|
+
def template
|
116
|
+
case self.site.permalink_style
|
117
|
+
when :pretty
|
118
|
+
"/:categories/:year/:month/:day/:title"
|
119
|
+
when :none
|
120
|
+
"/:categories/:title.html"
|
121
|
+
when :date
|
122
|
+
"/:categories/:year/:month/:day/:title.html"
|
123
|
+
else
|
124
|
+
self.site.permalink_style.to_s
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# The generated relative path of this post
|
122
129
|
# e.g. /2008/11/05/my-awesome-post.html
|
123
130
|
#
|
124
131
|
# Returns <String>
|
132
|
+
def generated_path
|
133
|
+
return permalink if permalink
|
134
|
+
|
135
|
+
@generated_path ||= {
|
136
|
+
"year" => date.strftime("%Y"),
|
137
|
+
"month" => date.strftime("%m"),
|
138
|
+
"day" => date.strftime("%d"),
|
139
|
+
"title" => slug,
|
140
|
+
"categories" => categories.sort.join('/')
|
141
|
+
}.inject(template) { |result, token|
|
142
|
+
result.gsub(/:#{token.first}/, token.last)
|
143
|
+
}.gsub("//", "/")
|
144
|
+
end
|
145
|
+
|
146
|
+
# The generated relative url of this post
|
147
|
+
# e.g. /2008/11/05/my-awesome-post
|
148
|
+
#
|
149
|
+
# Returns <String>
|
125
150
|
def url
|
126
|
-
|
127
|
-
permalink || self.id + ext
|
151
|
+
site.config['multiviews'] ? generated_path.sub(/\.html$/, '') : generated_path
|
128
152
|
end
|
129
153
|
|
130
154
|
# The UID for this post (useful in feeds)
|
@@ -132,7 +156,7 @@ module Jekyll
|
|
132
156
|
#
|
133
157
|
# Returns <String>
|
134
158
|
def id
|
135
|
-
self.dir
|
159
|
+
File.join(self.dir, self.slug)
|
136
160
|
end
|
137
161
|
|
138
162
|
# The post title
|
@@ -155,6 +179,13 @@ module Jekyll
|
|
155
179
|
end
|
156
180
|
end
|
157
181
|
end
|
182
|
+
|
183
|
+
# The path to the post file.
|
184
|
+
#
|
185
|
+
# Returns <String>
|
186
|
+
def path
|
187
|
+
File.expand_path(File.join(@base, @name))
|
188
|
+
end
|
158
189
|
|
159
190
|
# Calculate related posts.
|
160
191
|
#
|
@@ -202,9 +233,9 @@ module Jekyll
|
|
202
233
|
def write(dest)
|
203
234
|
FileUtils.mkdir_p(File.join(dest, dir))
|
204
235
|
|
205
|
-
path = File.join(dest, self.
|
236
|
+
path = File.join(dest, self.generated_path)
|
206
237
|
|
207
|
-
if
|
238
|
+
if template[/\.html$/].nil?
|
208
239
|
FileUtils.mkdir_p(path)
|
209
240
|
path = File.join(path, "index.html")
|
210
241
|
end
|
@@ -238,15 +269,37 @@ module Jekyll
|
|
238
269
|
"url" => self.url,
|
239
270
|
"date" => self.date,
|
240
271
|
"id" => self.id,
|
272
|
+
"path" => self.path,
|
241
273
|
"topics" => self.topics,
|
242
274
|
"categories" => self.categories,
|
243
275
|
"tags" => self.tags,
|
276
|
+
"next" => self.next,
|
277
|
+
"previous" => self.previous,
|
244
278
|
"content" => self.content }.deep_merge(self.data)
|
245
279
|
end
|
246
280
|
|
247
281
|
def inspect
|
248
282
|
"<Post: #{self.id}>"
|
249
283
|
end
|
284
|
+
|
285
|
+
def next
|
286
|
+
pos = self.site.posts.index(self)
|
287
|
+
|
288
|
+
if pos && pos < self.site.posts.length-1
|
289
|
+
self.site.posts[pos+1]
|
290
|
+
else
|
291
|
+
nil
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def previous
|
296
|
+
pos = self.site.posts.index(self)
|
297
|
+
if pos && pos > 0
|
298
|
+
self.site.posts[pos-1]
|
299
|
+
else
|
300
|
+
nil
|
301
|
+
end
|
302
|
+
end
|
250
303
|
end
|
251
304
|
|
252
305
|
end
|
data/lib/jekyll/site.rb
CHANGED
@@ -2,7 +2,7 @@ module Jekyll
|
|
2
2
|
|
3
3
|
class Site
|
4
4
|
attr_accessor :config, :layouts, :posts, :collated_posts, :categories, :tags
|
5
|
-
attr_accessor :source, :dest, :lsi, :pygments, :pygments_cache, :permalink_style,
|
5
|
+
attr_accessor :source, :dest, :lsi, :pygments, :pygments_cache, :permalink_style,
|
6
6
|
:sass, :post_defaults
|
7
7
|
|
8
8
|
# Initialize the site
|
@@ -18,7 +18,6 @@ module Jekyll
|
|
18
18
|
self.pygments = config['pygments']
|
19
19
|
self.pygments_cache = config['pygments_cache']
|
20
20
|
self.permalink_style = config['permalink'].to_sym
|
21
|
-
self.permalink_date = config['permalink_date'] && config['permalink_date'].sub(%r{\A/?(.*)/?\Z}, '/\1/')
|
22
21
|
self.post_defaults = config['post_defaults'] || {}
|
23
22
|
|
24
23
|
self.reset
|
@@ -50,8 +49,9 @@ module Jekyll
|
|
50
49
|
if self.config['haml']
|
51
50
|
begin
|
52
51
|
require 'haml'
|
53
|
-
require 'ostruct'
|
54
52
|
require 'jekyll/haml_helpers'
|
53
|
+
helpers = File.join(source, '_helpers.rb')
|
54
|
+
require helpers if File.exist?(helpers)
|
55
55
|
puts 'Enabled Haml'
|
56
56
|
rescue LoadError
|
57
57
|
puts 'You must have the haml gem installed first'
|
@@ -165,15 +165,14 @@ module Jekyll
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
+
self.posts.sort!
|
169
|
+
|
168
170
|
# second pass renders each post now that full site payload is available
|
169
171
|
self.posts.each do |post|
|
170
172
|
post.render(self.layouts, site_payload)
|
171
|
-
end
|
172
|
-
|
173
|
-
self.posts.sort!
|
174
|
-
self.posts.each do |post|
|
175
173
|
self.collated_posts[post.date.year][post.date.month][post.date.day].unshift(post)
|
176
174
|
end
|
175
|
+
|
177
176
|
self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a} }
|
178
177
|
self.tags.values.map { |ps| ps.sort! { |a, b| b <=> a} }
|
179
178
|
rescue Errno::ENOENT => e
|
data/test/test_generated_site.rb
CHANGED
@@ -18,7 +18,7 @@ class TestGeneratedSite < Test::Unit::TestCase
|
|
18
18
|
end
|
19
19
|
|
20
20
|
should "render post.content" do
|
21
|
-
latest_post = Dir[source_dir('_posts', '*')].last
|
21
|
+
latest_post = Dir[source_dir('_posts', '*')].sort.last
|
22
22
|
post = Post.new(@site, source_dir, '', File.basename(latest_post))
|
23
23
|
post.transform
|
24
24
|
assert @index.include?(post.content)
|
data/test/test_post.rb
CHANGED
@@ -25,6 +25,7 @@ class TestPost < Test::Unit::TestCase
|
|
25
25
|
assert !Post.valid?("blah")
|
26
26
|
end
|
27
27
|
|
28
|
+
|
28
29
|
context "processing posts" do
|
29
30
|
setup do
|
30
31
|
@post = Post.allocate
|
@@ -41,6 +42,8 @@ class TestPost < Test::Unit::TestCase
|
|
41
42
|
assert_equal Time.parse("2008-10-19"), @post.date
|
42
43
|
assert_equal "foo-bar", @post.slug
|
43
44
|
assert_equal ".textile", @post.ext
|
45
|
+
assert_equal "/2008/10/19", @post.dir
|
46
|
+
assert_equal "/2008/10/19/foo-bar", @post.id
|
44
47
|
end
|
45
48
|
|
46
49
|
should "create url based on date and title" do
|
@@ -49,16 +52,94 @@ class TestPost < Test::Unit::TestCase
|
|
49
52
|
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
50
53
|
end
|
51
54
|
|
52
|
-
should "respect permalink" do
|
55
|
+
should "respect permalink in yaml front matter" do
|
53
56
|
file = "2008-12-03-permalinked-post.textile"
|
54
57
|
@post.process(file)
|
55
58
|
@post.read_yaml(@source, file)
|
56
59
|
|
57
60
|
assert_equal "my_category/permalinked-post", @post.permalink
|
58
|
-
assert_equal "my_category
|
61
|
+
assert_equal "my_category", @post.dir
|
59
62
|
assert_equal "my_category/permalinked-post", @post.url
|
60
63
|
end
|
61
64
|
|
65
|
+
context "with site wide permalink" do
|
66
|
+
setup do
|
67
|
+
@post.categories = []
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with unspecified (date) style" do
|
71
|
+
setup do
|
72
|
+
@post.process(@fake_file)
|
73
|
+
end
|
74
|
+
|
75
|
+
should "process the url correctly" do
|
76
|
+
assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
|
77
|
+
assert_equal "/2008/10/19/foo-bar.html", @post.url
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "with unspecified (date) style and a category" do
|
82
|
+
setup do
|
83
|
+
@post.categories << "beer"
|
84
|
+
@post.process(@fake_file)
|
85
|
+
end
|
86
|
+
|
87
|
+
should "process the url correctly" do
|
88
|
+
assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
|
89
|
+
assert_equal "/beer/2008/10/19/foo-bar.html", @post.url
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "with unspecified (date) style and categories" do
|
94
|
+
setup do
|
95
|
+
@post.categories << "food"
|
96
|
+
@post.categories << "beer"
|
97
|
+
@post.process(@fake_file)
|
98
|
+
end
|
99
|
+
|
100
|
+
should "process the url correctly" do
|
101
|
+
assert_equal "/:categories/:year/:month/:day/:title.html", @post.template
|
102
|
+
assert_equal "/beer/food/2008/10/19/foo-bar.html", @post.url
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "with none style" do
|
107
|
+
setup do
|
108
|
+
@post.site.permalink_style = :none
|
109
|
+
@post.process(@fake_file)
|
110
|
+
end
|
111
|
+
|
112
|
+
should "process the url correctly" do
|
113
|
+
assert_equal "/:categories/:title.html", @post.template
|
114
|
+
assert_equal "/foo-bar.html", @post.url
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context "with pretty style" do
|
119
|
+
setup do
|
120
|
+
@post.site.permalink_style = :pretty
|
121
|
+
@post.process(@fake_file)
|
122
|
+
end
|
123
|
+
|
124
|
+
should "process the url correctly" do
|
125
|
+
assert_equal "/:categories/:year/:month/:day/:title", @post.template
|
126
|
+
assert_equal "/2008/10/19/foo-bar", @post.url
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
context "with prefix style and no extension" do
|
131
|
+
setup do
|
132
|
+
@post.site.permalink_style = "/prefix/:title"
|
133
|
+
@post.process(@fake_file)
|
134
|
+
end
|
135
|
+
|
136
|
+
should "process the url correctly" do
|
137
|
+
assert_equal "/prefix/:title", @post.template
|
138
|
+
assert_equal "/prefix/foo-bar", @post.url
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
62
143
|
should "read yaml front-matter" do
|
63
144
|
@post.read_yaml(@source, @real_file)
|
64
145
|
|
@@ -75,6 +156,32 @@ class TestPost < Test::Unit::TestCase
|
|
75
156
|
end
|
76
157
|
end
|
77
158
|
|
159
|
+
context "when in a site" do
|
160
|
+
setup do
|
161
|
+
clear_dest
|
162
|
+
stub(Jekyll).configuration { Jekyll::DEFAULTS }
|
163
|
+
@site = Site.new(Jekyll.configuration)
|
164
|
+
@site.posts = [setup_post('2008-02-02-published.textile'),
|
165
|
+
setup_post('2009-01-27-categories.textile')]
|
166
|
+
end
|
167
|
+
|
168
|
+
should "have next post" do
|
169
|
+
assert_equal(@site.posts.last, @site.posts.first.next)
|
170
|
+
end
|
171
|
+
|
172
|
+
should "have previous post" do
|
173
|
+
assert_equal(@site.posts.first, @site.posts.last.previous)
|
174
|
+
end
|
175
|
+
|
176
|
+
should "not have previous post if first" do
|
177
|
+
assert_equal(nil, @site.posts.first.previous)
|
178
|
+
end
|
179
|
+
|
180
|
+
should "not have next post if last" do
|
181
|
+
assert_equal(nil, @site.posts.last.next)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
78
185
|
context "initializing posts" do
|
79
186
|
should "publish when published yaml is no specified" do
|
80
187
|
post = setup_post("2008-02-02-published.textile")
|
@@ -118,6 +225,16 @@ class TestPost < Test::Unit::TestCase
|
|
118
225
|
assert File.exists?(File.join(dest_dir, '2008', '10', '18', 'foo-bar.html'))
|
119
226
|
end
|
120
227
|
|
228
|
+
should "write properly without html extension" do
|
229
|
+
post = setup_post("2008-10-18-foo-bar.textile")
|
230
|
+
post.site.permalink_style = ":title"
|
231
|
+
do_render(post)
|
232
|
+
post.write(dest_dir)
|
233
|
+
|
234
|
+
assert File.directory?(dest_dir)
|
235
|
+
assert File.exists?(File.join(dest_dir, 'foo-bar', 'index.html'))
|
236
|
+
end
|
237
|
+
|
121
238
|
should "insert data" do
|
122
239
|
post = setup_post("2008-11-21-complex.textile")
|
123
240
|
do_render(post)
|
data/test/test_tags.rb
CHANGED
@@ -1,35 +1,51 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestTags < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
|
5
|
+
def create_post(code)
|
6
|
+
stub(Jekyll).configuration do
|
7
|
+
Jekyll::DEFAULTS.merge({'pygments' => true})
|
8
|
+
end
|
9
|
+
site = Site.new(Jekyll.configuration)
|
10
|
+
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
11
|
+
|
12
|
+
content = <<CONTENT
|
7
13
|
---
|
8
|
-
layout: post
|
9
14
|
title: This is a test
|
10
|
-
|
11
15
|
---
|
12
|
-
This document results in a markdown error with maruku
|
13
16
|
|
14
|
-
|
15
|
-
puts "hi"
|
17
|
+
This document results in a markdown error with maruku
|
16
18
|
|
17
|
-
|
19
|
+
{% highlight text %}
|
20
|
+
#{code}
|
18
21
|
{% endhighlight %}
|
19
|
-
|
20
22
|
CONTENT
|
23
|
+
|
24
|
+
@result = Liquid::Template.parse(content).render({}, info)
|
25
|
+
@result = site.markdown(@result)
|
26
|
+
end
|
27
|
+
|
28
|
+
context "post content has highlight tag" do
|
29
|
+
setup do
|
30
|
+
create_post("test")
|
31
|
+
end
|
32
|
+
|
33
|
+
should "not cause a markdown error" do
|
34
|
+
assert_no_match /markdown\-html\-error/, @result
|
35
|
+
end
|
36
|
+
|
37
|
+
should "render markdown with pygments line handling" do
|
38
|
+
assert_match %{<pre>test\n</pre>}, @result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context "post content has highlight tag with UTF character" do
|
43
|
+
setup do
|
44
|
+
create_post("Æ")
|
21
45
|
end
|
22
46
|
|
23
47
|
should "render markdown with pygments line handling" do
|
24
|
-
|
25
|
-
Jekyll::DEFAULTS.merge({'pygments' => true})
|
26
|
-
end
|
27
|
-
site = Site.new(Jekyll.configuration)
|
28
|
-
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
|
29
|
-
|
30
|
-
result = Liquid::Template.parse(@content).render({}, info)
|
31
|
-
result = site.markdown(result)
|
32
|
-
assert_no_match(/markdown\-html\-error/,result)
|
48
|
+
assert_match %{<pre>Æ\n</pre>}, @result
|
33
49
|
end
|
34
50
|
end
|
35
51
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: henrik-jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-04-
|
13
|
+
date: 2009-04-27 00:00:00 -07:00
|
14
14
|
default_executable: jekyll
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|