jekyll-feed 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +17 -20
- data/History.markdown +5 -0
- data/jekyll-feed.gemspec +1 -1
- data/lib/feed.xml +7 -5
- data/lib/jekyll-feed.rb +19 -25
- data/script/cibuild +1 -1
- data/spec/fixtures/_posts/2013-12-12-dec-the-second.md +1 -0
- data/spec/fixtures/_posts/2015-02-12-strip-newlines.md +6 -0
- data/spec/fixtures/_posts/2015-05-12-liquid.md +7 -0
- data/spec/fixtures/_posts/2015-05-18-author-detail.md +1 -0
- data/spec/jekyll-feed_spec.rb +61 -12
- metadata +8 -27
- data/spec/fixtures/_my_collection/custom_permalink.md +0 -5
- data/spec/fixtures/_my_collection/custom_permalink_2.md +0 -5
- data/spec/fixtures/_my_collection/test.html +0 -4
- data/spec/fixtures/_other_things/test2.html +0 -4
- data/spec/fixtures/_posts/2014-05-11-exclude-this-post.md +0 -5
- data/spec/fixtures/feeds/atom.xml +0 -6
- data/spec/fixtures/images/hubot.png +0 -0
- data/spec/fixtures/jekyll-last-modified-at/page.html +0 -4
- data/spec/fixtures/some-subfolder/exclude-this-page.html +0 -5
- data/spec/fixtures/some-subfolder/test_index.html +0 -4
- data/spec/fixtures/some-subfolder/this-is-a-subfile.html +0 -0
- data/spec/fixtures/some-subfolder/this-is-a-subpage.html +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f446d429dab098b3e1f5223df91297057ddcb61
|
4
|
+
data.tar.gz: 3b71084e350e4ce5f7c9ba4b8594b8b52c0bd239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcd339a74b9f38edb29d218fa58d8432e4b48a957942980ecaab9c89f9824987e5363d284bebc3d9be5759be2f77c9c0e298147a6904296071018e44a3cfe14f
|
7
|
+
data.tar.gz: 39b527846ec7e0a93150df7b22639a0a0e3b79c4857d64de71aa3b875912f812badce5f2e43494550c5cd05af51164d13b38729836cda176f7270333a45b259b
|
data/.travis.yml
CHANGED
@@ -1,25 +1,22 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
5
|
-
- 2.0
|
6
|
-
- 1.9
|
7
|
-
script: "script/cibuild"
|
8
|
-
before_script: bundle update
|
9
|
-
cache: bundler
|
10
|
-
sudo: false
|
11
|
-
|
3
|
+
- 2.2
|
4
|
+
- 2.1
|
5
|
+
- 2.0
|
12
6
|
matrix:
|
13
|
-
|
14
|
-
-
|
15
|
-
|
16
|
-
|
17
|
-
rvm: 2.1
|
18
|
-
- rvm: 2.2
|
19
|
-
env: JEKYLL_VERSION=2.4
|
20
|
-
|
7
|
+
include:
|
8
|
+
- # Ruby 1.9
|
9
|
+
rvm: 1.9
|
10
|
+
env: JEKYLL_VERSION=2.0
|
21
11
|
env:
|
12
|
+
global:
|
13
|
+
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
22
14
|
matrix:
|
23
|
-
-
|
24
|
-
- JEKYLL_VERSION=2.
|
25
|
-
|
15
|
+
- JEKYLL_VERSION=3.0
|
16
|
+
- JEKYLL_VERSION=2.5
|
17
|
+
cache: bundler
|
18
|
+
sudo: false
|
19
|
+
before_script: bundle update
|
20
|
+
script: ./script/cibuild
|
21
|
+
notifications:
|
22
|
+
email: false
|
data/History.markdown
ADDED
data/jekyll-feed.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "jekyll-feed"
|
5
|
-
spec.version = "0.
|
5
|
+
spec.version = "0.4.0"
|
6
6
|
spec.authors = ["Ben Balter"]
|
7
7
|
spec.email = ["ben.balter@github.com"]
|
8
8
|
spec.summary = "A Jekyll plugin to generate an Atom feed of your Jekyll posts"
|
data/lib/feed.xml
CHANGED
@@ -11,7 +11,9 @@
|
|
11
11
|
<updated>{{ site.time | date_to_xmlschema }}</updated>
|
12
12
|
<id>{{ url_base | xml_escape }}/</id>
|
13
13
|
|
14
|
-
{% if site.
|
14
|
+
{% if site.title %}
|
15
|
+
<title>{{ site.title | xml_escape }}</title>
|
16
|
+
{% elsif site.name %}
|
15
17
|
<title>{{ site.name | xml_escape }}</title>
|
16
18
|
{% endif %}
|
17
19
|
|
@@ -37,7 +39,7 @@
|
|
37
39
|
|
38
40
|
{% for post in site.posts limit: 10 %}
|
39
41
|
<entry>
|
40
|
-
<title>{{ post.title | markdownify | strip_html |
|
42
|
+
<title>{{ post.title | markdownify | strip_html | replace: '\n', ' ' | strip | xml_escape }}</title>
|
41
43
|
<link href="{{ post.url | prepend: url_base }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
|
42
44
|
<published>{{ post.date | date_to_xmlschema }}</published>
|
43
45
|
{% if post.last_modified_at %}
|
@@ -47,7 +49,7 @@
|
|
47
49
|
{% endif %}
|
48
50
|
|
49
51
|
<id>{{ post.id | prepend: url_base | xml_escape }}</id>
|
50
|
-
<content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content |
|
52
|
+
<content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
|
51
53
|
|
52
54
|
{% if post.author %}
|
53
55
|
<author>
|
@@ -73,8 +75,8 @@
|
|
73
75
|
<category term="{{ tag | xml_escape }}" />
|
74
76
|
{% endfor %}
|
75
77
|
|
76
|
-
{% if post.excerpt and post.excerpt !=
|
77
|
-
<summary>{{ post.excerpt |
|
78
|
+
{% if post.excerpt and post.excerpt != empty %}
|
79
|
+
<summary>{{ post.excerpt | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
|
78
80
|
{% endif %}
|
79
81
|
</entry>
|
80
82
|
{% endfor %}
|
data/lib/jekyll-feed.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "fileutils"
|
2
2
|
|
3
3
|
module Jekyll
|
4
4
|
class PageWithoutAFile < Page
|
@@ -7,6 +7,12 @@ module Jekyll
|
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
+
module StripWhitespace
|
11
|
+
def strip(input)
|
12
|
+
input.to_s.strip
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
10
16
|
class FeedMetaTag < Liquid::Tag
|
11
17
|
def config
|
12
18
|
@context.registers[:site].config
|
@@ -52,9 +58,7 @@ module Jekyll
|
|
52
58
|
@site = site
|
53
59
|
@site.config["time"] = Time.new
|
54
60
|
unless feed_exists?
|
55
|
-
|
56
|
-
@site.keep_files ||= []
|
57
|
-
@site.keep_files << path
|
61
|
+
@site.pages << feed_content
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
@@ -63,27 +67,13 @@ module Jekyll
|
|
63
67
|
File.expand_path "feed.xml", File.dirname(__FILE__)
|
64
68
|
end
|
65
69
|
|
66
|
-
# Destination for feed.xml file within the site source directory
|
67
|
-
def destination_path
|
68
|
-
if @site.respond_to?(:in_dest_dir)
|
69
|
-
@site.in_dest_dir(path)
|
70
|
-
else
|
71
|
-
Jekyll.sanitized_path(@site.dest, path)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# copy feed template from source to destination
|
76
|
-
def write
|
77
|
-
FileUtils.mkdir_p File.dirname(destination_path)
|
78
|
-
File.open(destination_path, 'w') { |f| f.write(feed_content) }
|
79
|
-
end
|
80
|
-
|
81
70
|
def feed_content
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
71
|
+
feed = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", path)
|
72
|
+
feed.content = File.read(source_path).gsub(/\s*\n\s*/, "\n").gsub(/\s+{%/, "{%").gsub(/\s+</,"<")
|
73
|
+
feed.data["layout"] = nil
|
74
|
+
feed.data["sitemap"] = false
|
75
|
+
feed.output
|
76
|
+
feed
|
87
77
|
end
|
88
78
|
|
89
79
|
# Checks if a feed already exists in the site source
|
@@ -97,4 +87,8 @@ module Jekyll
|
|
97
87
|
end
|
98
88
|
end
|
99
89
|
|
100
|
-
Liquid::
|
90
|
+
unless defined? Liquid::StandardFilters.strip
|
91
|
+
Liquid::Template.register_filter(Jekyll::StripWhitespace)
|
92
|
+
end
|
93
|
+
|
94
|
+
Liquid::Template.register_tag("feed_meta", Jekyll::FeedMetaTag)
|
data/script/cibuild
CHANGED
data/spec/jekyll-feed_spec.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe(Jekyll::JekyllFeed) do
|
4
|
-
let(:overrides)
|
5
|
-
|
4
|
+
let(:overrides) { Hash.new }
|
5
|
+
let(:config) do
|
6
|
+
Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
|
6
7
|
"full_rebuild" => true,
|
7
8
|
"source" => source_dir,
|
8
9
|
"destination" => dest_dir,
|
@@ -15,10 +16,7 @@ describe(Jekyll::JekyllFeed) do
|
|
15
16
|
"my_collection" => { "output" => true },
|
16
17
|
"other_things" => { "output" => false }
|
17
18
|
}
|
18
|
-
}
|
19
|
-
end
|
20
|
-
let(:config) do
|
21
|
-
Jekyll.configuration(overrides)
|
19
|
+
}, overrides))
|
22
20
|
end
|
23
21
|
let(:site) { Jekyll::Site.new(config) }
|
24
22
|
let(:contents) { File.read(dest_dir("feed.xml")) }
|
@@ -74,6 +72,15 @@ describe(Jekyll::JekyllFeed) do
|
|
74
72
|
expect(contents).to match /<updated>2015-05-12T13:27:59\+00:00<\/updated>/
|
75
73
|
end
|
76
74
|
|
75
|
+
it "replaces newlines in posts to spaces" do
|
76
|
+
expect(contents).to match /<title>The plugin will properly strip newlines.<\/title>/
|
77
|
+
end
|
78
|
+
|
79
|
+
it "renders Liquid inside posts" do
|
80
|
+
expect(contents).to match /Liquid is rendered\./
|
81
|
+
expect(contents).not_to match /Liquid is not rendered\./
|
82
|
+
end
|
83
|
+
|
77
84
|
context "parsing" do
|
78
85
|
let(:feed) { RSS::Parser.parse(contents) }
|
79
86
|
|
@@ -93,7 +100,7 @@ describe(Jekyll::JekyllFeed) do
|
|
93
100
|
end
|
94
101
|
|
95
102
|
it "includes the items" do
|
96
|
-
expect(feed.items.count).to eql(
|
103
|
+
expect(feed.items.count).to eql(8)
|
97
104
|
end
|
98
105
|
|
99
106
|
it "includes item contents" do
|
@@ -102,6 +109,44 @@ describe(Jekyll::JekyllFeed) do
|
|
102
109
|
expect(post.link.href).to eql("http://example.org/2013/12/12/dec-the-second.html")
|
103
110
|
expect(post.published.content).to eql(Time.parse("2013-12-12"))
|
104
111
|
end
|
112
|
+
|
113
|
+
it "includes the item's excerpt" do
|
114
|
+
post = feed.items.last
|
115
|
+
expect(post.summary.content).to eql("Foo")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "doesn't include the item's excerpt if blank" do
|
119
|
+
post = feed.items.first
|
120
|
+
expect(post.summary).to be_nil
|
121
|
+
end
|
122
|
+
|
123
|
+
context "with site.title set" do
|
124
|
+
let(:site_title) { "My Site Title" }
|
125
|
+
let(:overrides) { {"title" => site_title} }
|
126
|
+
|
127
|
+
it "uses site.title for the title" do
|
128
|
+
expect(feed.title.content).to eql(site_title)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
context "with site.name set" do
|
133
|
+
let(:site_name) { "My Site Name" }
|
134
|
+
let(:overrides) { {"name" => site_name} }
|
135
|
+
|
136
|
+
it "uses site.name for the title" do
|
137
|
+
expect(feed.title.content).to eql(site_name)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "with site.name and site.title set" do
|
142
|
+
let(:site_title) { "My Site Title" }
|
143
|
+
let(:site_name) { "My Site Name" }
|
144
|
+
let(:overrides) { {"title" => site_title, "name" => site_name} }
|
145
|
+
|
146
|
+
it "uses site.title for the title, dropping site.name" do
|
147
|
+
expect(feed.title.content).to eql(site_title)
|
148
|
+
end
|
149
|
+
end
|
105
150
|
end
|
106
151
|
|
107
152
|
context "validation" do
|
@@ -128,8 +173,8 @@ describe(Jekyll::JekyllFeed) do
|
|
128
173
|
end
|
129
174
|
|
130
175
|
context "with a baseurl" do
|
131
|
-
let(:
|
132
|
-
|
176
|
+
let(:overrides) do
|
177
|
+
{ "baseurl" => "/bass" }
|
133
178
|
end
|
134
179
|
|
135
180
|
it "correctly adds the baseurl to the posts" do
|
@@ -148,10 +193,14 @@ describe(Jekyll::JekyllFeed) do
|
|
148
193
|
end
|
149
194
|
|
150
195
|
context "changing the feed path" do
|
151
|
-
let(:
|
152
|
-
|
196
|
+
let(:overrides) do
|
197
|
+
{
|
198
|
+
"feed" => {
|
199
|
+
"path" => "atom.xml"
|
200
|
+
}
|
201
|
+
}
|
153
202
|
end
|
154
|
-
|
203
|
+
|
155
204
|
it "should write to atom.xml" do
|
156
205
|
expect(Pathname.new(dest_dir("atom.xml"))).to exist
|
157
206
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-feed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- ".rspec"
|
126
126
|
- ".travis.yml"
|
127
127
|
- Gemfile
|
128
|
+
- History.markdown
|
128
129
|
- LICENSE.txt
|
129
130
|
- README.md
|
130
131
|
- Rakefile
|
@@ -136,25 +137,15 @@ files:
|
|
136
137
|
- script/release
|
137
138
|
- spec/fixtures/_config.yml
|
138
139
|
- spec/fixtures/_layouts/some_default.html
|
139
|
-
- spec/fixtures/_my_collection/custom_permalink.md
|
140
|
-
- spec/fixtures/_my_collection/custom_permalink_2.md
|
141
|
-
- spec/fixtures/_my_collection/test.html
|
142
|
-
- spec/fixtures/_other_things/test2.html
|
143
140
|
- spec/fixtures/_posts/2013-12-12-dec-the-second.md
|
144
141
|
- spec/fixtures/_posts/2014-03-02-march-the-second.md
|
145
142
|
- spec/fixtures/_posts/2014-03-04-march-the-fourth.md
|
146
|
-
- spec/fixtures/_posts/2014-05-11-exclude-this-post.md
|
147
143
|
- spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md
|
144
|
+
- spec/fixtures/_posts/2015-02-12-strip-newlines.md
|
145
|
+
- spec/fixtures/_posts/2015-05-12-liquid.md
|
148
146
|
- spec/fixtures/_posts/2015-05-12-pre.html
|
149
147
|
- spec/fixtures/_posts/2015-05-18-author-detail.md
|
150
|
-
- spec/fixtures/feeds/atom.xml
|
151
|
-
- spec/fixtures/images/hubot.png
|
152
148
|
- spec/fixtures/index.html
|
153
|
-
- spec/fixtures/jekyll-last-modified-at/page.html
|
154
|
-
- spec/fixtures/some-subfolder/exclude-this-page.html
|
155
|
-
- spec/fixtures/some-subfolder/test_index.html
|
156
|
-
- spec/fixtures/some-subfolder/this-is-a-subfile.html
|
157
|
-
- spec/fixtures/some-subfolder/this-is-a-subpage.html
|
158
149
|
- spec/jekyll-feed_spec.rb
|
159
150
|
- spec/spec_helper.rb
|
160
151
|
homepage: https://github.com/jekyll/jekyll-feed
|
@@ -177,31 +168,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
168
|
version: '0'
|
178
169
|
requirements: []
|
179
170
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.2.
|
171
|
+
rubygems_version: 2.2.5
|
181
172
|
signing_key:
|
182
173
|
specification_version: 4
|
183
174
|
summary: A Jekyll plugin to generate an Atom feed of your Jekyll posts
|
184
175
|
test_files:
|
185
176
|
- spec/fixtures/_config.yml
|
186
177
|
- spec/fixtures/_layouts/some_default.html
|
187
|
-
- spec/fixtures/_my_collection/custom_permalink.md
|
188
|
-
- spec/fixtures/_my_collection/custom_permalink_2.md
|
189
|
-
- spec/fixtures/_my_collection/test.html
|
190
|
-
- spec/fixtures/_other_things/test2.html
|
191
178
|
- spec/fixtures/_posts/2013-12-12-dec-the-second.md
|
192
179
|
- spec/fixtures/_posts/2014-03-02-march-the-second.md
|
193
180
|
- spec/fixtures/_posts/2014-03-04-march-the-fourth.md
|
194
|
-
- spec/fixtures/_posts/2014-05-11-exclude-this-post.md
|
195
181
|
- spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md
|
182
|
+
- spec/fixtures/_posts/2015-02-12-strip-newlines.md
|
183
|
+
- spec/fixtures/_posts/2015-05-12-liquid.md
|
196
184
|
- spec/fixtures/_posts/2015-05-12-pre.html
|
197
185
|
- spec/fixtures/_posts/2015-05-18-author-detail.md
|
198
|
-
- spec/fixtures/feeds/atom.xml
|
199
|
-
- spec/fixtures/images/hubot.png
|
200
186
|
- spec/fixtures/index.html
|
201
|
-
- spec/fixtures/jekyll-last-modified-at/page.html
|
202
|
-
- spec/fixtures/some-subfolder/exclude-this-page.html
|
203
|
-
- spec/fixtures/some-subfolder/test_index.html
|
204
|
-
- spec/fixtures/some-subfolder/this-is-a-subfile.html
|
205
|
-
- spec/fixtures/some-subfolder/this-is-a-subpage.html
|
206
187
|
- spec/jekyll-feed_spec.rb
|
207
188
|
- spec/spec_helper.rb
|
Binary file
|
File without changes
|