henrik-jekyll 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -53,6 +53,12 @@ filename is used to construct the URL in the generated site. The example post,
53
53
  for instance, ends up at
54
54
  <code>http://tom.preston-werner.com/2008/11/17/blogging-like-a-hacker.html</code>.
55
55
 
56
+ Jekyll also supports specifying the post time in the filename. The format is e.g.
57
+ '2009-04-13_23-45-my-post.html'. Note that the time is prefixed by an underscore,
58
+ not a dash, so post slugs starting with numbers won't be parsed incorrectly.
59
+ Times in the filename must be on a 24-hour clock. Times and dates are treated by
60
+ Jekyll as local time.
61
+
56
62
  Categories for posts are derived from the directory structure the posts were
57
63
  found within. A post that appears in the directory foo/bar/_posts is placed in
58
64
  the categories 'foo' and 'bar'. By selecting posts from particular categories
@@ -135,6 +141,12 @@ use that to make your code blocks look pretty. To activate Pygments support
135
141
  during the conversion:
136
142
 
137
143
  $ jekyll --pygments
144
+
145
+ Highlighting a blog post can take a second or two, and with a lot of posts,
146
+ it adds up. You can tell Jekyll to cache pygments output in a directory for
147
+ faster re-rendering:
148
+
149
+ $ jekyll --pygments-cache [PATH]
138
150
 
139
151
  h3. Markdown Processor
140
152
 
@@ -144,6 +156,26 @@ compilation), you must install it (gem install rdiscount) and then you can
144
156
  have it used instead:
145
157
 
146
158
  $ jekyll --rdiscount
159
+
160
+ h3. Sass
161
+
162
+ To transform all ".sass":http://github.com/nex3/haml/tree/master
163
+ files anywhere in your file tree to CSS (e.g. '/css/site.sass' will
164
+ generate '/css/site.css'):
165
+
166
+ $ jekyll --sass
167
+
168
+ h3. Haml
169
+
170
+ To transform ".haml":http://github.com/nex3/haml/tree/master files to HTML
171
+ (e.g. '/about.haml' will generate '/about.html'):
172
+
173
+ $ jekyll --haml
174
+
175
+ Note that files must have a YAML metadata block at the top to be converted,
176
+ and that Haml cannot currently be used for layouts -- only posts and pages.
177
+
178
+ Haml content is intentionally not filtered, so you can use any Ruby code.
147
179
 
148
180
  h3. Local Server
149
181
 
@@ -173,6 +205,19 @@ date parts and post name will be made and an index.html will be placed in the
173
205
  leaf directory resulting in URLs like 2008/11/17/blogging-like-a-hacker/.
174
206
 
175
207
  $ jekyll --permalink [date|none|pretty]
208
+
209
+ h3. Permalink Date Format
210
+
211
+ By default, unless you set the --permalink option to 'none', permalinks begin
212
+ with the date in a 'YYYY/MM/DD' format.
213
+
214
+ To customize this format, pass --permalink-date a strftime type format string.
215
+
216
+ $ jekyll --permalink-date [format string]
217
+
218
+ For example, to use only the year and month in the slug:
219
+
220
+ $ jekyll --permalink-date %Y/%m
176
221
 
177
222
  h2. Configuration File
178
223
 
@@ -211,12 +256,22 @@ Parameters set in a configuration file override the default values. Parameters
211
256
  set using command line options override both the default values and those set
212
257
  in a configuration file.
213
258
 
259
+ Additionally, you can set defaults for the post data blocks. For example, you
260
+ can set the default layout for posts, so you don't have to specify it in every
261
+ post:
262
+
263
+ post_defaults:
264
+ layout: post
265
+
266
+ Any values set in the actual post will override these defaults.
267
+
214
268
  h2. Data
215
269
 
216
270
  Jekyll traverses your site looking for files to process. Any files with YAML
217
271
  front matter (see below) are subject to processing. For each of these files,
218
- Jekyll makes a variety of data available to the pages via the Liquid
219
- templating system. The following is a reference of the available data.
272
+ Jekyll makes a variety of data available to the pages via Haml (regular pages
273
+ only) or the Liquid templating system. The following is a reference of the
274
+ available data.
220
275
 
221
276
  h3. Global
222
277
 
@@ -239,6 +294,21 @@ h3. Site
239
294
 
240
295
  site.posts
241
296
  A reverse chronological list of all Posts.
297
+
298
+ site.collated_posts
299
+ A nested hash by year, then month number, then day, then a list of Posts.
300
+ Suitable for post archives. You probably need to show these with Haml
301
+ since Liquid is too limited. For example:
302
+ - site.collated_posts.sort.reverse.each do |year,months|
303
+ %h2= year
304
+ - months.sort.reverse.each do |month,days|
305
+ %h3= Date::MONTHNAMES[month]
306
+ - days.sort.reverse.each do |day,posts|
307
+ %ol
308
+ - posts.each do |post|
309
+ %li
310
+ %strong= "#{day}:"
311
+ = link_to(h(post.title), post.url)
242
312
 
243
313
  site.related_posts
244
314
  If the page being processed is a Post, this contains a list of up to ten
@@ -249,6 +319,9 @@ h3. Site
249
319
  site.categories.CATEGORY
250
320
  The list of all Posts in category CATEGORY.
251
321
 
322
+ site.tags.TAG
323
+ The list of all Posts tagged TAG.
324
+
252
325
  h3. Post
253
326
 
254
327
  post.title
@@ -259,7 +332,7 @@ h3. Post
259
332
  e.g. /2008/12/14/my-post.html
260
333
 
261
334
  post.date
262
- The Date assigned to the Post.
335
+ The Date (actually a Time object) assigned to the Post.
263
336
 
264
337
  post.id
265
338
  An identifier unique to the Post (useful in RSS feeds).
@@ -277,6 +350,10 @@ h3. Post
277
350
  /_posts/music/metal/2008-12-24-metalocalypse.textile would have this field
278
351
  set to ['music', 'metal'].
279
352
 
353
+ post.tags
354
+ The list of tags on this post. Tags are much like topics, but can only be
355
+ specified in the YAML part of a post, and are not reflected in the URL.
356
+
280
357
  post.content
281
358
  The content of the Post.
282
359
 
@@ -302,6 +379,9 @@ h3. Predefined Global Variables
302
379
  If set, this specifies the layout file to use. Use the layout file
303
380
  name without file extension. Layout files must be placed in the
304
381
  <code>_layouts</code> directory.
382
+
383
+ A default layout for posts can be set in the configuration file.
384
+ See above.
305
385
 
306
386
  h3. Predefined Post Variables
307
387
 
@@ -313,12 +393,21 @@ h3. Predefined Post Variables
313
393
  published
314
394
  Set to false if you don't want a post to show up when the site is
315
395
  generated.
396
+
397
+ time
398
+ If you want posts to have a time, you can set this to e.g. '23:45' or
399
+ '11:45 pm'. This overrides any time specified in the filename like
400
+ '2009-04-12_23-44-my-post.html'. Note that you must quote the time:
401
+ time: "23:45"
316
402
 
317
403
  category/categories
318
404
  Instead of placing posts inside of folders, you can specify one or more
319
405
  categories that the post belongs to. When the site is generated the post
320
406
  will act as though it had been set with these categories normally.
321
407
 
408
+ tags
409
+ Similar to categories and topics but not reflected in the URL.
410
+
322
411
  h3. Custom Variables
323
412
 
324
413
  Any variables in the front matter that are not predefined are mixed into the
@@ -450,6 +539,10 @@ This would list all the posts in the category 'foo' by date and title.
450
539
 
451
540
  The posts within each category are sorted in reverse chronological order.
452
541
 
542
+ h2. Tags
543
+
544
+ Tags are like categories or topics but not reflected in the URL.
545
+
453
546
  h2. Blog migrations
454
547
 
455
548
  h3. Movable Type
data/bin/jekyll CHANGED
@@ -43,6 +43,10 @@ opts = OptionParser.new do |opts|
43
43
  opts.on("--pygments", "Use pygments to highlight code") do
44
44
  options['pygments'] = true
45
45
  end
46
+
47
+ opts.on("--pygments-cache", "Path to cache pygments output in, for faster re-rendering") do |path|
48
+ options['pygments_cache'] = path
49
+ end
46
50
 
47
51
  opts.on("--rdiscount", "Use rdiscount gem for Markdown") do
48
52
  options['markdown'] = 'rdiscount'
@@ -51,7 +55,19 @@ opts = OptionParser.new do |opts|
51
55
  opts.on("--permalink [TYPE]", "Use 'date' (default) for YYYY/MM/DD") do |style|
52
56
  options['permalink'] = style unless style.nil?
53
57
  end
58
+
59
+ opts.on("--permalink-date [FORMAT]", 'A strftime type format string. No times. (default format %Y/%m/%d)') do |format|
60
+ options['permalink_date'] = format unless format.nil?
61
+ end
54
62
 
63
+ opts.on("--sass", "Use Sass from haml gem for CSS generation") do
64
+ options['sass'] = true
65
+ end
66
+
67
+ opts.on("--haml", "Enable using Haml for posts and pages") do
68
+ options['haml'] = true
69
+ end
70
+
55
71
  opts.on("--version", "Display current version") do
56
72
  puts "Jekyll " + Jekyll.version
57
73
  exit 0
data/lib/jekyll.rb CHANGED
@@ -28,7 +28,7 @@ require 'jekyll/albino'
28
28
 
29
29
  module Jekyll
30
30
  # Default options. Overriden by values in _config.yaml or command-line opts.
31
- # (Strings rather symbols used for compatability with YAML)
31
+ # Strings are used instead of symbols for YAML compatibility.
32
32
  DEFAULTS = {
33
33
  'auto' => false,
34
34
  'server' => false,
@@ -39,6 +39,7 @@ module Jekyll
39
39
 
40
40
  'lsi' => false,
41
41
  'pygments' => false,
42
+ 'sass' => false,
42
43
  'markdown' => 'maruku',
43
44
  'permalink' => 'date',
44
45
 
data/lib/jekyll/albino.rb CHANGED
@@ -56,7 +56,7 @@ class Albino
56
56
 
57
57
  def initialize(target, lexer = :text, format = :html)
58
58
  @target = File.exists?(target) ? File.read(target) : target rescue target
59
- @options = { :l => lexer, :f => format }
59
+ @options = { :l => lexer, :f => format, :O => 'encoding=utf-8' }
60
60
  end
61
61
 
62
62
  def execute(command)
@@ -21,7 +21,8 @@ module Jekyll
21
21
  if self.content =~ /^(---\s*\n.*?)\n---\s*\n/m
22
22
  self.content = self.content[($1.size + 5)..-1]
23
23
 
24
- self.data = YAML.load($1)
24
+ self.data ||= {}
25
+ self.data = self.data.merge(YAML.load($1))
25
26
  end
26
27
  end
27
28
 
@@ -36,6 +37,10 @@ module Jekyll
36
37
  when 'markdown'
37
38
  self.ext = ".html"
38
39
  self.content = self.site.markdown(self.content)
40
+ when 'haml'
41
+ self.ext = ".html"
42
+ # Actually rendered in do_layout.
43
+ self.content = Haml::Engine.new(self.content, :attr_wrapper => %{"})
39
44
  end
40
45
  end
41
46
 
@@ -49,6 +54,8 @@ module Jekyll
49
54
  return 'textile'
50
55
  when /markdown/i, /mkdn/i, /md/i
51
56
  return 'markdown'
57
+ when /haml/i
58
+ return 'haml'
52
59
  end
53
60
  return 'unknown'
54
61
  end
@@ -63,8 +70,17 @@ module Jekyll
63
70
 
64
71
  # render and transform content (this becomes the final content of the object)
65
72
  payload["content_type"] = self.content_type
66
- self.content = Liquid::Template.parse(self.content).render(payload, info)
67
- self.transform
73
+
74
+ if self.content_type == "haml"
75
+ context = OpenStruct.new(:site => self.site, :page => OpenStruct.new(payload["page"]))
76
+ context.extend(HamlHelpers)
77
+
78
+ self.transform
79
+ self.content = self.content.render(context)
80
+ else
81
+ self.content = Liquid::Template.parse(self.content).render(payload, info)
82
+ self.transform
83
+ end
68
84
 
69
85
  # output keeps track of what will finally be written
70
86
  self.output = self.content
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+
1
3
  module Jekyll
2
4
 
3
5
  module Filters
@@ -17,14 +19,41 @@ module Jekyll
17
19
  date.xmlschema
18
20
  end
19
21
 
22
+ def time_to_string(date)
23
+ date.strftime("%d %b %Y, %H:%M")
24
+ end
25
+
26
+ def date_to_utc(date)
27
+ date.utc
28
+ end
29
+
30
+ def url_escape(input)
31
+ CGI.escape(input)
32
+ end
33
+
20
34
  def xml_escape(input)
21
- input.gsub("&", "&amp;").gsub("<", "&lt;").gsub(">", "&gt;")
35
+ CGI.escapeHTML(input)
22
36
  end
23
37
 
24
38
  def number_of_words(input)
25
39
  input.split.length
26
40
  end
27
41
 
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
+
28
57
  def array_to_sentence_string(array)
29
58
  connector = "and"
30
59
  case array.length
@@ -0,0 +1,15 @@
1
+ require 'cgi'
2
+
3
+ module Jekyll
4
+ module HamlHelpers
5
+
6
+ def h(text)
7
+ CGI.escapeHTML(text)
8
+ end
9
+
10
+ def link_to(text, url)
11
+ %{<a href="#{h url}">#{text}</a>}
12
+ end
13
+
14
+ end
15
+ end
data/lib/jekyll/post.rb CHANGED
@@ -8,10 +8,12 @@ module Jekyll
8
8
  attr_accessor :lsi
9
9
  end
10
10
 
11
- MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/
11
+ MATCHER = /^(.+\/)*(\d+-\d+-\d+(?:_\d+-\d+)?)-(.*)(\.[^.]+)$/
12
12
 
13
13
  # Post name validator. Post filenames must be like:
14
14
  # 2008-11-05-my-awesome-post.textile
15
+ # or:
16
+ # 2008-11-05_12-45-my-awesome-post.textile
15
17
  #
16
18
  # Returns <Bool>
17
19
  def self.valid?(name)
@@ -19,7 +21,7 @@ module Jekyll
19
21
  end
20
22
 
21
23
  attr_accessor :site
22
- attr_accessor :date, :slug, :ext, :categories, :topics, :published
24
+ attr_accessor :date, :slug, :ext, :categories, :tags, :topics, :published
23
25
  attr_accessor :data, :content, :output
24
26
 
25
27
  # Initialize this Post instance.
@@ -27,6 +29,7 @@ module Jekyll
27
29
  # +base+ is the String path to the dir containing the post file
28
30
  # +name+ is the String filename of the post file
29
31
  # +categories+ is an Array of Strings for the categories for this post
32
+ # +tags+ is an Array of Strings for the tags for this post
30
33
  #
31
34
  # Returns <Post>
32
35
  def initialize(site, source, dir, name)
@@ -40,8 +43,11 @@ module Jekyll
40
43
  self.topics = parts.size > 1 ? parts[0..-2] : []
41
44
 
42
45
  self.process(name)
46
+ self.data = self.site.post_defaults.dup
43
47
  self.read_yaml(@base, name)
44
48
 
49
+ extract_title_from_first_header_or_slug
50
+
45
51
  if self.data.has_key?('published') && self.data['published'] == false
46
52
  self.published = false
47
53
  else
@@ -61,6 +67,8 @@ module Jekyll
61
67
  end
62
68
  end
63
69
  end
70
+
71
+ self.tags = self.data['tags'] || []
64
72
  end
65
73
 
66
74
  # Spaceship is based on Post#date
@@ -76,6 +84,7 @@ module Jekyll
76
84
  # Returns nothing
77
85
  def process(name)
78
86
  m, cats, date, slug, ext = *name.match(MATCHER)
87
+ date = date.sub(/_(\d+)-(\d+)\Z/, ' \1:\2') # Make optional time part parsable.
79
88
  self.date = Time.parse(date)
80
89
  self.slug = slug
81
90
  self.ext = ext
@@ -93,7 +102,7 @@ module Jekyll
93
102
  else
94
103
  prefix = self.categories.empty? ? '' : '/' + self.categories.join('/')
95
104
  if [:date, :pretty].include?(self.site.permalink_style)
96
- prefix + date.strftime("/%Y/%m/%d/")
105
+ prefix + date.strftime(self.site.permalink_date || "/%Y/%m/%d/")
97
106
  else
98
107
  prefix + '/'
99
108
  end
@@ -125,6 +134,27 @@ module Jekyll
125
134
  def id
126
135
  self.dir + self.slug
127
136
  end
137
+
138
+ # The post title
139
+ #
140
+ # Returns <String>
141
+ def title
142
+ self.data && self.data["title"]
143
+ end
144
+
145
+ # The post date and time
146
+ #
147
+ # Returns <Time>
148
+ def date
149
+ @date_with_time ||= begin
150
+ if self.data && self.data.key?("time")
151
+ time = Time.parse(self.data["time"])
152
+ Time.mktime(@date.year, @date.month, @date.day, time.hour, time.min)
153
+ else
154
+ @date
155
+ end
156
+ end
157
+ end
128
158
 
129
159
  # Calculate related posts.
130
160
  #
@@ -183,17 +213,34 @@ module Jekyll
183
213
  f.write(self.output)
184
214
  end
185
215
  end
216
+
217
+ # Attempt to extract title from topmost header or slug.
218
+ #
219
+ # Returns <String>
220
+ def extract_title_from_first_header_or_slug
221
+ # Done before the transformation to HTML, or it won't go into <title>s.
222
+ self.data["title"] ||=
223
+ case content_type
224
+ when 'textile'
225
+ self.content[/\A\s*h\d\.\s*(.+)/, 1] # h1. Header
226
+ when 'markdown'
227
+ self.content[/\A\s*#+\s*(.+)\s*#*$/, 1] || # "# Header"
228
+ self.content[/\A\s*(\S.*)\r?\n\s*(-+|=+)\s*$/, 1] # "Header\n====="
229
+ end
230
+ self.data["title"] ||= self.slug.split('-').select {|w| w.capitalize! || w }.join(' ')
231
+ end
186
232
 
187
233
  # Convert this post into a Hash for use in Liquid templates.
188
234
  #
189
235
  # Returns <Hash>
190
236
  def to_liquid
191
- { "title" => self.data["title"] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '),
237
+ { "title" => self.title,
192
238
  "url" => self.url,
193
239
  "date" => self.date,
194
240
  "id" => self.id,
195
241
  "topics" => self.topics,
196
242
  "categories" => self.categories,
243
+ "tags" => self.tags,
197
244
  "content" => self.content }.deep_merge(self.data)
198
245
  end
199
246
 
data/lib/jekyll/site.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  module Jekyll
2
2
 
3
3
  class Site
4
- attr_accessor :config, :layouts, :posts, :categories
5
- attr_accessor :source, :dest, :lsi, :pygments, :permalink_style
4
+ attr_accessor :config, :layouts, :posts, :collated_posts, :categories, :tags
5
+ attr_accessor :source, :dest, :lsi, :pygments, :pygments_cache, :permalink_style, :permalink_date,
6
+ :sass, :post_defaults
6
7
 
7
8
  # Initialize the site
8
9
  # +config+ is a Hash containing site configurations details
@@ -15,7 +16,10 @@ module Jekyll
15
16
  self.dest = config['destination']
16
17
  self.lsi = config['lsi']
17
18
  self.pygments = config['pygments']
19
+ self.pygments_cache = config['pygments_cache']
18
20
  self.permalink_style = config['permalink'].to_sym
21
+ self.permalink_date = config['permalink_date'] && config['permalink_date'].sub(%r{\A/?(.*)/?\Z}, '/\1/')
22
+ self.post_defaults = config['post_defaults'] || {}
19
23
 
20
24
  self.reset
21
25
  self.setup
@@ -24,12 +28,41 @@ module Jekyll
24
28
  def reset
25
29
  self.layouts = {}
26
30
  self.posts = []
27
- self.categories = Hash.new { |hash, key| hash[key] = Array.new }
31
+ self.collated_posts = Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = Hash.new {|h,k| h[k] = [] } } }
32
+ self.categories = Hash.new { |hash, key| hash[key] = [] }
33
+ self.tags = Hash.new { |hash, key| hash[key] = [] }
28
34
  end
29
35
 
30
36
  def setup
31
37
  # Check to see if LSI is enabled.
32
38
  require 'classifier' if self.lsi
39
+
40
+ if self.config['sass']
41
+ begin
42
+ require 'sass'
43
+ self.sass = true
44
+ puts 'Using Sass for CSS generation'
45
+ rescue LoadError
46
+ puts 'You must have the haml gem installed first'
47
+ end
48
+ end
49
+
50
+ if self.config['haml']
51
+ begin
52
+ require 'haml'
53
+ require 'ostruct'
54
+ require 'jekyll/haml_helpers'
55
+ puts 'Enabled Haml'
56
+ rescue LoadError
57
+ puts 'You must have the haml gem installed first'
58
+ end
59
+ end
60
+
61
+ if self.pygments_cache
62
+ require 'fileutils'
63
+ FileUtils.mkdir_p(pygments_cache)
64
+ require 'digest/md5'
65
+ end
33
66
 
34
67
  # Set the Markdown interpreter (and Maruku self.config, if necessary)
35
68
  case self.config['markdown']
@@ -91,6 +124,7 @@ module Jekyll
91
124
  self.reset
92
125
  self.read_layouts
93
126
  self.transform_pages
127
+ self.transform_sass if self.sass
94
128
  self.write_posts
95
129
  end
96
130
 
@@ -126,6 +160,7 @@ module Jekyll
126
160
  if post.published
127
161
  self.posts << post
128
162
  post.categories.each { |c| self.categories[c] << post }
163
+ post.tags.each { |c| self.tags[c] << post }
129
164
  end
130
165
  end
131
166
  end
@@ -136,7 +171,11 @@ module Jekyll
136
171
  end
137
172
 
138
173
  self.posts.sort!
139
- self.categories.values.map { |cats| cats.sort! { |a, b| b <=> a} }
174
+ self.posts.each do |post|
175
+ self.collated_posts[post.date.year][post.date.month][post.date.day].unshift(post)
176
+ end
177
+ self.categories.values.map { |ps| ps.sort! { |a, b| b <=> a} }
178
+ self.tags.values.map { |ps| ps.sort! { |a, b| b <=> a} }
140
179
  rescue Errno::ENOENT => e
141
180
  # ignore missing layout dir
142
181
  end
@@ -194,6 +233,28 @@ module Jekyll
194
233
  end
195
234
  end
196
235
 
236
+ # Transform all *.sass files from <dest> to css with the same name
237
+ # and delete source sass files.
238
+ # Returns nothing
239
+ def transform_sass(dir = '')
240
+ base = File.join(self.source, dir)
241
+ entries = Dir.entries(base)
242
+ entries = entries.reject { |e| ['.', '_'].include?(e[0..0]) }
243
+ directories = entries.select { |e| File.directory?(File.join(base, e)) }
244
+ directories.each { |d| transform_sass(File.join(dir, d)) }
245
+ files = entries.reject { |e| File.directory?(File.join(base, e)) }
246
+ files = files.select { |f| File.extname(File.join(base, f)) == ".sass" }
247
+ files.each do |f|
248
+ input = File.open(File.join(base, f), "r")
249
+ result = Sass::Engine.new(input.read, :style => :compact, :load_paths => base).render
250
+ FileUtils.mkdir_p(File.join(self.dest, dir))
251
+ output = File.open(File.join(self.dest, dir, f).gsub(/.sass\Z/, ".css"), "w") do |o|
252
+ o.write(result)
253
+ end
254
+ FileUtils.rm(File.join(self.dest, dir, f))
255
+ end
256
+ end
257
+
197
258
  # Constructs a hash map of Posts indexed by the specified Post attribute
198
259
  #
199
260
  # Returns {post_attr => [<Post>]}
@@ -211,12 +272,14 @@ module Jekyll
211
272
  # Returns {"site" => {"time" => <Time>,
212
273
  # "posts" => [<Post>],
213
274
  # "categories" => [<Post>],
275
+ # "tags" => [<Post>],
214
276
  # "topics" => [<Post>] }}
215
277
  def site_payload
216
278
  {"site" => {
217
279
  "time" => Time.now,
218
280
  "posts" => self.posts.sort { |a,b| b <=> a },
219
281
  "categories" => post_attr_hash('categories'),
282
+ "tags" => post_attr_hash('tags'),
220
283
  "topics" => post_attr_hash('topics')
221
284
  }}
222
285
  end
@@ -30,12 +30,24 @@ module Jekyll
30
30
  end
31
31
 
32
32
  def render_pygments(context, code)
33
+ if cache_dir = context.registers[:site].pygments_cache
34
+ path = File.join(cache_dir, "#{@lang}-#{Digest::MD5.hexdigest(code)}.html")
35
+ if File.exist?(path)
36
+ highlighted_code = File.read(path)
37
+ else
38
+ highlighted_code = Albino.new(code, @lang).to_s(@options)
39
+ File.open(path, 'w') {|f| f.print(highlighted_code) }
40
+ end
41
+ else
42
+ highlighted_code = Albino.new(code, @lang).to_s(@options)
43
+ end
44
+
33
45
  if context["content_type"] == :markdown
34
- return "\n" + Albino.new(code, @lang).to_s(@options) + "\n"
46
+ return "\n" + highlighted_code + "\n"
35
47
  elsif context["content_type"] == :textile
36
- return "<notextile>" + Albino.new(code, @lang).to_s(@options) + "</notextile>"
48
+ return "<notextile>" + highlighted_code + "</notextile>"
37
49
  else
38
- return Albino.new(code, @lang).to_s(@options)
50
+ return highlighted_code
39
51
  end
40
52
  end
41
53
 
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: henrik-jekyll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Preston-Werner
8
+ - Henrik Nyh
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-04-07 00:00:00 -07:00
13
+ date: 2009-04-15 00:00:00 -07:00
13
14
  default_executable: jekyll
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
@@ -97,6 +98,7 @@ files:
97
98
  - lib/jekyll/convertible.rb
98
99
  - lib/jekyll/core_ext.rb
99
100
  - lib/jekyll/filters.rb
101
+ - lib/jekyll/haml_helpers.rb
100
102
  - lib/jekyll/layout.rb
101
103
  - lib/jekyll/page.rb
102
104
  - lib/jekyll/post.rb