jekyll-feed 0.9.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/History.markdown +115 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +118 -4
  5. data/lib/jekyll-feed.rb +2 -0
  6. data/lib/jekyll-feed/feed.xml +45 -15
  7. data/lib/jekyll-feed/generator.rb +109 -24
  8. data/lib/jekyll-feed/meta-tag.rb +9 -8
  9. data/lib/jekyll-feed/page-without-a-file.rb +2 -0
  10. data/lib/jekyll-feed/version.rb +7 -0
  11. metadata +49 -78
  12. data/.gitignore +0 -20
  13. data/.rspec +0 -2
  14. data/.rubocop.yml +0 -29
  15. data/.travis.yml +0 -20
  16. data/Gemfile +0 -6
  17. data/Rakefile +0 -6
  18. data/jekyll-feed.gemspec +0 -25
  19. data/script/bootstrap +0 -3
  20. data/script/cibuild +0 -7
  21. data/script/release +0 -7
  22. data/spec/fixtures/_config.yml +0 -9
  23. data/spec/fixtures/_data/authors.yml +0 -5
  24. data/spec/fixtures/_drafts/2015-01-12-a-draft.md +0 -4
  25. data/spec/fixtures/_layouts/some_default.html +0 -11
  26. data/spec/fixtures/_posts/2013-12-12-dec-the-second.md +0 -6
  27. data/spec/fixtures/_posts/2014-03-02-march-the-second.md +0 -5
  28. data/spec/fixtures/_posts/2014-03-04-march-the-fourth.md +0 -8
  29. data/spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md +0 -5
  30. data/spec/fixtures/_posts/2015-02-12-strip-newlines.md +0 -6
  31. data/spec/fixtures/_posts/2015-05-12-liquid.md +0 -7
  32. data/spec/fixtures/_posts/2015-05-12-pre.html +0 -7
  33. data/spec/fixtures/_posts/2015-05-18-author-detail.md +0 -9
  34. data/spec/fixtures/_posts/2015-08-08-stuck-in-the-middle.html +0 -2
  35. data/spec/fixtures/_posts/2016-04-25-author-reference.md +0 -6
  36. data/spec/fixtures/feed.xslt.xml +0 -0
  37. data/spec/jekyll-feed_spec.rb +0 -278
  38. data/spec/spec_helper.rb +0 -28
@@ -1,5 +0,0 @@
1
- garthdb:
2
- name: Garth
3
- twitter: garthdb
4
- uri: "http://garthdb.com"
5
- email: example@mail.com
@@ -1,4 +0,0 @@
1
- ---
2
- ---
3
-
4
- This is a draft.
@@ -1,11 +0,0 @@
1
- ---
2
- ---
3
- <html>
4
- <head>
5
- {% feed_meta %}
6
- </head>
7
- <body>
8
- THIS IS MY LAYOUT
9
- {{ content }}
10
- </body>
11
- </html>
@@ -1,6 +0,0 @@
1
- ---
2
- excerpt: "Foo"
3
- image: "/image.png"
4
- ---
5
-
6
- # December the twelfth, actually.
@@ -1,5 +0,0 @@
1
- ---
2
- image: "https://cdn.example.org/absolute.png"
3
- ---
4
-
5
- March the second!
@@ -1,8 +0,0 @@
1
- ---
2
- tags:
3
- - '"/><VADER>'
4
- image:
5
- path: "/object-image.png"
6
- ---
7
-
8
- March the fourth!
@@ -1,5 +0,0 @@
1
- ---
2
- last_modified_at: 2015-05-12T13:27:59+00:00
3
- ---
4
-
5
- Please don't modify this file. It's modified time is important.
@@ -1,6 +0,0 @@
1
- ---
2
- title:
3
- The plugin
4
- will properly
5
- strip newlines.
6
- ---
@@ -1,7 +0,0 @@
1
- ---
2
- ---
3
-
4
- {% capture liquidstring %}
5
- Liquid is not rendered.
6
- {% endcapture %}
7
- {{ liquidstring | replace:'not ','' }}
@@ -1,7 +0,0 @@
1
- ---
2
- author: Pat
3
- ---
4
-
5
- <pre>Line 1
6
- Line 2
7
- Line 3</pre>
@@ -1,9 +0,0 @@
1
- ---
2
- excerpt: ""
3
- author:
4
- name: Ben
5
- uri: "http://ben.balter.com"
6
- email: ben@example.com
7
- ---
8
-
9
- # December the twelfth, actually.
@@ -1,6 +0,0 @@
1
- ---
2
- excerpt: ""
3
- author: garthdb
4
- ---
5
-
6
- # April the twenty-fifth?
File without changes
@@ -1,278 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe(JekyllFeed) do
4
- let(:overrides) { Hash.new }
5
- let(:config) do
6
- Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
7
- "full_rebuild" => true,
8
- "source" => source_dir,
9
- "destination" => dest_dir,
10
- "show_drafts" => true,
11
- "url" => "http://example.org",
12
- "name" => "My awesome site",
13
- "author" => {
14
- "name" => "Dr. Jekyll"
15
- },
16
- "collections" => {
17
- "my_collection" => { "output" => true },
18
- "other_things" => { "output" => false }
19
- }
20
- }, overrides))
21
- end
22
- let(:site) { Jekyll::Site.new(config) }
23
- let(:contents) { File.read(dest_dir("feed.xml")) }
24
- let(:context) { make_context(site: site) }
25
- let(:feed_meta) { Liquid::Template.parse("{% feed_meta %}").render!(context, {}) }
26
- before(:each) do
27
- site.process
28
- end
29
-
30
- it "has no layout" do
31
- expect(contents).not_to match(/\ATHIS IS MY LAYOUT/)
32
- end
33
-
34
- it "creates a feed.xml file" do
35
- expect(Pathname.new(dest_dir("feed.xml"))).to exist
36
- end
37
-
38
-
39
- it "doesn't have multiple new lines or trailing whitespace" do
40
- expect(contents).to_not match /\s+\n/
41
- expect(contents).to_not match /\n{2,}/
42
- end
43
-
44
- it "puts all the posts in the feed.xml file" do
45
- expect(contents).to match /http:\/\/example\.org\/2014\/03\/04\/march-the-fourth\.html/
46
- expect(contents).to match /http:\/\/example\.org\/2014\/03\/02\/march-the-second\.html/
47
- expect(contents).to match /http:\/\/example\.org\/2013\/12\/12\/dec-the-second\.html/
48
- expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
49
- expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/
50
- end
51
-
52
- it "does not include assets or any static files that aren't .html" do
53
- expect(contents).not_to match /http:\/\/example\.org\/images\/hubot\.png/
54
- expect(contents).not_to match /http:\/\/example\.org\/feeds\/atom\.xml/
55
- end
56
-
57
- it "preserves linebreaks in preformatted text in posts" do
58
- expect(contents).to match /Line 1\nLine 2\nLine 3/
59
- end
60
-
61
- it "supports post author name as an object" do
62
- expect(contents).to match /<author>\s*<name>Ben<\/name>\s*<email>ben@example.com<\/email>\s*<uri>http:\/\/ben.balter.com<\/uri>\s*<\/author>/
63
- end
64
-
65
- it "supports post author name as a string" do
66
- expect(contents).to match /<author>\s*<name>Pat<\/name>\s*<\/author>/
67
- end
68
-
69
- it "does not output author tag no author is provided" do
70
- expect(contents).not_to match /<author>\s*<name><\/name>\s*<\/author>/
71
- end
72
-
73
- it "does use author reference with data from _data/authors.yml" do
74
- expect(contents).to match /<author>\s*<name>Garth<\/name>\s*<email>example@mail.com<\/email>\s*<uri>http:\/\/garthdb.com<\/uri>\s*<\/author>/
75
- end
76
-
77
- it "converts markdown posts to HTML" do
78
- expect(contents).to match /&lt;p&gt;March the second!&lt;\/p&gt;/
79
- end
80
-
81
- it "uses last_modified_at where available" do
82
- expect(contents).to match /<updated>2015-05-12T13:27:59\+00:00<\/updated>/
83
- end
84
-
85
- it "replaces newlines in posts to spaces" do
86
- expect(contents).to match %r!<title type="html">The plugin will properly strip newlines.</title>!
87
- end
88
-
89
- it "renders Liquid inside posts" do
90
- expect(contents).to match /Liquid is rendered\./
91
- expect(contents).not_to match /Liquid is not rendered\./
92
- end
93
-
94
- it "includes the item image" do
95
- expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/image.png" />')
96
- expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://cdn.example.org/absolute.png" />')
97
- expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/object-image.png" />')
98
- end
99
-
100
- context "parsing" do
101
- let(:feed) { RSS::Parser.parse(contents) }
102
-
103
- it "outputs an RSS feed" do
104
- expect(feed.feed_type).to eql("atom")
105
- expect(feed.feed_version).to eql("1.0")
106
- expect(feed.encoding).to eql("UTF-8")
107
- end
108
-
109
- it "outputs the link" do
110
- expect(feed.link.href).to eql("http://example.org/feed.xml")
111
- end
112
-
113
- it "outputs the generator" do
114
- expect(feed.generator.content).to eql("Jekyll")
115
- expect(feed.generator.version).to eql(Jekyll::VERSION)
116
- end
117
-
118
- it "includes the items" do
119
- expect(feed.items.count).to eql(10)
120
- end
121
-
122
- it "includes item contents" do
123
- post = feed.items.last
124
- expect(post.title.content).to eql("Dec The Second")
125
- expect(post.link.href).to eql("http://example.org/2013/12/12/dec-the-second.html")
126
- expect(post.published.content).to eql(Time.parse("2013-12-12"))
127
- end
128
-
129
- it "includes the item's excerpt" do
130
- post = feed.items.last
131
- expect(post.summary.content).to eql("Foo")
132
- end
133
-
134
- it "doesn't include the item's excerpt if blank" do
135
- post = feed.items.first
136
- expect(post.summary).to be_nil
137
- end
138
-
139
- context "with site.title set" do
140
- let(:site_title) { "My Site Title" }
141
- let(:overrides) { {"title" => site_title} }
142
-
143
- it "uses site.title for the title" do
144
- expect(feed.title.content).to eql(site_title)
145
- end
146
- end
147
-
148
- context "with site.name set" do
149
- let(:site_name) { "My Site Name" }
150
- let(:overrides) { {"name" => site_name} }
151
-
152
- it "uses site.name for the title" do
153
- expect(feed.title.content).to eql(site_name)
154
- end
155
- end
156
-
157
- context "with site.name and site.title set" do
158
- let(:site_title) { "My Site Title" }
159
- let(:site_name) { "My Site Name" }
160
- let(:overrides) { {"title" => site_title, "name" => site_name} }
161
-
162
- it "uses site.title for the title, dropping site.name" do
163
- expect(feed.title.content).to eql(site_title)
164
- end
165
- end
166
- end
167
-
168
- context "smartify" do
169
- let(:site_title) { "Pat's Site" }
170
- let(:overrides) { { "title" => site_title } }
171
- let(:feed) { RSS::Parser.parse(contents) }
172
-
173
- it "processes site title with SmartyPants" do
174
- expect(feed.title.content).to eql("Pat’s Site")
175
- end
176
- end
177
-
178
- context "validation" do
179
- it "validates" do
180
- # See https://validator.w3.org/docs/api.html
181
- url = "https://validator.w3.org/feed/check.cgi?output=soap12"
182
- response = Typhoeus.post(url, body: { rawdata: contents }, accept_encoding: "gzip")
183
- pending "Something went wrong with the W3 validator" unless response.success?
184
- result = Nokogiri::XML(response.body)
185
- result.remove_namespaces!
186
-
187
- result.css("warning").each do |warning|
188
- # Quiet a warning that results from us passing the feed as a string
189
- next if warning.css("text").text =~ /Self reference doesn't match document location/
190
-
191
- # Quiet expected warning that results from blank summary test case
192
- next if warning.css("text").text =~ /(content|summary) should not be blank/
193
-
194
- # Quiet expected warning about multiple posts with same updated time
195
- next if warning.css("text").text =~ /Two entries with the same value for atom:updated/
196
-
197
- warn "Validation warning: #{warning.css("text").text} on line #{warning.css("line").text} column #{warning.css("column").text}"
198
- end
199
-
200
- errors = result.css("error").map do |error|
201
- "Validation error: #{error.css("text").text} on line #{error.css("line").text} column #{error.css("column").text}"
202
- end
203
-
204
- expect(result.css("validity").text).to eql("true"), errors.join("\n")
205
- end
206
- end
207
-
208
- context "with a baseurl" do
209
- let(:overrides) do
210
- { "baseurl" => "/bass" }
211
- end
212
-
213
- it "correctly adds the baseurl to the posts" do
214
- expect(contents).to match /http:\/\/example\.org\/bass\/2014\/03\/04\/march-the-fourth\.html/
215
- expect(contents).to match /http:\/\/example\.org\/bass\/2014\/03\/02\/march-the-second\.html/
216
- expect(contents).to match /http:\/\/example\.org\/bass\/2013\/12\/12\/dec-the-second\.html/
217
- end
218
-
219
- it "renders the feed meta" do
220
- expected = 'href="http://example.org/bass/feed.xml"'
221
- expect(feed_meta).to include(expected)
222
- end
223
- end
224
-
225
- context "feed meta" do
226
- it "renders the feed meta" do
227
- expected = '<link type="application/atom+xml" rel="alternate" href="http://example.org/feed.xml" title="My awesome site" />'
228
- expect(feed_meta).to eql(expected)
229
- end
230
-
231
- context "with a blank site name" do
232
- let(:config) do
233
- Jekyll.configuration({
234
- "source" => source_dir,
235
- "destination" => dest_dir,
236
- "url" => "http://example.org"
237
- })
238
- end
239
-
240
- it "does not output blank title" do
241
- expect(feed_meta).not_to include('title=')
242
- end
243
- end
244
- end
245
-
246
- context "changing the feed path" do
247
- let(:overrides) do
248
- {
249
- "feed" => {
250
- "path" => "atom.xml"
251
- }
252
- }
253
- end
254
-
255
- it "should write to atom.xml" do
256
- expect(Pathname.new(dest_dir("atom.xml"))).to exist
257
- end
258
-
259
- it "renders the feed meta with custom feed path" do
260
- expected = 'href="http://example.org/atom.xml"'
261
- expect(feed_meta).to include(expected)
262
- end
263
- end
264
-
265
- context "feed stylesheet" do
266
- it "includes the stylesheet" do
267
- expect(contents).to include('<?xml-stylesheet type="text/xml" href="http://example.org/feed.xslt.xml"?>')
268
- end
269
- end
270
-
271
- context "with site.lang set" do
272
- let(:overrides) { { "lang" => "en-US" } }
273
-
274
- it "should set the language" do
275
- expect(contents).to match %r{type="text/html" hreflang="en-US" />}
276
- end
277
- end
278
- end
data/spec/spec_helper.rb DELETED
@@ -1,28 +0,0 @@
1
- require 'jekyll'
2
- require 'typhoeus'
3
- require 'nokogiri'
4
- require 'rss'
5
- require File.expand_path('../lib/jekyll-feed', File.dirname(__FILE__))
6
-
7
- Jekyll.logger.log_level = :error
8
-
9
- RSpec.configure do |config|
10
- config.run_all_when_everything_filtered = true
11
- config.filter_run :focus
12
- config.order = 'random'
13
-
14
- SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
15
- DEST_DIR = File.expand_path("../dest", __FILE__)
16
-
17
- def source_dir(*files)
18
- File.join(SOURCE_DIR, *files)
19
- end
20
-
21
- def dest_dir(*files)
22
- File.join(DEST_DIR, *files)
23
- end
24
-
25
- def make_context(registers = {})
26
- Liquid::Context.new({}, {}, { site: site }.merge(registers))
27
- end
28
- end