jekyll 1.5.1 → 2.0.0.alpha.1

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 (115) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.markdown +6 -6
  3. data/History.markdown +99 -23
  4. data/README.markdown +7 -3
  5. data/Rakefile +5 -5
  6. data/bin/jekyll +101 -116
  7. data/features/embed_filters.feature +13 -0
  8. data/features/include_tag.feature +11 -0
  9. data/features/markdown.feature +3 -3
  10. data/features/site_configuration.feature +34 -3
  11. data/features/step_definitions/jekyll_steps.rb +47 -34
  12. data/features/support/env.rb +25 -28
  13. data/jekyll.gemspec +38 -18
  14. data/lib/jekyll.rb +7 -15
  15. data/lib/jekyll/commands/build.rb +2 -0
  16. data/lib/jekyll/commands/serve.rb +11 -1
  17. data/lib/jekyll/configuration.rb +22 -6
  18. data/lib/jekyll/converter.rb +16 -16
  19. data/lib/jekyll/converters/markdown.rb +30 -15
  20. data/lib/jekyll/converters/markdown/maruku_parser.rb +4 -5
  21. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +34 -3
  22. data/lib/jekyll/converters/sass.rb +58 -0
  23. data/lib/jekyll/converters/textile.rb +2 -2
  24. data/lib/jekyll/convertible.rb +25 -6
  25. data/lib/jekyll/core_ext.rb +0 -35
  26. data/lib/jekyll/deprecator.rb +2 -2
  27. data/lib/jekyll/entry_filter.rb +61 -25
  28. data/lib/jekyll/excerpt.rb +8 -6
  29. data/lib/jekyll/filters.rb +46 -2
  30. data/lib/jekyll/layout_reader.rb +40 -0
  31. data/lib/jekyll/mime.types +19 -9
  32. data/lib/jekyll/page.rb +6 -4
  33. data/lib/jekyll/post.rb +11 -18
  34. data/lib/jekyll/site.rb +34 -32
  35. data/lib/jekyll/tags/highlight.rb +26 -4
  36. data/lib/jekyll/tags/include.rb +29 -17
  37. data/lib/jekyll/tags/post_url.rb +10 -1
  38. data/lib/jekyll/url.rb +0 -2
  39. data/lib/site_template/_config.yml +1 -1
  40. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +1 -1
  41. data/lib/site_template/css/main.css +8 -1
  42. data/script/bootstrap +2 -0
  43. data/script/branding +11 -0
  44. data/script/cibuild +5 -0
  45. data/script/rebund +140 -0
  46. data/site/_config.yml +2 -2
  47. data/site/_data/docs.yml +44 -0
  48. data/site/{css → _includes/css}/gridism.css +0 -0
  49. data/site/_includes/css/normalize.css +1 -0
  50. data/site/{css → _includes/css}/pygments.css +2 -0
  51. data/site/{css → _includes/css}/style.css +10 -0
  52. data/site/_includes/docs_contents.html +4 -12
  53. data/site/_includes/docs_contents_mobile.html +4 -17
  54. data/site/_includes/docs_option.html +1 -1
  55. data/site/_includes/docs_ul.html +2 -2
  56. data/site/_includes/footer.html +1 -1
  57. data/site/_includes/top.html +1 -4
  58. data/site/_layouts/news_item.html +2 -2
  59. data/site/_posts/2013-07-24-jekyll-1-1-1-released.markdown +4 -4
  60. data/site/_posts/2013-09-14-jekyll-1-2-1-released.markdown +1 -1
  61. data/site/_posts/2013-10-28-jekyll-1-3-0-rc1-released.markdown +1 -1
  62. data/site/_posts/2013-12-09-jekyll-1-4-1-released.markdown +20 -0
  63. data/site/_posts/2014-01-13-jekyll-1-4-3-released.markdown +1 -2
  64. data/site/css/screen.css +27 -0
  65. data/site/docs/assets.md +46 -0
  66. data/site/docs/configuration.md +18 -4
  67. data/site/docs/contributing.md +2 -2
  68. data/site/docs/datafiles.md +6 -6
  69. data/site/docs/deployment-methods.md +5 -0
  70. data/site/docs/extras.md +38 -2
  71. data/site/docs/frontmatter.md +2 -1
  72. data/site/docs/history.md +0 -22
  73. data/site/docs/installation.md +7 -7
  74. data/site/docs/migrations.md +1 -1
  75. data/site/docs/plugins.md +11 -2
  76. data/site/docs/posts.md +25 -4
  77. data/site/docs/sites.md +1 -1
  78. data/site/docs/structure.md +1 -1
  79. data/site/docs/templates.md +13 -8
  80. data/site/docs/troubleshooting.md +8 -5
  81. data/site/docs/usage.md +11 -0
  82. data/site/docs/variables.md +18 -0
  83. data/site/docs/windows.md +44 -0
  84. data/test/helper.rb +5 -8
  85. data/test/source/_includes/include.html +1 -0
  86. data/test/source/_includes/sig.markdown +2 -2
  87. data/test/source/_posts/2013-12-17-include-variable-filters.markdown +21 -0
  88. data/test/source/_posts/2013-12-20-properties.text +11 -0
  89. data/test/source/_sass/_grid.scss +1 -0
  90. data/test/source/css/main.scss +4 -0
  91. data/test/source/js/coffeescript.coffee +10 -0
  92. data/test/source/properties.html +8 -0
  93. data/test/source/unpublished.html +7 -0
  94. data/test/test_coffeescript.rb +49 -0
  95. data/test/test_configuration.rb +29 -18
  96. data/test/test_convertible.rb +7 -9
  97. data/test/test_core_ext.rb +0 -22
  98. data/test/test_entry_filter.rb +36 -2
  99. data/test/test_excerpt.rb +43 -1
  100. data/test/test_filters.rb +44 -5
  101. data/test/test_generated_site.rb +5 -1
  102. data/test/test_layout_reader.rb +17 -0
  103. data/test/test_page.rb +28 -10
  104. data/test/test_post.rb +32 -15
  105. data/test/test_redcarpet.rb +19 -3
  106. data/test/test_sass.rb +122 -0
  107. data/test/test_site.rb +56 -7
  108. data/test/test_tags.rb +102 -51
  109. metadata +154 -80
  110. data/site/_posts/2014-03-24-jekyll-1-5-0-released.markdown +0 -19
  111. data/site/_posts/2014-03-27-jekyll-1-5-1-released.markdown +0 -26
  112. data/site/css/normalize.css +0 -1
  113. data/test/source/_posts/2014-01-06-permalink-traversal.md +0 -5
  114. data/test/source/exploit.md +0 -5
  115. data/test/test_path_sanitization.rb +0 -18
@@ -13,6 +13,7 @@ require 'set'
13
13
  # self.ext=
14
14
  # self.output=
15
15
  # self.name
16
+ # self.path
16
17
  module Jekyll
17
18
  module Convertible
18
19
  # Returns the contents as a String.
@@ -20,7 +21,12 @@ module Jekyll
20
21
  self.content || ''
21
22
  end
22
23
 
23
- # Returns merged optin hash for File.read of self.site (if exists)
24
+ # Whether the file is published or not, as indicated in YAML front-matter
25
+ def published?
26
+ !(self.data.has_key?('published') && self.data['published'] == false)
27
+ end
28
+
29
+ # Returns merged option hash for File.read of self.site (if exists)
24
30
  # and a given param
25
31
  def merged_file_read_opts(opts)
26
32
  (self.site ? self.site.file_read_opts : {}).merge(opts)
@@ -35,11 +41,11 @@ module Jekyll
35
41
  # Returns nothing.
36
42
  def read_yaml(base, name, opts = {})
37
43
  begin
38
- self.content = File.read_with_options(File.join(base, name),
39
- merged_file_read_opts(opts))
44
+ self.content = File.read(File.join(base, name),
45
+ merged_file_read_opts(opts))
40
46
  if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
41
47
  self.content = $POSTMATCH
42
- self.data = YAML.safe_load($1)
48
+ self.data = SafeYAML.load($1)
43
49
  end
44
50
  rescue SyntaxError => e
45
51
  puts "YAML Exception reading #{File.join(base, name)}: #{e.message}"
@@ -144,8 +150,8 @@ module Jekyll
144
150
  info = { :filters => [Jekyll::Filters], :registers => { :site => self.site, :page => payload['page'] } }
145
151
 
146
152
  # render and transform content (this becomes the final content of the object)
147
- payload["pygments_prefix"] = converter.pygments_prefix
148
- payload["pygments_suffix"] = converter.pygments_suffix
153
+ payload["highlighter_prefix"] = converter.highlighter_prefix
154
+ payload["highlighter_suffix"] = converter.highlighter_suffix
149
155
 
150
156
  self.content = self.render_liquid(self.content,
151
157
  payload,
@@ -170,5 +176,18 @@ module Jekyll
170
176
  f.write(self.output)
171
177
  end
172
178
  end
179
+
180
+ # Accessor for data properties by Liquid.
181
+ #
182
+ # property - The String name of the property to retrieve.
183
+ #
184
+ # Returns the String value or nil if the property isn't included.
185
+ def [](property)
186
+ if self.class::ATTRIBUTES_FOR_LIQUID.include?(property)
187
+ send(property)
188
+ else
189
+ data[property]
190
+ end
191
+ end
173
192
  end
174
193
  end
@@ -53,38 +53,3 @@ class Hash
53
53
  dup.symbolize_keys!
54
54
  end
55
55
  end
56
-
57
- # Thanks, ActiveSupport!
58
- class Date
59
- # Converts datetime to an appropriate format for use in XML
60
- def xmlschema
61
- strftime("%Y-%m-%dT%H:%M:%S%Z")
62
- end if RUBY_VERSION < '1.9'
63
- end
64
-
65
- module Enumerable
66
- # Returns true if path matches against any glob pattern.
67
- # Look for more detail about glob pattern in method File::fnmatch.
68
- def glob_include?(e)
69
- any? { |exp| File.fnmatch?(exp, e) }
70
- end
71
- end
72
-
73
- # Ruby 1.8's File.read don't support option.
74
- # read_with_options ignore optional parameter for 1.8,
75
- # and act as alias for 1.9 or later.
76
- class File
77
- if RUBY_VERSION < '1.9'
78
- def self.read_with_options(path, opts = {})
79
- self.read(path)
80
- end
81
-
82
- def self.realpath(filename)
83
- Pathname.new(filename).realpath.to_s
84
- end
85
- else
86
- def self.read_with_options(path, opts = {})
87
- self.read(path, opts)
88
- end
89
- end
90
- end
@@ -9,8 +9,8 @@ module Jekyll
9
9
  arg_is_present? args, "--auto", "The switch '--auto' has been replaced with '--watch'."
10
10
  arg_is_present? args, "--no-auto", "To disable auto-replication, simply leave off \
11
11
  the '--watch' switch."
12
- arg_is_present? args, "--pygments", "The 'pygments' setting can only be set in \
13
- your config files."
12
+ arg_is_present? args, "--pygments", "The 'pygments'settings has been removed in \
13
+ favour of 'highlighter'."
14
14
  arg_is_present? args, "--paginate", "The 'paginate' setting can only be set in your \
15
15
  config files."
16
16
  arg_is_present? args, "--url", "The 'url' setting can only be set in your config files."
@@ -1,35 +1,71 @@
1
- class EntryFilter
2
- attr_reader :site
3
- def initialize(site)
4
- @site = site
5
- end
1
+ module Jekyll
2
+ class EntryFilter
3
+ attr_reader :site
4
+
5
+ def initialize(site, base_directory = nil)
6
+ @site = site
7
+ @base_directory = derive_base_directory(@site, base_directory.to_s.dup)
8
+ end
6
9
 
7
- def filter(entries)
8
- entries.reject do |e|
9
- unless included?(e)
10
- special?(e) || backup?(e) || excluded?(e) || symlink?(e)
10
+ def base_directory
11
+ @base_directory.to_s
12
+ end
13
+
14
+ def derive_base_directory(site, base_dir)
15
+ if base_dir.start_with?(site.source)
16
+ base_dir[site.source] = ""
11
17
  end
18
+ base_dir
12
19
  end
13
- end
14
20
 
15
- def included?(entry)
16
- site.include.glob_include?(entry)
17
- end
21
+ def relative_to_source(entry)
22
+ File.join(base_directory, entry)
23
+ end
18
24
 
19
- def special?(entry)
20
- ['.', '_', '#'].include?(entry[0..0])
21
- end
25
+ def filter(entries)
26
+ entries.reject do |e|
27
+ unless included?(e)
28
+ special?(e) || backup?(e) || excluded?(e) || symlink?(e)
29
+ end
30
+ end
31
+ end
22
32
 
23
- def backup?(entry)
24
- entry[-1..-1] == '~'
25
- end
33
+ def included?(entry)
34
+ glob_include?(site.include, entry)
35
+ end
26
36
 
27
- def excluded?(entry)
28
- site.exclude.glob_include?(entry)
29
- end
37
+ def special?(entry)
38
+ ['.', '_', '#'].include?(entry[0..0])
39
+ end
30
40
 
31
- def symlink?(entry)
32
- File.symlink?(entry) && site.safe
33
- end
41
+ def backup?(entry)
42
+ entry[-1..-1] == '~'
43
+ end
34
44
 
45
+ def excluded?(entry)
46
+ excluded = glob_include?(site.exclude, relative_to_source(entry))
47
+ Jekyll.logger.debug "excluded?(#{relative_to_source(entry)}) ==> #{excluded}"
48
+ excluded
49
+ end
50
+
51
+ def symlink?(entry)
52
+ File.symlink?(entry) && site.safe
53
+ end
54
+
55
+ def ensure_leading_slash(path)
56
+ path[0..0] == "/" ? path : "/#{path}"
57
+ end
58
+
59
+ # Returns true if path matches against any glob pattern.
60
+ # Look for more detail about glob pattern in method File::fnmatch.
61
+ def glob_include?(enum, e)
62
+ entry = ensure_leading_slash(e)
63
+ enum.any? do |exp|
64
+ item = ensure_leading_slash(exp)
65
+ Jekyll.logger.debug "glob_include?(#{entry})"
66
+ Jekyll.logger.debug " ==> File.fnmatch?(#{item}, #{entry}) == #{File.fnmatch?(item, entry)}"
67
+ File.fnmatch?(item, entry)
68
+ end
69
+ end
70
+ end
35
71
  end
@@ -1,9 +1,17 @@
1
+ require 'jekyll/convertible'
2
+ require 'forwardable'
3
+
1
4
  module Jekyll
2
5
  class Excerpt
3
6
  include Convertible
7
+ extend Forwardable
4
8
 
5
9
  attr_accessor :post
6
10
  attr_accessor :content, :output, :ext
11
+
12
+ def_delegator :@post, :site, :site
13
+ def_delegator :@post, :name, :name
14
+ def_delegator :@post, :ext, :ext
7
15
 
8
16
  # Initialize this Post instance.
9
17
  #
@@ -17,12 +25,6 @@ module Jekyll
17
25
  self.content = extract_excerpt(post.content)
18
26
  end
19
27
 
20
- %w[site name ext].each do |meth|
21
- define_method(meth) do
22
- post.send(meth)
23
- end
24
- end
25
-
26
28
  def to_liquid
27
29
  post.to_liquid(Post::EXCERPT_ATTRIBUTES_FOR_LIQUID)
28
30
  end
@@ -100,7 +100,7 @@ module Jekyll
100
100
  def cgi_escape(input)
101
101
  CGI::escape(input)
102
102
  end
103
-
103
+
104
104
  # URI escape a string.
105
105
  #
106
106
  # input - The String to escape.
@@ -124,7 +124,7 @@ module Jekyll
124
124
  input.split.length
125
125
  end
126
126
 
127
- # Join an array of things into a string by separating with commes and the
127
+ # Join an array of things into a string by separating with commas and the
128
128
  # word "and" for the last one.
129
129
  #
130
130
  # array - The Array of Strings to join.
@@ -158,6 +158,38 @@ module Jekyll
158
158
  input.to_json
159
159
  end
160
160
 
161
+ # Group an array of items by a property
162
+ #
163
+ # input - the inputted Enumerable
164
+ # property - the property
165
+ #
166
+ # Returns an array of Hashes, each looking something like this:
167
+ # {"name" => "larry"
168
+ # "items" => [...] } # all the items where `property` == "larry"
169
+ def group_by(input, property)
170
+ if groupable?(input)
171
+ input.group_by do |item|
172
+ item_property(item, property).to_s
173
+ end.inject([]) do |memo, i|
174
+ memo << {"name" => i.first, "items" => i.last}
175
+ end
176
+ else
177
+ input
178
+ end
179
+ end
180
+
181
+ # Filter an array of objects
182
+ #
183
+ # input - the object array
184
+ # key - key within each object to filter by
185
+ # value - desired value
186
+ #
187
+ # Returns the filtered array of objects
188
+ def where(input, key, value)
189
+ return input unless input.is_a?(Array)
190
+ input.select { |object| object[key] == value }
191
+ end
192
+
161
193
  private
162
194
  def time(input)
163
195
  case input
@@ -170,5 +202,17 @@ module Jekyll
170
202
  exit(1)
171
203
  end
172
204
  end
205
+
206
+ def groupable?(element)
207
+ element.respond_to?(:group_by)
208
+ end
209
+
210
+ def item_property(item, property)
211
+ if item.respond_to?(:data)
212
+ item.data[property.to_s]
213
+ else
214
+ item[property.to_s]
215
+ end
216
+ end
173
217
  end
174
218
  end
@@ -0,0 +1,40 @@
1
+ module Jekyll
2
+ class LayoutReader
3
+ attr_reader :site
4
+ def initialize(site)
5
+ @site = site
6
+ @layouts = {}
7
+ end
8
+
9
+ def read
10
+ layout_entries.each do |f|
11
+ @layouts[layout_name(f)] = Layout.new(site, layout_directory, f)
12
+ end
13
+
14
+ @layouts
15
+ end
16
+
17
+ private
18
+
19
+ def layout_entries
20
+ entries = []
21
+ within(layout_directory) do
22
+ entries = EntryFilter.new(site).filter(Dir['**/*.*'])
23
+ end
24
+ entries
25
+ end
26
+
27
+ def layout_name(file)
28
+ file.split(".")[0..-2].join(".")
29
+ end
30
+
31
+ def within(directory)
32
+ return unless File.exists?(directory)
33
+ Dir.chdir(directory) { yield }
34
+ end
35
+
36
+ def layout_directory
37
+ File.join(site.source, site.config['layouts'])
38
+ end
39
+ end
40
+ end
@@ -1,12 +1,13 @@
1
- # These are the same MIME types that GitHub Pages uses as of 17 Mar 2013.
1
+ -# These are the same MIME types that GitHub Pages uses as of 26 January 2014
2
2
 
3
3
  text/html html htm shtml
4
4
  text/css css
5
- text/xml xml rss xsl
5
+ text/xml xml rss xsl xsd
6
6
  image/gif gif
7
7
  image/jpeg jpeg jpg
8
8
  application/x-javascript js
9
9
  application/atom+xml atom
10
+ application/json json geojson topojson
10
11
 
11
12
  text/mathml mml
12
13
  text/plain txt
@@ -17,16 +18,22 @@ text/cache-manifest manifest appcache
17
18
  text/coffeescript coffee
18
19
  text/plain pde
19
20
  text/plain md markdown
21
+ text/vcard vcf vcard
20
22
 
21
23
  image/png png
22
24
  image/svg+xml svg
25
+ image/svg+xml svgz
23
26
  image/tiff tif tiff
24
27
  image/vnd.wap.wbmp wbmp
25
28
  image/x-icon ico
26
29
  image/x-jng jng
27
30
  image/x-ms-bmp bmp
28
31
 
29
- application/json json
32
+ application/vnd.ms-fontobject eot
33
+ application/x-font-ttf ttf
34
+ application/x-font-woff woff
35
+ font/opentype otf
36
+
30
37
  application/java-archive jar ear
31
38
  application/mac-binhex40 hqx
32
39
  application/msword doc
@@ -34,18 +41,19 @@ application/pdf pdf
34
41
  application/postscript ps eps ai
35
42
  application/rdf+xml rdf
36
43
  application/rtf rtf
37
- text/vcard vcf vcard
38
44
  application/vnd.apple.pkpass pkpass
39
45
  application/vnd.ms-excel xls
40
46
  application/vnd.ms-powerpoint ppt
41
47
  application/vnd.wap.wmlc wmlc
42
48
  application/xhtml+xml xhtml
43
- application/x-chrome-extension crx
44
49
  application/x-cocoa cco
45
- application/x-font-ttf ttf
50
+ application/x-chrome-extension crx
46
51
  application/x-java-archive-diff jardiff
47
52
  application/x-java-jnlp-file jnlp
48
53
  application/x-makeself run
54
+ application/x-ms-application application
55
+ application/x-ms-manifest manifest
56
+ application/x-ms-vsto vsto
49
57
  application/x-ns-proxy-autoconfig pac
50
58
  application/x-perl pl pm
51
59
  application/x-pilot prc pdb
@@ -63,8 +71,8 @@ application/zip zip
63
71
 
64
72
  application/octet-stream bin exe dll
65
73
  application/octet-stream deb
74
+ application/octet-stream deploy
66
75
  application/octet-stream dmg
67
- application/octet-stream eot
68
76
  application/octet-stream iso img
69
77
  application/octet-stream msi msp msm
70
78
 
@@ -74,12 +82,14 @@ audio/x-realaudio ra
74
82
  audio/ogg ogg
75
83
 
76
84
  video/3gpp 3gpp 3gp
85
+ video/m4v m4v
86
+ video/mp4 mp4
77
87
  video/mpeg mpeg mpg
88
+ video/ogg ogg ogv
78
89
  video/quicktime mov
90
+ video/webm webm
79
91
  video/x-flv flv
80
92
  video/x-mng mng
81
93
  video/x-ms-asf asx asf
82
94
  video/x-ms-wmv wmv
83
95
  video/x-msvideo avi
84
- video/ogg ogv
85
- video/webm webm
@@ -9,9 +9,11 @@ module Jekyll
9
9
 
10
10
  # Attributes for Liquid templates
11
11
  ATTRIBUTES_FOR_LIQUID = %w[
12
- url
13
12
  content
13
+ dir
14
+ name
14
15
  path
16
+ url
15
17
  ]
16
18
 
17
19
  # Initialize a new Page.
@@ -124,7 +126,7 @@ module Jekyll
124
126
 
125
127
  # The path to the page source file, relative to the site source
126
128
  def relative_path
127
- File.join(@dir, @name)
129
+ File.join(*[@dir, @name].map(&:to_s).reject(&:empty?))
128
130
  end
129
131
 
130
132
  # Obtain destination path.
@@ -133,8 +135,8 @@ module Jekyll
133
135
  #
134
136
  # Returns the destination file path String.
135
137
  def destination(dest)
136
- path = Jekyll.sanitized_path(dest, url)
137
- path = File.join(path, "index.html") if url =~ /\/$/
138
+ path = File.join(dest, self.url)
139
+ path = File.join(path, "index.html") if self.url =~ /\/$/
138
140
  path
139
141
  end
140
142