jekyll 2.0.0.alpha.1 → 2.0.0.alpha.2

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 (132) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +15 -0
  3. data/.travis.yml +27 -0
  4. data/History.markdown +66 -1
  5. data/LICENSE +2 -2
  6. data/README.markdown +2 -2
  7. data/Rakefile +4 -44
  8. data/bin/jekyll +10 -113
  9. data/docs/jp/CONTRIBUTING.jp.markdown +93 -0
  10. data/docs/jp/README.jp.markdown +69 -0
  11. data/features/create_sites.feature +12 -12
  12. data/features/drafts.feature +23 -2
  13. data/features/embed_filters.feature +7 -5
  14. data/features/include_tag.feature +7 -7
  15. data/features/markdown.feature +4 -4
  16. data/features/pagination.feature +2 -2
  17. data/features/permalinks.feature +7 -7
  18. data/features/post_data.feature +21 -21
  19. data/features/post_excerpts.feature +6 -6
  20. data/features/site_configuration.feature +17 -17
  21. data/features/site_data.feature +15 -15
  22. data/features/step_definitions/jekyll_steps.rb +4 -4
  23. data/features/support/env.rb +2 -2
  24. data/jekyll.gemspec +17 -284
  25. data/lib/jekyll.rb +21 -5
  26. data/lib/jekyll/command.rb +72 -20
  27. data/lib/jekyll/commands/build.rb +82 -58
  28. data/lib/jekyll/commands/docs.rb +30 -0
  29. data/lib/jekyll/commands/doctor.rb +18 -1
  30. data/lib/jekyll/commands/new.rb +19 -6
  31. data/lib/jekyll/commands/serve.rb +80 -49
  32. data/lib/jekyll/configuration.rb +3 -3
  33. data/lib/jekyll/converters/markdown/kramdown_parser.rb +1 -1
  34. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +1 -0
  35. data/lib/jekyll/convertible.rb +19 -21
  36. data/lib/jekyll/draft.rb +5 -0
  37. data/lib/jekyll/excerpt.rb +5 -5
  38. data/lib/jekyll/layout.rb +2 -2
  39. data/lib/jekyll/layout_reader.rb +15 -2
  40. data/lib/jekyll/page.rb +17 -17
  41. data/lib/jekyll/post.rb +33 -33
  42. data/lib/jekyll/related_posts.rb +5 -5
  43. data/lib/jekyll/site.rb +84 -85
  44. data/lib/jekyll/static_file.rb +13 -0
  45. data/lib/jekyll/stevenson.rb +1 -1
  46. data/lib/jekyll/tags/highlight.rb +16 -6
  47. data/lib/jekyll/tags/include.rb +17 -17
  48. data/lib/jekyll/url.rb +2 -0
  49. data/lib/jekyll/utils.rb +79 -0
  50. data/lib/jekyll/version.rb +3 -0
  51. data/lib/site_template/_config.yml +3 -1
  52. data/lib/site_template/_includes/footer.html +61 -0
  53. data/lib/site_template/_includes/head.html +12 -0
  54. data/lib/site_template/_includes/header.html +27 -0
  55. data/lib/site_template/_layouts/default.html +9 -34
  56. data/lib/site_template/_layouts/page.html +14 -0
  57. data/lib/site_template/_layouts/post.html +11 -5
  58. data/lib/site_template/_posts/0000-00-00-this-post-demonstrates-post-content-styles.md +88 -0
  59. data/lib/site_template/about/index.md +10 -0
  60. data/lib/site_template/css/main.css +333 -100
  61. data/lib/site_template/feed.xml +21 -0
  62. data/lib/site_template/index.html +8 -4
  63. data/lib/site_template/projects/index.md +14 -0
  64. data/script/cibuild +0 -1
  65. data/script/rebund +1 -1
  66. data/site/_includes/analytics.html +2 -2
  67. data/site/_includes/css/normalize.css +1 -1
  68. data/site/_includes/css/style.css +28 -4
  69. data/site/_includes/docs_option.html +1 -1
  70. data/site/_includes/docs_ul.html +3 -3
  71. data/site/_includes/footer.html +1 -1
  72. data/site/_includes/header.html +2 -2
  73. data/site/_includes/news_item.html +1 -1
  74. data/site/_includes/primary-nav-items.html +4 -4
  75. data/site/_includes/section_nav.html +2 -2
  76. data/site/_includes/top.html +6 -7
  77. data/site/_layouts/news_item.html +1 -1
  78. data/site/_posts/2013-07-25-jekyll-1-0-4-released.markdown +1 -1
  79. data/site/_posts/2013-07-25-jekyll-1-1-2-released.markdown +1 -1
  80. data/site/_posts/2013-09-14-jekyll-1-2-1-released.markdown +1 -1
  81. data/site/_posts/2014-03-24-jekyll-1-5-0-released.markdown +19 -0
  82. data/site/docs/assets.md +14 -0
  83. data/site/docs/configuration.md +65 -56
  84. data/site/docs/contributing.md +7 -2
  85. data/site/docs/deployment-methods.md +1 -1
  86. data/site/docs/github-pages.md +1 -1
  87. data/site/docs/history.md +21 -0
  88. data/site/docs/index.md +7 -1
  89. data/site/docs/installation.md +28 -0
  90. data/site/docs/migrations.md +1 -1
  91. data/site/docs/plugins.md +6 -0
  92. data/site/docs/structure.md +3 -3
  93. data/site/docs/templates.md +44 -44
  94. data/site/docs/usage.md +1 -1
  95. data/site/docs/variables.md +15 -2
  96. data/site/favicon.png +0 -0
  97. data/site/feed.xml +0 -1
  98. data/site/img/article-footer.png +0 -0
  99. data/site/img/footer-arrow.png +0 -0
  100. data/site/img/footer-logo.png +0 -0
  101. data/site/img/logo-2x.png +0 -0
  102. data/site/img/octojekyll.png +0 -0
  103. data/site/img/tube.png +0 -0
  104. data/site/img/tube1x.png +0 -0
  105. data/site/index.html +5 -5
  106. data/site/js/modernizr-2.7.1.min.js +4 -0
  107. data/test/helper.rb +11 -0
  108. data/test/source/_drafts/draft-properties.text +11 -0
  109. data/test/source/_posts/2011-04-12-md-extension.md +1 -1
  110. data/test/source/_posts/2014-01-06-permalink-traversal.md +5 -0
  111. data/test/source/exploit.md +5 -0
  112. data/test/source/static_files.html +4 -0
  113. data/test/test_configuration.rb +2 -2
  114. data/test/test_draft.rb +56 -0
  115. data/test/test_excerpt.rb +2 -2
  116. data/test/test_filters.rb +1 -1
  117. data/test/test_generated_site.rb +10 -1
  118. data/test/test_kramdown.rb +1 -1
  119. data/test/test_layout_reader.rb +17 -0
  120. data/test/test_page.rb +10 -0
  121. data/test/test_pager.rb +4 -2
  122. data/test/test_path_sanitization.rb +14 -0
  123. data/test/test_post.rb +12 -1
  124. data/test/test_sass.rb +1 -64
  125. data/test/test_site.rb +26 -1
  126. data/test/test_tags.rb +39 -2
  127. data/test/{test_core_ext.rb → test_utils.rb} +12 -12
  128. metadata +200 -86
  129. data/lib/jekyll/converters/sass.rb +0 -58
  130. data/lib/jekyll/core_ext.rb +0 -55
  131. data/lib/site_template/css/syntax.css +0 -60
  132. data/site/js/modernizr-2.5.3.min.js +0 -4
@@ -36,7 +36,7 @@ module Jekyll
36
36
  'exclude' => [],
37
37
  'paginate_path' => '/page:num',
38
38
 
39
- 'markdown_ext' => 'markdown,mkd,mkdn,md',
39
+ 'markdown_ext' => 'markdown,mkdown,mkdn,mkd,md',
40
40
  'textile_ext' => 'textile',
41
41
 
42
42
  'port' => '4000',
@@ -159,7 +159,7 @@ module Jekyll
159
159
  begin
160
160
  files.each do |config_file|
161
161
  new_config = read_config_file(config_file)
162
- configuration = configuration.deep_merge(new_config)
162
+ configuration = Utils.deep_merge_hashes(configuration, new_config)
163
163
  end
164
164
  rescue ArgumentError => err
165
165
  Jekyll.logger.warn "WARNING:", "Error reading configuration. " +
@@ -229,7 +229,7 @@ module Jekyll
229
229
  config[option] = csv_to_array(config[option])
230
230
  end
231
231
  end
232
-
232
+
233
233
  if config.fetch('markdown', 'kramdown').to_s.downcase.eql?("maruku")
234
234
  Jekyll::Deprecator.deprecation_message "You're using the 'maruku' " +
235
235
  "Markdown processor. Maruku support has been deprecated and will " +
@@ -20,7 +20,7 @@ module Jekyll
20
20
  end
21
21
  end
22
22
 
23
- Kramdown::Document.new(content, @config["kramdown"].symbolize_keys).to_html
23
+ Kramdown::Document.new(content, Utils.symbolize_hash_keys(@config["kramdown"])).to_html
24
24
  end
25
25
 
26
26
  end
@@ -5,6 +5,7 @@ module Jekyll
5
5
 
6
6
  module CommonMethods
7
7
  def add_code_tags(code, lang)
8
+ code = code.to_s
8
9
  code = code.sub(/<pre>/, "<pre><code class=\"#{lang} language-#{lang}\" data-lang=\"#{lang}\">")
9
10
  code = code.sub(/<\/pre>/,"</code></pre>")
10
11
  end
@@ -18,18 +18,18 @@ module Jekyll
18
18
  module Convertible
19
19
  # Returns the contents as a String.
20
20
  def to_s
21
- self.content || ''
21
+ content || ''
22
22
  end
23
23
 
24
24
  # Whether the file is published or not, as indicated in YAML front-matter
25
25
  def published?
26
- !(self.data.has_key?('published') && self.data['published'] == false)
26
+ !(data.has_key?('published') && data['published'] == false)
27
27
  end
28
28
 
29
29
  # Returns merged option hash for File.read of self.site (if exists)
30
30
  # and a given param
31
31
  def merged_file_read_opts(opts)
32
- (self.site ? self.site.file_read_opts : {}).merge(opts)
32
+ (site ? site.file_read_opts : {}).merge(opts)
33
33
  end
34
34
 
35
35
  # Read the YAML frontmatter.
@@ -43,7 +43,7 @@ module Jekyll
43
43
  begin
44
44
  self.content = File.read(File.join(base, name),
45
45
  merged_file_read_opts(opts))
46
- if self.content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
46
+ if content =~ /\A(---\s*\n.*?\n?)^(---\s*$\n?)/m
47
47
  self.content = $POSTMATCH
48
48
  self.data = SafeYAML.load($1)
49
49
  end
@@ -60,10 +60,10 @@ module Jekyll
60
60
  #
61
61
  # Returns nothing.
62
62
  def transform
63
- self.content = converter.convert(self.content)
63
+ self.content = converter.convert(content)
64
64
  rescue => e
65
65
  Jekyll.logger.error "Conversion error:", "There was an error converting" +
66
- " '#{self.path}'."
66
+ " '#{path}'."
67
67
  raise e
68
68
  end
69
69
 
@@ -72,7 +72,7 @@ module Jekyll
72
72
  # Returns the String extension for the output file.
73
73
  # e.g. ".html" for an HTML output file.
74
74
  def output_ext
75
- converter.output_ext(self.ext)
75
+ converter.output_ext(ext)
76
76
  end
77
77
 
78
78
  # Determine which converter to use based on this convertible's
@@ -80,7 +80,7 @@ module Jekyll
80
80
  #
81
81
  # Returns the Converter instance.
82
82
  def converter
83
- @converter ||= self.site.converters.find { |c| c.matches(self.ext) }
83
+ @converter ||= site.converters.find { |c| c.matches(ext) }
84
84
  end
85
85
 
86
86
  # Render Liquid in the content
@@ -107,7 +107,7 @@ module Jekyll
107
107
  further_data = Hash[(attrs || self.class::ATTRIBUTES_FOR_LIQUID).map { |attribute|
108
108
  [attribute, send(attribute)]
109
109
  }]
110
- data.deep_merge(further_data)
110
+ Utils.deep_merge_hashes(data, further_data)
111
111
  end
112
112
 
113
113
  # Recursively render layouts
@@ -119,16 +119,16 @@ module Jekyll
119
119
  # Returns nothing
120
120
  def render_all_layouts(layouts, payload, info)
121
121
  # recursively render layouts
122
- layout = layouts[self.data["layout"]]
122
+ layout = layouts[data["layout"]]
123
123
  used = Set.new([layout])
124
124
 
125
125
  while layout
126
- payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
126
+ payload = Utils.deep_merge_hashes(payload, {"content" => output, "page" => layout.data})
127
127
 
128
- self.output = self.render_liquid(layout.content,
128
+ self.output = render_liquid(layout.content,
129
129
  payload,
130
130
  info,
131
- File.join(self.site.config['layouts'], layout.name))
131
+ File.join(site.config['layouts'], layout.name))
132
132
 
133
133
  if layout = layouts[layout.data["layout"]]
134
134
  if used.include?(layout)
@@ -147,21 +147,19 @@ module Jekyll
147
147
  #
148
148
  # Returns nothing.
149
149
  def do_layout(payload, layouts)
150
- info = { :filters => [Jekyll::Filters], :registers => { :site => self.site, :page => payload['page'] } }
150
+ info = { :filters => [Jekyll::Filters], :registers => { :site => site, :page => payload['page'] } }
151
151
 
152
152
  # render and transform content (this becomes the final content of the object)
153
153
  payload["highlighter_prefix"] = converter.highlighter_prefix
154
154
  payload["highlighter_suffix"] = converter.highlighter_suffix
155
155
 
156
- self.content = self.render_liquid(self.content,
157
- payload,
158
- info)
159
- self.transform
156
+ self.content = render_liquid(content, payload, info)
157
+ transform
160
158
 
161
159
  # output keeps track of what will finally be written
162
- self.output = self.content
160
+ self.output = content
163
161
 
164
- self.render_all_layouts(layouts, payload, info)
162
+ render_all_layouts(layouts, payload, info)
165
163
  end
166
164
 
167
165
  # Write the generated page file to the destination directory.
@@ -173,7 +171,7 @@ module Jekyll
173
171
  path = destination(dest)
174
172
  FileUtils.mkdir_p(File.dirname(path))
175
173
  File.open(path, 'wb') do |f|
176
- f.write(self.output)
174
+ f.write(output)
177
175
  end
178
176
  end
179
177
 
@@ -18,6 +18,11 @@ module Jekyll
18
18
  File.join(source, dir, '_drafts')
19
19
  end
20
20
 
21
+ # The path to the draft source file, relative to the site source
22
+ def relative_path
23
+ File.join(@dir, '_drafts', @name)
24
+ end
25
+
21
26
  # Extract information from the post filename.
22
27
  #
23
28
  # name - The String filename of the post file.
@@ -8,7 +8,7 @@ module Jekyll
8
8
 
9
9
  attr_accessor :post
10
10
  attr_accessor :content, :output, :ext
11
-
11
+
12
12
  def_delegator :@post, :site, :site
13
13
  def_delegator :@post, :name, :name
14
14
  def_delegator :@post, :ext, :ext
@@ -39,7 +39,7 @@ module Jekyll
39
39
  end
40
40
 
41
41
  # 'Path' of the excerpt.
42
- #
42
+ #
43
43
  # Returns the path for the post this excerpt belongs to with #excerpt appended
44
44
  def path
45
45
  File.join(post.path, "#excerpt")
@@ -47,9 +47,9 @@ module Jekyll
47
47
 
48
48
  # Check if excerpt includes a string
49
49
  #
50
- # Returns true if the string passed in
50
+ # Returns true if the string passed in
51
51
  def include?(something)
52
- (self.output && self.output.include?(something)) || self.content.include?(something)
52
+ (output && output.include?(something)) || content.include?(something)
53
53
  end
54
54
 
55
55
  # The UID for this post (useful in feeds).
@@ -61,7 +61,7 @@ module Jekyll
61
61
  end
62
62
 
63
63
  def to_s
64
- self.output || self.content
64
+ output || content
65
65
  end
66
66
 
67
67
  # Returns the shorthand String identifier of this Post.
@@ -29,8 +29,8 @@ module Jekyll
29
29
 
30
30
  self.data = {}
31
31
 
32
- self.process(name)
33
- self.read_yaml(base, name)
32
+ process(name)
33
+ read_yaml(base, name)
34
34
  end
35
35
 
36
36
  # Extract information from the layout filename.
@@ -14,6 +14,10 @@ module Jekyll
14
14
  @layouts
15
15
  end
16
16
 
17
+ def layout_directory
18
+ @layout_directory ||= (layout_directory_in_cwd || layout_directory_inside_source)
19
+ end
20
+
17
21
  private
18
22
 
19
23
  def layout_entries
@@ -33,8 +37,17 @@ module Jekyll
33
37
  Dir.chdir(directory) { yield }
34
38
  end
35
39
 
36
- def layout_directory
37
- File.join(site.source, site.config['layouts'])
40
+ def layout_directory_inside_source
41
+ Jekyll.sanitized_path(site.source, site.config['layouts'])
42
+ end
43
+
44
+ def layout_directory_in_cwd
45
+ dir = Jekyll.sanitized_path(Dir.pwd, site.config['layouts'])
46
+ if File.directory?(dir)
47
+ dir
48
+ else
49
+ nil
50
+ end
38
51
  end
39
52
  end
40
53
  end
@@ -28,8 +28,8 @@ module Jekyll
28
28
  @dir = dir
29
29
  @name = name
30
30
 
31
- self.process(name)
32
- self.read_yaml(File.join(base, dir), name)
31
+ process(name)
32
+ read_yaml(File.join(base, dir), name)
33
33
  end
34
34
 
35
35
  # The generated directory into which the page will be placed
@@ -46,11 +46,11 @@ module Jekyll
46
46
  #
47
47
  # Returns the String permalink or nil if none has been set.
48
48
  def permalink
49
- return nil if self.data.nil? || self.data['permalink'].nil?
49
+ return nil if data.nil? || data['permalink'].nil?
50
50
  if site.config['relative_permalinks']
51
- File.join(@dir, self.data['permalink'])
51
+ File.join(@dir, data['permalink'])
52
52
  else
53
- self.data['permalink']
53
+ data['permalink']
54
54
  end
55
55
  end
56
56
 
@@ -58,7 +58,7 @@ module Jekyll
58
58
  #
59
59
  # Returns the template String.
60
60
  def template
61
- if self.site.permalink_style == :pretty
61
+ if site.permalink_style == :pretty
62
62
  if index? && html?
63
63
  "/:path/"
64
64
  elsif html?
@@ -87,8 +87,8 @@ module Jekyll
87
87
  def url_placeholders
88
88
  {
89
89
  :path => @dir,
90
- :basename => self.basename,
91
- :output_ext => self.output_ext
90
+ :basename => basename,
91
+ :output_ext => output_ext
92
92
  }
93
93
  end
94
94
 
@@ -99,7 +99,7 @@ module Jekyll
99
99
  # Returns nothing.
100
100
  def process(name)
101
101
  self.ext = File.extname(name)
102
- self.basename = name[0 .. -self.ext.length-1]
102
+ self.basename = name[0 .. -ext.length - 1]
103
103
  end
104
104
 
105
105
  # Add any necessary layouts to this post
@@ -109,10 +109,10 @@ module Jekyll
109
109
  #
110
110
  # Returns nothing.
111
111
  def render(layouts, site_payload)
112
- payload = {
113
- "page" => self.to_liquid,
112
+ payload = Utils.deep_merge_hashes({
113
+ "page" => to_liquid,
114
114
  'paginator' => pager.to_liquid
115
- }.deep_merge(site_payload)
115
+ }, site_payload)
116
116
 
117
117
  do_layout(payload, layouts)
118
118
  end
@@ -121,7 +121,7 @@ module Jekyll
121
121
  #
122
122
  # Returns the path to the source file
123
123
  def path
124
- self.data.fetch('path', self.relative_path.sub(/\A\//, ''))
124
+ data.fetch('path', relative_path.sub(/\A\//, ''))
125
125
  end
126
126
 
127
127
  # The path to the page source file, relative to the site source
@@ -135,14 +135,14 @@ module Jekyll
135
135
  #
136
136
  # Returns the destination file path String.
137
137
  def destination(dest)
138
- path = File.join(dest, self.url)
139
- path = File.join(path, "index.html") if self.url =~ /\/$/
138
+ path = Jekyll.sanitized_path(dest, url)
139
+ path = File.join(path, "index.html") if url =~ /\/$/
140
140
  path
141
141
  end
142
142
 
143
143
  # Returns the object as a debug String.
144
144
  def inspect
145
- "#<Jekyll:Page @name=#{self.name.inspect}>"
145
+ "#<Jekyll:Page @name=#{name.inspect}>"
146
146
  end
147
147
 
148
148
  # Returns the Boolean of whether this Page is HTML or not.
@@ -156,7 +156,7 @@ module Jekyll
156
156
  end
157
157
 
158
158
  def uses_relative_permalinks
159
- permalink && @dir != "" && site.config['relative_permalinks']
159
+ permalink && !@dir.empty? && site.config['relative_permalinks']
160
160
  end
161
161
  end
162
162
  end
@@ -49,30 +49,30 @@ module Jekyll
49
49
  def initialize(site, source, dir, name)
50
50
  @site = site
51
51
  @dir = dir
52
- @base = self.containing_dir(source, dir)
52
+ @base = containing_dir(source, dir)
53
53
  @name = name
54
54
 
55
55
  self.categories = dir.downcase.split('/').reject { |x| x.empty? }
56
- self.process(name)
57
- self.read_yaml(@base, name)
56
+ process(name)
57
+ read_yaml(@base, name)
58
58
 
59
- if self.data.has_key?('date')
60
- self.date = Time.parse(self.data["date"].to_s)
59
+ if data.has_key?('date')
60
+ self.date = Time.parse(data["date"].to_s)
61
61
  end
62
62
 
63
- self.populate_categories
64
- self.populate_tags
63
+ populate_categories
64
+ populate_tags
65
65
  end
66
66
 
67
67
  def populate_categories
68
- if self.categories.empty?
69
- self.categories = self.data.pluralized_array('category', 'categories').map {|c| c.to_s.downcase}
68
+ if categories.empty?
69
+ self.categories = Utils.pluralized_array_from_hash(data, 'category', 'categories').map {|c| c.to_s.downcase}
70
70
  end
71
- self.categories.flatten!
71
+ categories.flatten!
72
72
  end
73
73
 
74
74
  def populate_tags
75
- self.tags = self.data.pluralized_array("tag", "tags").flatten
75
+ self.tags = Utils.pluralized_array_from_hash(data, "tag", "tags").flatten
76
76
  end
77
77
 
78
78
  # Get the full path to the directory containing the post files
@@ -88,7 +88,7 @@ module Jekyll
88
88
  # Returns nothing.
89
89
  def read_yaml(base, name)
90
90
  super(base, name)
91
- self.extracted_excerpt = self.extract_excerpt
91
+ self.extracted_excerpt = extract_excerpt
92
92
  end
93
93
 
94
94
  # The post excerpt. This is either a custom excerpt
@@ -96,19 +96,19 @@ module Jekyll
96
96
  #
97
97
  # Returns excerpt string.
98
98
  def excerpt
99
- self.data.fetch('excerpt', self.extracted_excerpt.to_s)
99
+ data.fetch('excerpt', extracted_excerpt.to_s)
100
100
  end
101
101
 
102
102
  # Public: the Post title, from the YAML Front-Matter or from the slug
103
103
  #
104
104
  # Returns the post title
105
105
  def title
106
- self.data.fetch("title", self.titleized_slug)
106
+ data.fetch("title", titleized_slug)
107
107
  end
108
108
 
109
109
  # Turns the post slug into a suitable title
110
110
  def titleized_slug
111
- self.slug.split('-').select {|w| w.capitalize! || w }.join(' ')
111
+ slug.split('-').select {|w| w.capitalize! || w }.join(' ')
112
112
  end
113
113
 
114
114
  # Public: the path to the post relative to the site source,
@@ -118,7 +118,7 @@ module Jekyll
118
118
  #
119
119
  # Returns the path to the file relative to the site source
120
120
  def path
121
- self.data.fetch('path', self.relative_path.sub(/\A\//, ''))
121
+ data.fetch('path', relative_path.sub(/\A\//, ''))
122
122
  end
123
123
 
124
124
  # The path to the post source file, relative to the site source
@@ -172,11 +172,11 @@ module Jekyll
172
172
  #
173
173
  # Returns the String permalink.
174
174
  def permalink
175
- self.data && self.data['permalink']
175
+ data && data['permalink']
176
176
  end
177
177
 
178
178
  def template
179
- case self.site.permalink_style
179
+ case site.permalink_style
180
180
  when :pretty
181
181
  "/:categories/:year/:month/:day/:title/"
182
182
  when :none
@@ -186,7 +186,7 @@ module Jekyll
186
186
  when :ordinal
187
187
  "/:categories/:year/:y_day/:title.html"
188
188
  else
189
- self.site.permalink_style.to_s
189
+ site.permalink_style.to_s
190
190
  end
191
191
  end
192
192
 
@@ -214,7 +214,7 @@ module Jekyll
214
214
  :categories => (categories || []).map { |c| URI.escape(c.to_s) }.join('/'),
215
215
  :short_month => date.strftime("%b"),
216
216
  :y_day => date.strftime("%j"),
217
- :output_ext => self.output_ext
217
+ :output_ext => output_ext
218
218
  }
219
219
  end
220
220
 
@@ -223,7 +223,7 @@ module Jekyll
223
223
  #
224
224
  # Returns the String UID.
225
225
  def id
226
- File.join(self.dir, self.slug)
226
+ File.join(dir, slug)
227
227
  end
228
228
 
229
229
  # Calculate related posts.
@@ -241,16 +241,16 @@ module Jekyll
241
241
  # Returns nothing.
242
242
  def render(layouts, site_payload)
243
243
  # construct payload
244
- payload = {
244
+ payload = Utils.deep_merge_hashes({
245
245
  "site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) },
246
- "page" => self.to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID)
247
- }.deep_merge(site_payload)
246
+ "page" => to_liquid(EXCERPT_ATTRIBUTES_FOR_LIQUID)
247
+ }, site_payload)
248
248
 
249
249
  if generate_excerpt?
250
- self.extracted_excerpt.do_layout(payload, {})
250
+ extracted_excerpt.do_layout(payload, {})
251
251
  end
252
252
 
253
- do_layout(payload.merge({"page" => self.to_liquid}), layouts)
253
+ do_layout(payload.merge({"page" => to_liquid}), layouts)
254
254
  end
255
255
 
256
256
  # Obtain destination path.
@@ -260,29 +260,29 @@ module Jekyll
260
260
  # Returns destination file path String.
261
261
  def destination(dest)
262
262
  # The url needs to be unescaped in order to preserve the correct filename
263
- path = File.join(dest, CGI.unescape(self.url))
263
+ path = Jekyll.sanitized_path(dest, CGI.unescape(url))
264
264
  path = File.join(path, "index.html") if path[/\.html$/].nil?
265
265
  path
266
266
  end
267
267
 
268
268
  # Returns the shorthand String identifier of this Post.
269
269
  def inspect
270
- "<Post: #{self.id}>"
270
+ "<Post: #{id}>"
271
271
  end
272
272
 
273
273
  def next
274
- pos = self.site.posts.index {|post| post.equal?(self) }
275
- if pos && pos < self.site.posts.length-1
276
- self.site.posts[pos+1]
274
+ pos = site.posts.index {|post| post.equal?(self) }
275
+ if pos && pos < site.posts.length - 1
276
+ site.posts[pos + 1]
277
277
  else
278
278
  nil
279
279
  end
280
280
  end
281
281
 
282
282
  def previous
283
- pos = self.site.posts.index {|post| post.equal?(self) }
283
+ pos = site.posts.index {|post| post.equal?(self) }
284
284
  if pos && pos > 0
285
- self.site.posts[pos-1]
285
+ site.posts[pos - 1]
286
286
  else
287
287
  nil
288
288
  end