jekyll 3.0.0.pre.beta10 → 3.0.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.
- checksums.yaml +4 -4
- data/lib/jekyll.rb +1 -3
- data/lib/jekyll/cleaner.rb +3 -2
- data/lib/jekyll/collection.rb +20 -2
- data/lib/jekyll/command.rb +1 -1
- data/lib/jekyll/commands/build.rb +2 -2
- data/lib/jekyll/configuration.rb +36 -5
- data/lib/jekyll/convertible.rb +13 -10
- data/lib/jekyll/document.rb +173 -17
- data/lib/jekyll/excerpt.rb +45 -33
- data/lib/jekyll/hooks.rb +9 -7
- data/lib/jekyll/page.rb +1 -1
- data/lib/jekyll/publisher.rb +2 -2
- data/lib/jekyll/reader.rb +4 -4
- data/lib/jekyll/readers/collection_reader.rb +4 -2
- data/lib/jekyll/readers/post_reader.rb +35 -10
- data/lib/jekyll/regenerator.rb +4 -4
- data/lib/jekyll/related_posts.rb +3 -3
- data/lib/jekyll/renderer.rb +12 -2
- data/lib/jekyll/site.rb +16 -13
- data/lib/jekyll/tags/post_url.rb +4 -4
- data/lib/jekyll/utils.rb +12 -7
- data/lib/jekyll/version.rb +1 -1
- data/lib/site_template/_includes/footer.html +2 -19
- data/lib/site_template/_includes/icon-github.html +1 -0
- data/lib/site_template/_includes/icon-github.svg +1 -0
- data/lib/site_template/_includes/icon-twitter.html +1 -0
- data/lib/site_template/_includes/icon-twitter.svg +1 -0
- data/lib/site_template/_sass/_layout.scss +1 -0
- data/lib/site_template/_sass/_syntax-highlighting.scss +4 -0
- data/lib/site_template/about.md +6 -2
- data/lib/site_template/css/main.scss +1 -1
- metadata +6 -5
- data/lib/jekyll/draft.rb +0 -40
- data/lib/jekyll/post.rb +0 -334
- data/lib/jekyll/readers/draft_reader.rb +0 -37
data/lib/jekyll/tags/post_url.rb
CHANGED
@@ -14,7 +14,7 @@ module Jekyll
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def ==(other)
|
17
|
-
other.
|
17
|
+
other.basename.match(@name_regex)
|
18
18
|
end
|
19
19
|
|
20
20
|
def deprecated_equality(other)
|
@@ -32,11 +32,11 @@ module Jekyll
|
|
32
32
|
#
|
33
33
|
# Returns the post slug with the subdirectory (relative to _posts)
|
34
34
|
def post_slug(other)
|
35
|
-
path = other.
|
35
|
+
path = other.basename.split("/")[0...-1].join("/")
|
36
36
|
if path.nil? || path == ""
|
37
|
-
other.slug
|
37
|
+
other.data['slug']
|
38
38
|
else
|
39
|
-
path + '/' + other.slug
|
39
|
+
path + '/' + other.data['slug']
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
data/lib/jekyll/utils.rb
CHANGED
@@ -8,6 +8,13 @@ module Jekyll
|
|
8
8
|
SLUGIFY_DEFAULT_REGEXP = Regexp.new('[^[:alnum:]]+').freeze
|
9
9
|
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
|
10
10
|
|
11
|
+
# Non-destructive version of deep_merge_hashes! See that method.
|
12
|
+
#
|
13
|
+
# Returns the merged hashes.
|
14
|
+
def deep_merge_hashes(master_hash, other_hash)
|
15
|
+
deep_merge_hashes!(master_hash.dup, other_hash)
|
16
|
+
end
|
17
|
+
|
11
18
|
# Merges a master hash with another hash, recursively.
|
12
19
|
#
|
13
20
|
# master_hash - the "parent" hash whose values will be overridden
|
@@ -17,16 +24,14 @@ module Jekyll
|
|
17
24
|
# http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
|
18
25
|
#
|
19
26
|
# Thanks to whoever made it.
|
20
|
-
def deep_merge_hashes(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
if other_hash[key].is_a? Hash and target[key].is_a? Hash
|
25
|
-
target[key] = Utils.deep_merge_hashes(target[key], other_hash[key])
|
27
|
+
def deep_merge_hashes!(target, overwrite)
|
28
|
+
overwrite.each_key do |key|
|
29
|
+
if overwrite[key].is_a? Hash and target[key].is_a? Hash
|
30
|
+
target[key] = Utils.deep_merge_hashes(target[key], overwrite[key])
|
26
31
|
next
|
27
32
|
end
|
28
33
|
|
29
|
-
target[key] =
|
34
|
+
target[key] = overwrite[key]
|
30
35
|
end
|
31
36
|
|
32
37
|
target
|
data/lib/jekyll/version.rb
CHANGED
@@ -16,30 +16,13 @@
|
|
16
16
|
<ul class="social-media-list">
|
17
17
|
{% if site.github_username %}
|
18
18
|
<li>
|
19
|
-
|
20
|
-
<span class="icon icon--github">
|
21
|
-
<svg viewBox="0 0 16 16">
|
22
|
-
<path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/>
|
23
|
-
</svg>
|
24
|
-
</span>
|
25
|
-
|
26
|
-
<span class="username">{{ site.github_username }}</span>
|
27
|
-
</a>
|
19
|
+
{% include icon-github.html username=site.github_username %}
|
28
20
|
</li>
|
29
21
|
{% endif %}
|
30
22
|
|
31
23
|
{% if site.twitter_username %}
|
32
24
|
<li>
|
33
|
-
|
34
|
-
<span class="icon icon--twitter">
|
35
|
-
<svg viewBox="0 0 16 16">
|
36
|
-
<path fill="#828282" d="M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809
|
37
|
-
c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27 c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767 c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206 C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271 c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469 c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"/>
|
38
|
-
</svg>
|
39
|
-
</span>
|
40
|
-
|
41
|
-
<span class="username">{{ site.twitter_username }}</span>
|
42
|
-
</a>
|
25
|
+
{% include icon-twitter.html username=site.twitter_username %}
|
43
26
|
</li>
|
44
27
|
{% endif %}
|
45
28
|
</ul>
|
@@ -0,0 +1 @@
|
|
1
|
+
<a href="https://github.com/{{ include.username }}"><span class="icon icon--github">{% include icon-github.svg %}</span><span class="username">{{ include.username }}</span></a>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg viewBox="0 0 16 16"><path fill="#828282" d="M7.999,0.431c-4.285,0-7.76,3.474-7.76,7.761 c0,3.428,2.223,6.337,5.307,7.363c0.388,0.071,0.53-0.168,0.53-0.374c0-0.184-0.007-0.672-0.01-1.32 c-2.159,0.469-2.614-1.04-2.614-1.04c-0.353-0.896-0.862-1.135-0.862-1.135c-0.705-0.481,0.053-0.472,0.053-0.472 c0.779,0.055,1.189,0.8,1.189,0.8c0.692,1.186,1.816,0.843,2.258,0.645c0.071-0.502,0.271-0.843,0.493-1.037 C4.86,11.425,3.049,10.76,3.049,7.786c0-0.847,0.302-1.54,0.799-2.082C3.768,5.507,3.501,4.718,3.924,3.65 c0,0,0.652-0.209,2.134,0.796C6.677,4.273,7.34,4.187,8,4.184c0.659,0.003,1.323,0.089,1.943,0.261 c1.482-1.004,2.132-0.796,2.132-0.796c0.423,1.068,0.157,1.857,0.077,2.054c0.497,0.542,0.798,1.235,0.798,2.082 c0,2.981-1.814,3.637-3.543,3.829c0.279,0.24,0.527,0.713,0.527,1.437c0,1.037-0.01,1.874-0.01,2.129 c0,0.208,0.14,0.449,0.534,0.373c3.081-1.028,5.302-3.935,5.302-7.362C15.76,3.906,12.285,0.431,7.999,0.431z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<a href="https://twitter.com/{{ include.username }}"><span class="icon icon--twitter">{% include icon-twitter.svg %}</span><span class="username">{{ include.username }}</span></a>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg viewBox="0 0 16 16"><path fill="#828282" d="M15.969,3.058c-0.586,0.26-1.217,0.436-1.878,0.515c0.675-0.405,1.194-1.045,1.438-1.809c-0.632,0.375-1.332,0.647-2.076,0.793c-0.596-0.636-1.446-1.033-2.387-1.033c-1.806,0-3.27,1.464-3.27,3.27 c0,0.256,0.029,0.506,0.085,0.745C5.163,5.404,2.753,4.102,1.14,2.124C0.859,2.607,0.698,3.168,0.698,3.767 c0,1.134,0.577,2.135,1.455,2.722C1.616,6.472,1.112,6.325,0.671,6.08c0,0.014,0,0.027,0,0.041c0,1.584,1.127,2.906,2.623,3.206 C3.02,9.402,2.731,9.442,2.433,9.442c-0.211,0-0.416-0.021-0.615-0.059c0.416,1.299,1.624,2.245,3.055,2.271 c-1.119,0.877-2.529,1.4-4.061,1.4c-0.264,0-0.524-0.015-0.78-0.046c1.447,0.928,3.166,1.469,5.013,1.469 c6.015,0,9.304-4.983,9.304-9.304c0-0.142-0.003-0.283-0.009-0.423C14.976,4.29,15.531,3.714,15.969,3.058z"/></svg>
|
data/lib/site_template/about.md
CHANGED
@@ -6,6 +6,10 @@ permalink: /about/
|
|
6
6
|
|
7
7
|
This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](http://jekyllrb.com/)
|
8
8
|
|
9
|
-
You can find the source code for the Jekyll new theme at:
|
9
|
+
You can find the source code for the Jekyll new theme at:
|
10
|
+
{% include icon-github.html username="jglovier" %} /
|
11
|
+
[jekyll-new](https://github.com/jglovier/jekyll-new)
|
10
12
|
|
11
|
-
You can find the source code for Jekyll at
|
13
|
+
You can find the source code for Jekyll at
|
14
|
+
{% include icon-github.html username="jekyll" %} /
|
15
|
+
[jekyll](https://github.com/jekyll/jekyll)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.0.pre.
|
4
|
+
version: 3.0.0.pre.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Preston-Werner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -154,7 +154,6 @@ files:
|
|
154
154
|
- lib/jekyll/convertible.rb
|
155
155
|
- lib/jekyll/deprecator.rb
|
156
156
|
- lib/jekyll/document.rb
|
157
|
-
- lib/jekyll/draft.rb
|
158
157
|
- lib/jekyll/entry_filter.rb
|
159
158
|
- lib/jekyll/errors.rb
|
160
159
|
- lib/jekyll/excerpt.rb
|
@@ -173,12 +172,10 @@ files:
|
|
173
172
|
- lib/jekyll/page.rb
|
174
173
|
- lib/jekyll/plugin.rb
|
175
174
|
- lib/jekyll/plugin_manager.rb
|
176
|
-
- lib/jekyll/post.rb
|
177
175
|
- lib/jekyll/publisher.rb
|
178
176
|
- lib/jekyll/reader.rb
|
179
177
|
- lib/jekyll/readers/collection_reader.rb
|
180
178
|
- lib/jekyll/readers/data_reader.rb
|
181
|
-
- lib/jekyll/readers/draft_reader.rb
|
182
179
|
- lib/jekyll/readers/layout_reader.rb
|
183
180
|
- lib/jekyll/readers/page_reader.rb
|
184
181
|
- lib/jekyll/readers/post_reader.rb
|
@@ -201,6 +198,10 @@ files:
|
|
201
198
|
- lib/site_template/_includes/footer.html
|
202
199
|
- lib/site_template/_includes/head.html
|
203
200
|
- lib/site_template/_includes/header.html
|
201
|
+
- lib/site_template/_includes/icon-github.html
|
202
|
+
- lib/site_template/_includes/icon-github.svg
|
203
|
+
- lib/site_template/_includes/icon-twitter.html
|
204
|
+
- lib/site_template/_includes/icon-twitter.svg
|
204
205
|
- lib/site_template/_layouts/default.html
|
205
206
|
- lib/site_template/_layouts/page.html
|
206
207
|
- lib/site_template/_layouts/post.html
|
data/lib/jekyll/draft.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
|
3
|
-
class Draft < Post
|
4
|
-
|
5
|
-
# Valid post name regex (no date)
|
6
|
-
MATCHER = /^(.*)(\.[^.]+)$/
|
7
|
-
|
8
|
-
# Draft name validator. Draft filenames must be like:
|
9
|
-
# my-awesome-post.textile
|
10
|
-
#
|
11
|
-
# Returns true if valid, false if not.
|
12
|
-
def self.valid?(name)
|
13
|
-
name =~ MATCHER
|
14
|
-
end
|
15
|
-
|
16
|
-
# Get the full path to the directory containing the draft files
|
17
|
-
def containing_dir(dir)
|
18
|
-
site.in_source_dir(dir, '_drafts')
|
19
|
-
end
|
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
|
-
|
26
|
-
# Extract information from the post filename.
|
27
|
-
#
|
28
|
-
# name - The String filename of the post file.
|
29
|
-
#
|
30
|
-
# Returns nothing.
|
31
|
-
def process(name)
|
32
|
-
m, slug, ext = *name.match(MATCHER)
|
33
|
-
self.date = File.mtime(File.join(@base, name))
|
34
|
-
self.slug = slug
|
35
|
-
self.ext = ext
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
data/lib/jekyll/post.rb
DELETED
@@ -1,334 +0,0 @@
|
|
1
|
-
module Jekyll
|
2
|
-
class Post
|
3
|
-
include Comparable
|
4
|
-
include Convertible
|
5
|
-
|
6
|
-
# Valid post name regex.
|
7
|
-
MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)(\.[^.]+)$/
|
8
|
-
|
9
|
-
EXCERPT_ATTRIBUTES_FOR_LIQUID = %w[
|
10
|
-
title
|
11
|
-
url
|
12
|
-
dir
|
13
|
-
date
|
14
|
-
id
|
15
|
-
categories
|
16
|
-
next
|
17
|
-
previous
|
18
|
-
tags
|
19
|
-
path
|
20
|
-
]
|
21
|
-
|
22
|
-
# Attributes for Liquid templates
|
23
|
-
ATTRIBUTES_FOR_LIQUID = EXCERPT_ATTRIBUTES_FOR_LIQUID + %w[
|
24
|
-
content
|
25
|
-
excerpt
|
26
|
-
excerpt_separator
|
27
|
-
draft?
|
28
|
-
]
|
29
|
-
|
30
|
-
# Post name validator. Post filenames must be like:
|
31
|
-
# 2008-11-05-my-awesome-post.textile
|
32
|
-
#
|
33
|
-
# Returns true if valid, false if not.
|
34
|
-
def self.valid?(name)
|
35
|
-
name =~ MATCHER
|
36
|
-
end
|
37
|
-
|
38
|
-
attr_accessor :site
|
39
|
-
attr_accessor :data, :extracted_excerpt, :content, :output, :ext
|
40
|
-
attr_accessor :date, :slug, :tags, :categories
|
41
|
-
|
42
|
-
attr_reader :name
|
43
|
-
|
44
|
-
# Initialize this Post instance.
|
45
|
-
#
|
46
|
-
# site - The Site.
|
47
|
-
# base - The String path to the dir containing the post file.
|
48
|
-
# name - The String filename of the post file.
|
49
|
-
#
|
50
|
-
# Returns the new Post.
|
51
|
-
def initialize(site, source, dir, name)
|
52
|
-
@site = site
|
53
|
-
@dir = dir
|
54
|
-
@base = containing_dir(dir)
|
55
|
-
@name = name
|
56
|
-
|
57
|
-
self.categories = dir.split('/').reject { |x| x.empty? }
|
58
|
-
process(name)
|
59
|
-
read_yaml(@base, name)
|
60
|
-
|
61
|
-
data.default_proc = proc do |hash, key|
|
62
|
-
site.frontmatter_defaults.find(relative_path, type, key)
|
63
|
-
end
|
64
|
-
|
65
|
-
if data.key?('date')
|
66
|
-
self.date = Utils.parse_date(data["date"].to_s, "Post '#{relative_path}' does not have a valid date in the YAML front matter.")
|
67
|
-
end
|
68
|
-
|
69
|
-
populate_categories
|
70
|
-
populate_tags
|
71
|
-
|
72
|
-
Jekyll::Hooks.trigger :post, :post_init, self
|
73
|
-
end
|
74
|
-
|
75
|
-
def published?
|
76
|
-
if data.key?('published') && data['published'] == false
|
77
|
-
false
|
78
|
-
else
|
79
|
-
true
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def populate_categories
|
84
|
-
categories_from_data = Utils.pluralized_array_from_hash(data, 'category', 'categories')
|
85
|
-
self.categories = (
|
86
|
-
Array(categories) + categories_from_data
|
87
|
-
).map { |c| c.to_s }.flatten.uniq
|
88
|
-
end
|
89
|
-
|
90
|
-
def populate_tags
|
91
|
-
self.tags = Utils.pluralized_array_from_hash(data, "tag", "tags").flatten
|
92
|
-
end
|
93
|
-
|
94
|
-
# Get the full path to the directory containing the post files
|
95
|
-
def containing_dir(dir)
|
96
|
-
site.in_source_dir(dir, '_posts')
|
97
|
-
end
|
98
|
-
|
99
|
-
# Read the YAML frontmatter.
|
100
|
-
#
|
101
|
-
# base - The String path to the dir containing the file.
|
102
|
-
# name - The String filename of the file.
|
103
|
-
#
|
104
|
-
# Returns nothing.
|
105
|
-
def read_yaml(base, name)
|
106
|
-
super(base, name)
|
107
|
-
self.extracted_excerpt = extract_excerpt
|
108
|
-
end
|
109
|
-
|
110
|
-
# The post excerpt. This is either a custom excerpt
|
111
|
-
# set in YAML front matter or the result of extract_excerpt.
|
112
|
-
#
|
113
|
-
# Returns excerpt string.
|
114
|
-
def excerpt
|
115
|
-
data.fetch('excerpt') { extracted_excerpt.to_s }
|
116
|
-
end
|
117
|
-
|
118
|
-
# Public: the Post title, from the YAML Front-Matter or from the slug
|
119
|
-
#
|
120
|
-
# Returns the post title
|
121
|
-
def title
|
122
|
-
data.fetch('title') { titleized_slug }
|
123
|
-
end
|
124
|
-
|
125
|
-
# Public: the Post excerpt_separator, from the YAML Front-Matter or site default
|
126
|
-
# excerpt_separator value
|
127
|
-
#
|
128
|
-
# Returns the post excerpt_separator
|
129
|
-
def excerpt_separator
|
130
|
-
(data['excerpt_separator'] || site.config['excerpt_separator']).to_s
|
131
|
-
end
|
132
|
-
|
133
|
-
# Turns the post slug into a suitable title
|
134
|
-
def titleized_slug
|
135
|
-
slug.split('-').select {|w| w.capitalize! || w }.join(' ')
|
136
|
-
end
|
137
|
-
|
138
|
-
# Public: the path to the post relative to the site source,
|
139
|
-
# from the YAML Front-Matter or from a combination of
|
140
|
-
# the directory it's in, "_posts", and the name of the
|
141
|
-
# post file
|
142
|
-
#
|
143
|
-
# Returns the path to the file relative to the site source
|
144
|
-
def path
|
145
|
-
data.fetch('path') { relative_path.sub(/\A\//, '') }
|
146
|
-
end
|
147
|
-
|
148
|
-
# The path to the post source file, relative to the site source
|
149
|
-
def relative_path
|
150
|
-
File.join(*[@dir, "_posts", @name].map(&:to_s).reject(&:empty?))
|
151
|
-
end
|
152
|
-
|
153
|
-
# Compares Post objects. First compares the Post date. If the dates are
|
154
|
-
# equal, it compares the Post slugs.
|
155
|
-
#
|
156
|
-
# other - The other Post we are comparing to.
|
157
|
-
#
|
158
|
-
# Returns -1, 0, 1
|
159
|
-
def <=>(other)
|
160
|
-
cmp = self.date <=> other.date
|
161
|
-
if 0 == cmp
|
162
|
-
cmp = self.slug <=> other.slug
|
163
|
-
end
|
164
|
-
return cmp
|
165
|
-
end
|
166
|
-
|
167
|
-
# Extract information from the post filename.
|
168
|
-
#
|
169
|
-
# name - The String filename of the post file.
|
170
|
-
#
|
171
|
-
# Returns nothing.
|
172
|
-
def process(name)
|
173
|
-
m, cats, date, slug, ext = *name.match(MATCHER)
|
174
|
-
self.date = Utils.parse_date(date, "Post '#{relative_path}' does not have a valid date in the filename.")
|
175
|
-
self.slug = slug
|
176
|
-
self.ext = ext
|
177
|
-
end
|
178
|
-
|
179
|
-
# The generated directory into which the post will be placed
|
180
|
-
# upon generation. This is derived from the permalink or, if
|
181
|
-
# permalink is absent, set to the default date
|
182
|
-
# e.g. "/2008/11/05/" if the permalink style is :date, otherwise nothing.
|
183
|
-
#
|
184
|
-
# Returns the String directory.
|
185
|
-
def dir
|
186
|
-
File.dirname(url)
|
187
|
-
end
|
188
|
-
|
189
|
-
# The full path and filename of the post. Defined in the YAML of the post
|
190
|
-
# body (optional).
|
191
|
-
#
|
192
|
-
# Returns the String permalink.
|
193
|
-
def permalink
|
194
|
-
data && data['permalink']
|
195
|
-
end
|
196
|
-
|
197
|
-
def template
|
198
|
-
case site.permalink_style
|
199
|
-
when :pretty
|
200
|
-
"/:categories/:year/:month/:day/:title/"
|
201
|
-
when :none
|
202
|
-
"/:categories/:title.html"
|
203
|
-
when :date
|
204
|
-
"/:categories/:year/:month/:day/:title.html"
|
205
|
-
when :ordinal
|
206
|
-
"/:categories/:year/:y_day/:title.html"
|
207
|
-
else
|
208
|
-
site.permalink_style.to_s
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
# The generated relative url of this post.
|
213
|
-
#
|
214
|
-
# Returns the String url.
|
215
|
-
def url
|
216
|
-
@url ||= URL.new({
|
217
|
-
:template => template,
|
218
|
-
:placeholders => url_placeholders,
|
219
|
-
:permalink => permalink
|
220
|
-
}).to_s
|
221
|
-
end
|
222
|
-
|
223
|
-
# Returns a hash of URL placeholder names (as symbols) mapping to the
|
224
|
-
# desired placeholder replacements. For details see "url.rb"
|
225
|
-
def url_placeholders
|
226
|
-
{
|
227
|
-
:year => date.strftime("%Y"),
|
228
|
-
:month => date.strftime("%m"),
|
229
|
-
:day => date.strftime("%d"),
|
230
|
-
:hour => date.strftime("%H"),
|
231
|
-
:minute => date.strftime("%M"),
|
232
|
-
:second => date.strftime("%S"),
|
233
|
-
:title => slug,
|
234
|
-
:i_day => date.strftime("%-d"),
|
235
|
-
:i_month => date.strftime("%-m"),
|
236
|
-
:categories => (categories || []).map { |c| c.to_s.downcase }.uniq.join('/'),
|
237
|
-
:short_month => date.strftime("%b"),
|
238
|
-
:short_year => date.strftime("%y"),
|
239
|
-
:y_day => date.strftime("%j"),
|
240
|
-
:output_ext => output_ext
|
241
|
-
}
|
242
|
-
end
|
243
|
-
|
244
|
-
# The UID for this post (useful in feeds).
|
245
|
-
# e.g. /2008/11/05/my-awesome-post
|
246
|
-
#
|
247
|
-
# Returns the String UID.
|
248
|
-
def id
|
249
|
-
File.join(dir, slug)
|
250
|
-
end
|
251
|
-
|
252
|
-
# Calculate related posts.
|
253
|
-
#
|
254
|
-
# Returns an Array of related Posts.
|
255
|
-
def related_posts(posts)
|
256
|
-
Jekyll::RelatedPosts.new(self).build
|
257
|
-
end
|
258
|
-
|
259
|
-
# Add any necessary layouts to this post.
|
260
|
-
#
|
261
|
-
# layouts - A Hash of {"name" => "layout"}.
|
262
|
-
# site_payload - The site payload hash.
|
263
|
-
#
|
264
|
-
# Returns nothing.
|
265
|
-
def render(layouts, site_payload)
|
266
|
-
# construct payload
|
267
|
-
payload = Utils.deep_merge_hashes({
|
268
|
-
"site" => { "related_posts" => related_posts(site_payload["site"]["posts"]) },
|
269
|
-
"page" => to_liquid(self.class::EXCERPT_ATTRIBUTES_FOR_LIQUID)
|
270
|
-
}, site_payload)
|
271
|
-
|
272
|
-
if generate_excerpt?
|
273
|
-
extracted_excerpt.do_layout(payload, {})
|
274
|
-
end
|
275
|
-
|
276
|
-
do_layout(payload.merge({"page" => to_liquid}), layouts)
|
277
|
-
end
|
278
|
-
|
279
|
-
# Obtain destination path.
|
280
|
-
#
|
281
|
-
# dest - The String path to the destination dir.
|
282
|
-
#
|
283
|
-
# Returns destination file path String.
|
284
|
-
def destination(dest)
|
285
|
-
# The url needs to be unescaped in order to preserve the correct filename
|
286
|
-
path = site.in_dest_dir(dest, URL.unescape_path(url))
|
287
|
-
path = File.join(path, "index.html") if self.url.end_with?("/")
|
288
|
-
path << output_ext unless path.end_with?(output_ext)
|
289
|
-
path
|
290
|
-
end
|
291
|
-
|
292
|
-
# Returns the shorthand String identifier of this Post.
|
293
|
-
def inspect
|
294
|
-
"<Post: #{id}>"
|
295
|
-
end
|
296
|
-
|
297
|
-
def next
|
298
|
-
pos = site.posts.index {|post| post.equal?(self) }
|
299
|
-
if pos && pos < site.posts.length - 1
|
300
|
-
site.posts[pos + 1]
|
301
|
-
else
|
302
|
-
nil
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
def previous
|
307
|
-
pos = site.posts.index {|post| post.equal?(self) }
|
308
|
-
if pos && pos > 0
|
309
|
-
site.posts[pos - 1]
|
310
|
-
else
|
311
|
-
nil
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
# Returns if this Post is a Draft
|
316
|
-
def draft?
|
317
|
-
is_a?(Jekyll::Draft)
|
318
|
-
end
|
319
|
-
|
320
|
-
protected
|
321
|
-
|
322
|
-
def extract_excerpt
|
323
|
-
if generate_excerpt?
|
324
|
-
Jekyll::Excerpt.new(self)
|
325
|
-
else
|
326
|
-
""
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
def generate_excerpt?
|
331
|
-
!excerpt_separator.empty?
|
332
|
-
end
|
333
|
-
end
|
334
|
-
end
|