jekyll 3.1.0.pre.beta1 → 3.1.0.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of jekyll might be problematic. Click here for more details.

Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.markdown +1 -0
  4. data/bin/jekyll +17 -8
  5. data/lib/jekyll.rb +6 -6
  6. data/lib/jekyll/cleaner.rb +1 -1
  7. data/lib/jekyll/collection.rb +8 -7
  8. data/lib/jekyll/command.rb +0 -4
  9. data/lib/jekyll/commands/build.rb +2 -6
  10. data/lib/jekyll/commands/clean.rb +1 -3
  11. data/lib/jekyll/commands/doctor.rb +15 -19
  12. data/lib/jekyll/commands/help.rb +0 -2
  13. data/lib/jekyll/commands/serve.rb +11 -3
  14. data/lib/jekyll/commands/serve/servlet.rb +3 -3
  15. data/lib/jekyll/configuration.rb +28 -29
  16. data/lib/jekyll/converters/identity.rb +1 -1
  17. data/lib/jekyll/converters/markdown.rb +7 -7
  18. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +1 -1
  19. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +5 -6
  20. data/lib/jekyll/converters/smartypants.rb +34 -0
  21. data/lib/jekyll/convertible.rb +29 -16
  22. data/lib/jekyll/deprecator.rb +1 -1
  23. data/lib/jekyll/document.rb +26 -27
  24. data/lib/jekyll/drops/collection_drop.rb +0 -2
  25. data/lib/jekyll/drops/document_drop.rb +0 -1
  26. data/lib/jekyll/drops/drop.rb +54 -6
  27. data/lib/jekyll/drops/site_drop.rb +0 -1
  28. data/lib/jekyll/drops/unified_payload_drop.rb +0 -1
  29. data/lib/jekyll/drops/url_drop.rb +45 -13
  30. data/lib/jekyll/entry_filter.rb +1 -1
  31. data/lib/jekyll/errors.rb +4 -2
  32. data/lib/jekyll/external.rb +5 -6
  33. data/lib/jekyll/filters.rb +18 -7
  34. data/lib/jekyll/frontmatter_defaults.rb +16 -15
  35. data/lib/jekyll/generator.rb +1 -2
  36. data/lib/jekyll/hooks.rb +26 -26
  37. data/lib/jekyll/liquid_renderer.rb +1 -1
  38. data/lib/jekyll/liquid_renderer/table.rb +2 -2
  39. data/lib/jekyll/page.rb +7 -8
  40. data/lib/jekyll/plugin.rb +31 -12
  41. data/lib/jekyll/plugin_manager.rb +3 -4
  42. data/lib/jekyll/reader.rb +7 -7
  43. data/lib/jekyll/readers/collection_reader.rb +1 -2
  44. data/lib/jekyll/readers/data_reader.rb +7 -7
  45. data/lib/jekyll/readers/page_reader.rb +3 -3
  46. data/lib/jekyll/readers/post_reader.rb +2 -2
  47. data/lib/jekyll/readers/static_file_reader.rb +2 -2
  48. data/lib/jekyll/regenerator.rb +17 -18
  49. data/lib/jekyll/related_posts.rb +0 -2
  50. data/lib/jekyll/renderer.rb +14 -12
  51. data/lib/jekyll/site.rb +18 -22
  52. data/lib/jekyll/static_file.rb +15 -15
  53. data/lib/jekyll/stevenson.rb +2 -2
  54. data/lib/jekyll/tags/highlight.rb +10 -11
  55. data/lib/jekyll/tags/include.rb +10 -11
  56. data/lib/jekyll/tags/post_url.rb +7 -10
  57. data/lib/jekyll/url.rb +4 -5
  58. data/lib/jekyll/utils.rb +27 -22
  59. data/lib/jekyll/utils/ansi.rb +1 -1
  60. data/lib/jekyll/utils/platforms.rb +0 -1
  61. data/lib/jekyll/version.rb +1 -1
  62. data/lib/site_template/_includes/head.html +1 -1
  63. metadata +4 -3
@@ -15,7 +15,7 @@ module Jekyll
15
15
  def file(filename)
16
16
  filename = @site.in_source_dir(filename).sub(/\A#{Regexp.escape(@site.source)}\//, '')
17
17
 
18
- LiquidRenderer::File.new(self, filename).tap do |file|
18
+ LiquidRenderer::File.new(self, filename).tap do
19
19
  @stats[filename] ||= {}
20
20
  @stats[filename][:count] ||= 0
21
21
  @stats[filename][:count] += 1
@@ -69,10 +69,10 @@ module Jekyll
69
69
  end
70
70
 
71
71
  def data_for_table(n)
72
- sorted = @stats.sort_by{ |filename, file_stats| -file_stats[:time] }
72
+ sorted = @stats.sort_by { |_, file_stats| -file_stats[:time] }
73
73
  sorted = sorted.slice(0, n)
74
74
 
75
- table = [[ 'Filename', 'Count', 'Bytes', 'Time' ]]
75
+ table = [%w(Filename Count Bytes Time)]
76
76
 
77
77
  sorted.each do |filename, file_stats|
78
78
  row = []
@@ -8,13 +8,13 @@ module Jekyll
8
8
  attr_accessor :data, :content, :output
9
9
 
10
10
  # Attributes for Liquid templates
11
- ATTRIBUTES_FOR_LIQUID = %w[
11
+ ATTRIBUTES_FOR_LIQUID = %w(
12
12
  content
13
13
  dir
14
14
  name
15
15
  path
16
16
  url
17
- ]
17
+ )
18
18
 
19
19
  # A set of extensions that are considered HTML or HTML-like so we
20
20
  # should not alter them, this includes .xhtml through XHTM5.
@@ -37,11 +37,10 @@ module Jekyll
37
37
  @dir = dir
38
38
  @name = name
39
39
 
40
-
41
40
  process(name)
42
41
  read_yaml(File.join(base, dir), name)
43
42
 
44
- data.default_proc = proc do |hash, key|
43
+ data.default_proc = proc do |_, key|
45
44
  site.frontmatter_defaults.find(File.join(dir, name), type, key)
46
45
  end
47
46
 
@@ -107,7 +106,7 @@ module Jekyll
107
106
  # Returns nothing.
108
107
  def process(name)
109
108
  self.ext = File.extname(name)
110
- self.basename = name[0 .. -ext.length - 1]
109
+ self.basename = name[0..-ext.length - 1]
111
110
  end
112
111
 
113
112
  # Add any necessary layouts to this post
@@ -117,8 +116,8 @@ module Jekyll
117
116
  #
118
117
  # Returns nothing.
119
118
  def render(layouts, site_payload)
120
- site_payload.page = to_liquid
121
- site_payload.paginator = pager.to_liquid
119
+ site_payload["page"] = to_liquid
120
+ site_payload["paginator"] = pager.to_liquid
122
121
 
123
122
  do_layout(site_payload, layouts)
124
123
  end
@@ -143,7 +142,7 @@ module Jekyll
143
142
  def destination(dest)
144
143
  path = site.in_dest_dir(dest, URL.unescape_path(url))
145
144
  path = File.join(path, "index") if url.end_with?("/")
146
- path << output_ext unless path.end_with?(output_ext)
145
+ path << output_ext unless path.end_with? output_ext
147
146
  path
148
147
  end
149
148
 
@@ -1,20 +1,39 @@
1
1
  module Jekyll
2
2
  class Plugin
3
- PRIORITIES = { :lowest => -100,
4
- :low => -10,
5
- :normal => 0,
6
- :high => 10,
7
- :highest => 100 }
3
+ PRIORITIES = {
4
+ :low => -10,
5
+ :highest => 100,
6
+ :lowest => -100,
7
+ :normal => 0,
8
+ :high => 10
9
+ }
8
10
 
9
- # Fetch all the subclasses of this class and its subclasses' subclasses.
10
11
  #
11
- # Returns an array of descendant classes.
12
- def self.descendants
13
- descendants = []
14
- ObjectSpace.each_object(singleton_class) do |k|
15
- descendants.unshift k unless k == self
12
+
13
+ def self.inherited(const)
14
+ return catch_inheritance(const) do |const_|
15
+ catch_inheritance(const_)
16
+ end
17
+ end
18
+
19
+ #
20
+
21
+ def self.catch_inheritance(const)
22
+ const.define_singleton_method :inherited do |const_|
23
+ (@children ||= Set.new).add const_
24
+ if block_given?
25
+ yield const_
26
+ end
16
27
  end
17
- descendants
28
+ end
29
+
30
+ #
31
+
32
+ def self.descendants
33
+ @children ||= Set.new
34
+ out = @children.map(&:descendants)
35
+ out << self unless superclass == Plugin
36
+ Set.new(out).flatten
18
37
  end
19
38
 
20
39
  # Get or set the priority of this plugin. When called without an
@@ -76,7 +76,7 @@ module Jekyll
76
76
  #
77
77
  # Returns an Array of plugin search paths
78
78
  def plugins_path
79
- if (site.config['plugins_dir'] == Jekyll::Configuration::DEFAULTS['plugins_dir'])
79
+ if site.config['plugins_dir'] == Jekyll::Configuration::DEFAULTS['plugins_dir']
80
80
  [site.in_source_dir(site.config['plugins_dir'])]
81
81
  else
82
82
  Array(site.config['plugins_dir']).map { |d| File.expand_path(d) }
@@ -86,11 +86,10 @@ module Jekyll
86
86
  def deprecation_checks
87
87
  pagination_included = (site.config['gems'] || []).include?('jekyll-paginate') || defined?(Jekyll::Paginate)
88
88
  if site.config['paginate'] && !pagination_included
89
- Jekyll::Deprecator.deprecation_message "You appear to have pagination " +
90
- "turned on, but you haven't included the `jekyll-paginate` gem. " +
89
+ Jekyll::Deprecator.deprecation_message "You appear to have pagination " \
90
+ "turned on, but you haven't included the `jekyll-paginate` gem. " \
91
91
  "Ensure you have `gems: [jekyll-paginate]` in your configuration file."
92
92
  end
93
93
  end
94
-
95
94
  end
96
95
  end
@@ -22,7 +22,7 @@ module Jekyll
22
22
 
23
23
  # Sorts posts, pages, and static files.
24
24
  def sort_files!
25
- site.collections.values.each{|c| c.docs.sort!}
25
+ site.collections.values.each { |c| c.docs.sort! }
26
26
  site.pages.sort_by!(&:name)
27
27
  site.static_files.sort_by!(&:relative_path)
28
28
  end
@@ -38,9 +38,9 @@ module Jekyll
38
38
  base = site.in_source_dir(dir)
39
39
 
40
40
  dot = Dir.chdir(base) { filter_entries(Dir.entries('.'), base) }
41
- dot_dirs = dot.select{ |file| File.directory?(@site.in_source_dir(base,file)) }
41
+ dot_dirs = dot.select { |file| File.directory?(@site.in_source_dir(base, file)) }
42
42
  dot_files = (dot - dot_dirs)
43
- dot_pages = dot_files.select{ |file| Utils.has_yaml_header?(@site.in_source_dir(base,file)) }
43
+ dot_pages = dot_files.select { |file| Utils.has_yaml_header?(@site.in_source_dir(base, file)) }
44
44
  dot_static_files = dot_files - dot_pages
45
45
 
46
46
  retrieve_posts(dir)
@@ -67,12 +67,12 @@ module Jekyll
67
67
  # dot_dirs - The Array of subdirectories in the dir.
68
68
  #
69
69
  # Returns nothing.
70
- def retrieve_dirs(base, dir, dot_dirs)
71
- dot_dirs.map { |file|
72
- dir_path = site.in_source_dir(dir,file)
70
+ def retrieve_dirs(_base, dir, dot_dirs)
71
+ dot_dirs.map do |file|
72
+ dir_path = site.in_source_dir(dir, file)
73
73
  rel_path = File.join(dir, file)
74
74
  @site.reader.read_directories(rel_path) unless @site.dest.sub(/\/$/, '') == dir_path
75
- }
75
+ end
76
76
  end
77
77
 
78
78
  # Retrieve all the pages from the current directory,
@@ -1,6 +1,6 @@
1
1
  module Jekyll
2
2
  class CollectionReader
3
- SPECIAL_COLLECTIONS = %w{posts data}.freeze
3
+ SPECIAL_COLLECTIONS = %w(posts data).freeze
4
4
 
5
5
  attr_reader :site, :content
6
6
  def initialize(site)
@@ -16,6 +16,5 @@ module Jekyll
16
16
  collection.read unless SPECIAL_COLLECTIONS.include?(collection.label)
17
17
  end
18
18
  end
19
-
20
19
  end
21
20
  end
@@ -50,13 +50,13 @@ module Jekyll
50
50
  # Returns the contents of the data file.
51
51
  def read_data_file(path)
52
52
  case File.extname(path).downcase
53
- when '.csv'
54
- CSV.read(path, {
55
- :headers => true,
56
- :encoding => site.config['encoding']
57
- }).map(&:to_hash)
58
- else
59
- SafeYAML.load_file(path)
53
+ when '.csv'
54
+ CSV.read(path, {
55
+ :headers => true,
56
+ :encoding => site.config['encoding']
57
+ }).map(&:to_hash)
58
+ else
59
+ SafeYAML.load_file(path)
60
60
  end
61
61
  end
62
62
 
@@ -4,7 +4,7 @@ module Jekyll
4
4
  def initialize(site, dir)
5
5
  @site = site
6
6
  @dir = dir
7
- @unfiltered_content = Array.new
7
+ @unfiltered_content = []
8
8
  end
9
9
 
10
10
  # Read all the files in <source>/<dir>/ for Yaml header and create a new Page
@@ -14,8 +14,8 @@ module Jekyll
14
14
  #
15
15
  # Returns an array of static pages.
16
16
  def read(files)
17
- files.map{ |page| @unfiltered_content << Page.new(@site, @site.source, @dir, page) }
18
- @unfiltered_content.select{ |page| site.publisher.publish?(page) }
17
+ files.map { |page| @unfiltered_content << Page.new(@site, @site.source, @dir, page) }
18
+ @unfiltered_content.select { |page| site.publisher.publish?(page) }
19
19
  end
20
20
  end
21
21
  end
@@ -53,8 +53,8 @@ module Jekyll
53
53
  next unless entry =~ matcher
54
54
  path = @site.in_source_dir(File.join(dir, magic_dir, entry))
55
55
  Document.new(path, {
56
- site: @site,
57
- collection: @site.posts
56
+ :site => @site,
57
+ :collection => @site.posts
58
58
  })
59
59
  end.reject(&:nil?)
60
60
  end
@@ -4,7 +4,7 @@ module Jekyll
4
4
  def initialize(site, dir)
5
5
  @site = site
6
6
  @dir = dir
7
- @unfiltered_content = Array.new
7
+ @unfiltered_content = []
8
8
  end
9
9
 
10
10
  # Read all the files in <source>/<dir>/ for Yaml header and create a new Page
@@ -14,7 +14,7 @@ module Jekyll
14
14
  #
15
15
  # Returns an array of static files.
16
16
  def read(files)
17
- files.map{ |file| @unfiltered_content << StaticFile.new(@site, @site.source, @dir, file)}
17
+ files.map { |file| @unfiltered_content << StaticFile.new(@site, @site.source, @dir, file) }
18
18
  @unfiltered_content
19
19
  end
20
20
  end
@@ -62,7 +62,6 @@ module Jekyll
62
62
  clear_cache
63
63
  end
64
64
 
65
-
66
65
  # Clear just the cache
67
66
  #
68
67
  # Returns nothing
@@ -70,13 +69,12 @@ module Jekyll
70
69
  @cache = {}
71
70
  end
72
71
 
73
-
74
72
  # Checks if the source has been modified or the
75
73
  # destination is missing
76
74
  #
77
75
  # returns a boolean
78
76
  def source_modified_or_dest_missing?(source_path, dest_path)
79
- modified?(source_path) || (dest_path and !File.exist?(dest_path))
77
+ modified?(source_path) || (dest_path && !File.exist?(dest_path))
80
78
  end
81
79
 
82
80
  # Checks if a path's (or one of its dependencies)
@@ -90,7 +88,7 @@ module Jekyll
90
88
  return true if path.nil?
91
89
 
92
90
  # Check for path in cache
93
- if cache.has_key? path
91
+ if cache.key? path
94
92
  return cache[path]
95
93
  end
96
94
 
@@ -117,9 +115,9 @@ module Jekyll
117
115
  #
118
116
  # Returns nothing.
119
117
  def add_dependency(path, dependency)
120
- return if (metadata[path].nil? || @disabled)
118
+ return if metadata[path].nil? || @disabled
121
119
 
122
- if !metadata[path]["deps"].include? dependency
120
+ unless metadata[path]["deps"].include? dependency
123
121
  metadata[path]["deps"] << dependency
124
122
  add(dependency) unless metadata.include?(dependency)
125
123
  end
@@ -157,20 +155,21 @@ module Jekyll
157
155
  #
158
156
  # Returns the read metadata.
159
157
  def read_metadata
160
- @metadata = if !disabled? && File.file?(metadata_file)
161
- content = File.binread(metadata_file)
162
-
163
- begin
164
- Marshal.load(content)
165
- rescue TypeError
166
- SafeYAML.load(content)
167
- rescue ArgumentError => e
168
- Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}")
158
+ @metadata =
159
+ if !disabled? && File.file?(metadata_file)
160
+ content = File.binread(metadata_file)
161
+
162
+ begin
163
+ Marshal.load(content)
164
+ rescue TypeError
165
+ SafeYAML.load(content)
166
+ rescue ArgumentError => e
167
+ Jekyll.logger.warn("Failed to load #{metadata_file}: #{e}")
168
+ {}
169
+ end
170
+ else
169
171
  {}
170
172
  end
171
- else
172
- {}
173
- end
174
173
  end
175
174
  end
176
175
  end
@@ -1,6 +1,5 @@
1
1
  module Jekyll
2
2
  class RelatedPosts
3
-
4
3
  class << self
5
4
  attr_accessor :lsi
6
5
  end
@@ -24,7 +23,6 @@ module Jekyll
24
23
  end
25
24
  end
26
25
 
27
-
28
26
  def build_index
29
27
  self.class.lsi ||= begin
30
28
  lsi = ClassifierReborn::LSI.new(:auto_rebuild => false)
@@ -2,7 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  class Renderer
5
-
6
5
  attr_reader :document, :site, :payload
7
6
 
8
7
  def initialize(site, document, site_payload = nil)
@@ -23,7 +22,11 @@ module Jekyll
23
22
  #
24
23
  # Returns the output extname including the leading period.
25
24
  def output_ext
26
- @output_ext ||= converters.first.output_ext(document.extname)
25
+ @output_ext ||= if document.permalink
26
+ File.extname(document.permalink)
27
+ else
28
+ converters.first.output_ext(document.extname)
29
+ end
27
30
  end
28
31
 
29
32
  ######################
@@ -33,23 +36,23 @@ module Jekyll
33
36
  def run
34
37
  Jekyll.logger.debug "Rendering:", document.relative_path
35
38
 
36
- payload.page = document.to_liquid
39
+ payload["page"] = document.to_liquid
37
40
 
38
41
  if document.collection.label == 'posts' && document.is_a?(Document)
39
- payload.site['related_posts'] = document.related_posts
42
+ payload['site']['related_posts'] = document.related_posts
40
43
  end
41
44
 
42
45
  Jekyll.logger.debug "Pre-Render Hooks:", document.relative_path
43
46
  document.trigger_hooks(:pre_render, payload)
44
47
 
45
48
  info = {
46
- filters: [Jekyll::Filters],
47
- registers: { :site => site, :page => payload.page }
49
+ :filters => [Jekyll::Filters],
50
+ :registers => { :site => site, :page => payload['page'] }
48
51
  }
49
52
 
50
53
  # render and transform content (this becomes the final content of the object)
51
- payload.highlighter_prefix = converters.first.highlighter_prefix
52
- payload.highlighter_suffix = converters.first.highlighter_suffix
54
+ payload['highlighter_prefix'] = converters.first.highlighter_prefix
55
+ payload['highlighter_suffix'] = converters.first.highlighter_suffix
53
56
 
54
57
  output = document.content
55
58
 
@@ -133,9 +136,9 @@ module Jekyll
133
136
  used = Set.new([layout])
134
137
 
135
138
  while layout
136
- payload.content = output
137
- payload.page = document.to_liquid
138
- payload.layout = layout.data
139
+ payload['content'] = output
140
+ payload['page'] = document.to_liquid
141
+ payload['layout'] = Utils.deep_merge_hashes(payload['layout'] || {}, layout.data)
139
142
 
140
143
  output = render_liquid(
141
144
  layout.content,
@@ -161,6 +164,5 @@ module Jekyll
161
164
 
162
165
  output
163
166
  end
164
-
165
167
  end
166
168
  end
@@ -19,8 +19,8 @@ module Jekyll
19
19
  def initialize(config)
20
20
  @config = config.clone
21
21
 
22
- %w[safe lsi highlighter baseurl exclude include future unpublished
23
- show_drafts limit_posts keep_files gems].each do |opt|
22
+ %w(safe lsi highlighter baseurl exclude include future unpublished
23
+ show_drafts limit_posts keep_files gems).each do |opt|
24
24
  self.send("#{opt}=", config[opt])
25
25
  end
26
26
 
@@ -165,7 +165,7 @@ module Jekyll
165
165
 
166
166
  Jekyll::Hooks.trigger :site, :pre_render, self, payload
167
167
 
168
- collections.each do |label, collection|
168
+ collections.each do |_, collection|
169
169
  collection.docs.each do |document|
170
170
  if regenerator.regenerate?(document)
171
171
  document.output = Jekyll::Renderer.new(self, document, payload).run
@@ -196,9 +196,9 @@ module Jekyll
196
196
  #
197
197
  # Returns nothing.
198
198
  def write
199
- each_site_file { |item|
199
+ each_site_file do |item|
200
200
  item.write(dest) if regenerator.regenerate?(item)
201
- }
201
+ end
202
202
  regenerator.write_metadata
203
203
  Jekyll::Hooks.trigger :site, :post_write, self
204
204
  end
@@ -263,25 +263,21 @@ module Jekyll
263
263
  end
264
264
 
265
265
  # Get the implementation class for the given Converter.
266
- #
267
- # klass - The Class of the Converter to fetch.
268
- #
269
266
  # Returns the Converter instance implementing the given Converter.
267
+ # klass - The Class of the Converter to fetch.
268
+
270
269
  def find_converter_instance(klass)
271
- converters.find { |c| c.class == klass } || proc { raise "No converter for #{klass}" }.call
270
+ converters.find { |klass_| klass_.instance_of?(klass) } || \
271
+ raise("No Converters found for #{klass}")
272
272
  end
273
273
 
274
+ # klass - class or module containing the subclasses.
275
+ # Returns array of instances of subclasses of parameter.
274
276
  # Create array of instances of the subclasses of the class or module
275
- # passed in as argument.
276
- #
277
- # klass - class or module containing the subclasses which should be
278
- # instantiated
279
- #
280
- # Returns array of instances of subclasses of parameter
277
+ # passed in as argument.
278
+
281
279
  def instantiate_subclasses(klass)
282
- klass.descendants.select do |c|
283
- !safe || c.safe
284
- end.sort.map do |c|
280
+ klass.descendants.select { |c| !safe || c.safe }.sort.map do |c|
285
281
  c.new(config)
286
282
  end
287
283
  end
@@ -292,10 +288,10 @@ module Jekyll
292
288
  # Returns
293
289
  def relative_permalinks_are_deprecated
294
290
  if config['relative_permalinks']
295
- Jekyll.logger.abort_with "Since v3.0, permalinks for pages" +
296
- " in subfolders must be relative to the" +
297
- " site source directory, not the parent" +
298
- " directory. Check http://jekyllrb.com/docs/upgrading/"+
291
+ Jekyll.logger.abort_with "Since v3.0, permalinks for pages" \
292
+ " in subfolders must be relative to the" \
293
+ " site source directory, not the parent" \
294
+ " directory. Check http://jekyllrb.com/docs/upgrading/"\
299
295
  " for more info."
300
296
  end
301
297
  end