jekyll-feed 0.12.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.markdown +46 -1
- data/README.md +64 -2
- data/lib/jekyll-feed/feed.xml +25 -6
- data/lib/jekyll-feed/generator.rb +30 -2
- data/lib/jekyll-feed/meta-tag.rb +5 -2
- data/lib/jekyll-feed/version.rb +1 -1
- metadata +11 -59
- data/.gitignore +0 -21
- data/.rspec +0 -2
- data/.rubocop.yml +0 -27
- data/.travis.yml +0 -24
- data/Gemfile +0 -11
- data/Rakefile +0 -8
- data/appveyor.yml +0 -23
- data/jekyll-feed.gemspec +0 -30
- data/script/bootstrap +0 -3
- data/script/cibuild +0 -7
- data/script/fmt +0 -10
- data/script/release +0 -7
- data/script/test +0 -4
- data/spec/fixtures/_collection/2018-01-01-collection-doc.md +0 -4
- data/spec/fixtures/_collection/2018-01-02-collection-category-doc.md +0 -5
- data/spec/fixtures/_config.yml +0 -9
- data/spec/fixtures/_data/authors.yml +0 -5
- data/spec/fixtures/_drafts/2015-01-12-a-draft.md +0 -4
- data/spec/fixtures/_layouts/some_default.html +0 -11
- data/spec/fixtures/_posts/2013-12-12-dec-the-second.md +0 -7
- data/spec/fixtures/_posts/2014-03-02-march-the-second.md +0 -6
- data/spec/fixtures/_posts/2014-03-04-march-the-fourth.md +0 -9
- data/spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md +0 -5
- data/spec/fixtures/_posts/2015-02-12-strip-newlines.md +0 -6
- data/spec/fixtures/_posts/2015-05-12-liquid.md +0 -7
- data/spec/fixtures/_posts/2015-05-12-pre.html +0 -8
- data/spec/fixtures/_posts/2015-05-18-author-detail.md +0 -9
- data/spec/fixtures/_posts/2015-08-08-stuck-in-the-middle.html +0 -2
- data/spec/fixtures/_posts/2016-04-25-author-reference.md +0 -6
- data/spec/fixtures/feed.xslt.xml +0 -0
- data/spec/jekyll-feed_spec.rb +0 -474
- data/spec/spec_helper.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8f1fde42e53f27b048363aa57f03f5d51a3f68fbe6af4e0ffb69209b373ffeb
|
4
|
+
data.tar.gz: aaaa1c370f29527e3806c6753ae76a2fa8297337f0e667f25fd43d05779fcfef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6800a223adf7b8c6ae236d6b9d3e355d4ca31c7d2e67752cfd2cb5b3fe599ddda2d9c6f28a38a7c6d5e648ac67ca585fe6fe2a2e08f38c158a1b6a95ded11fd7
|
7
|
+
data.tar.gz: a17bf5e936302721494bba9028ccda96ca88a4e229e0b1c88e6abe63f1ee2c60e3992296da05721d30400952fcc0ccafe4a2bd179038553ee57d3c940a1d04e9
|
data/History.markdown
CHANGED
@@ -1,6 +1,51 @@
|
|
1
1
|
## HEAD
|
2
2
|
|
3
|
-
|
3
|
+
## 0.15.1 / 2020-10-04
|
4
|
+
|
5
|
+
### Bug Fixes
|
6
|
+
|
7
|
+
* MetaTag: when encoding for XML special characters, handle non-string objects (#326)
|
8
|
+
|
9
|
+
## 0.15.0 / 2020-07-10
|
10
|
+
|
11
|
+
### Minor Enhancements
|
12
|
+
|
13
|
+
* Add support for drafts (#316)
|
14
|
+
|
15
|
+
## 0.14.0 / 2020-06-24
|
16
|
+
|
17
|
+
### Minor Enhancements
|
18
|
+
|
19
|
+
* add support for categories (#153) (#233)
|
20
|
+
* add support for tags (#264)
|
21
|
+
* Make posts limit configurable (#314)
|
22
|
+
* XML escape the title field of feed_meta (#306)
|
23
|
+
|
24
|
+
### Bug Fixes
|
25
|
+
|
26
|
+
* Fix feed link when post title contains HTML (#305)
|
27
|
+
|
28
|
+
### Development Fixes
|
29
|
+
|
30
|
+
* Use Dir to list source files (#309)
|
31
|
+
* Require Ruby >=2.4.0 (#307)
|
32
|
+
|
33
|
+
## 0.13.0 / 2019-11-13
|
34
|
+
|
35
|
+
### Minor Enhancements
|
36
|
+
|
37
|
+
* Excerpt only flag (#287)
|
38
|
+
* Add media:content tag (#290)
|
39
|
+
|
40
|
+
### Development Fixes
|
41
|
+
|
42
|
+
* test: use categories in post (#249)
|
43
|
+
|
44
|
+
## 0.12.1 / 2019-03-23
|
45
|
+
|
46
|
+
### Bug Fixes
|
47
|
+
|
48
|
+
* Re-introduce Ruby 2.3 support and test Jekyll 3.7+ (#272)
|
4
49
|
|
5
50
|
## 0.12.0 / 2019-03-21
|
6
51
|
|
data/README.md
CHANGED
@@ -31,7 +31,7 @@ The plugin will automatically use any of the following configuration variables,
|
|
31
31
|
|
32
32
|
* `title` or `name` - The title of the site, e.g., "My awesome site"
|
33
33
|
* `description` - A longer description of what your site is about, e.g., "Where I blog about Jekyll and other awesome things"
|
34
|
-
* `url` - The URL to your site, e.g., `
|
34
|
+
* `url` - The URL to your site, e.g., `https://example.com`. If none is provided, the plugin will try to use `site.github.url`.
|
35
35
|
* `author` - Global author information (see below)
|
36
36
|
|
37
37
|
### Already have a feed path?
|
@@ -134,7 +134,7 @@ Jekyll's `smartify` filter uses [kramdown](https://kramdown.gettalong.org/option
|
|
134
134
|
|
135
135
|
### Custom styling
|
136
136
|
|
137
|
-
Want to style what your feed looks like in the browser?
|
137
|
+
Want to style what your feed looks like in the browser? When a XSLT Styleheet file named `feed.xslt.xml` exists at the root of your repository, a link to this stylesheet is added to the generated feed.
|
138
138
|
|
139
139
|
## Why Atom, and not RSS?
|
140
140
|
|
@@ -151,6 +151,15 @@ feed:
|
|
151
151
|
- updates
|
152
152
|
```
|
153
153
|
|
154
|
+
## Posts limit
|
155
|
+
|
156
|
+
By default the plugin limits the number of posts in the feed to 10. Simply define a new limit in your config:
|
157
|
+
|
158
|
+
```yml
|
159
|
+
feed:
|
160
|
+
posts_limit: 20
|
161
|
+
```
|
162
|
+
|
154
163
|
## Collections
|
155
164
|
|
156
165
|
Jekyll Feed can generate feeds for collections other than the Posts collection. This works best for chronological collections (e.g., collections with dates in the filenames). Simply define which collections you'd like feeds for in your config:
|
@@ -182,6 +191,59 @@ feed:
|
|
182
191
|
- updates
|
183
192
|
```
|
184
193
|
|
194
|
+
## Excerpt Only flag
|
195
|
+
|
196
|
+
Optional flag `excerpt_only` allows you to exclude post content from the Atom feed. Default value is `false` for backward compatibility.
|
197
|
+
|
198
|
+
When in `config.yml` is `true` than all posts in feed will be without `<content>` tags.
|
199
|
+
|
200
|
+
```yml
|
201
|
+
feed:
|
202
|
+
excerpt_only: true
|
203
|
+
```
|
204
|
+
|
205
|
+
The same flag can be used directly in post file. It will be disable `<content>` tag for selected post.
|
206
|
+
Settings in post file has higher priority than in config file.
|
207
|
+
|
208
|
+
## Tags
|
209
|
+
|
210
|
+
To automatically generate feeds for each tag you apply to your posts you can add a tags setting to your config:
|
211
|
+
|
212
|
+
```yml
|
213
|
+
feed:
|
214
|
+
tags: true
|
215
|
+
```
|
216
|
+
|
217
|
+
If there are tags you don't want included in this auto generation you can exclude them
|
218
|
+
|
219
|
+
```yml
|
220
|
+
feed:
|
221
|
+
tags:
|
222
|
+
except:
|
223
|
+
- tag-to-exclude
|
224
|
+
- another-tag
|
225
|
+
```
|
226
|
+
|
227
|
+
If you wish to change the location of these auto generated feeds (`/feed/by_tag/<TAG>.xml` by default) you can provide an alternative folder for them to live in.
|
228
|
+
|
229
|
+
```yml
|
230
|
+
feed:
|
231
|
+
tags:
|
232
|
+
path: "alternative/path/for/tags/feeds/"
|
233
|
+
```
|
234
|
+
|
235
|
+
If you only want to generate feeds for a few tags you can also set this.
|
236
|
+
|
237
|
+
```yml
|
238
|
+
feed:
|
239
|
+
tags:
|
240
|
+
only:
|
241
|
+
- tag-to-include
|
242
|
+
- another-tag
|
243
|
+
```
|
244
|
+
|
245
|
+
Note that if you include a tag that is excluded a feed will not be generated for it.
|
246
|
+
|
185
247
|
## Contributing
|
186
248
|
|
187
249
|
1. Fork it (https://github.com/jekyll/jekyll-feed/fork)
|
data/lib/jekyll-feed/feed.xml
CHANGED
@@ -39,18 +39,32 @@
|
|
39
39
|
</author>
|
40
40
|
{% endif %}
|
41
41
|
|
42
|
-
{%
|
42
|
+
{% if page.tags %}
|
43
|
+
{% assign posts = site.tags[page.tags] %}
|
44
|
+
{% else %}
|
45
|
+
{% assign posts = site[page.collection] %}
|
46
|
+
{% endif %}
|
43
47
|
{% if page.category %}
|
44
|
-
{% assign posts = posts | where: "category",page.category %}
|
48
|
+
{% assign posts = posts | where: "category", page.category %}
|
45
49
|
{% endif %}
|
46
|
-
{%
|
50
|
+
{% unless site.show_drafts %}
|
51
|
+
{% assign posts = posts | where_exp: "post", "post.draft != true" %}
|
52
|
+
{% endunless %}
|
53
|
+
{% assign posts = posts | sort: "date" | reverse %}
|
54
|
+
{% assign posts_limit = site.feed.posts_limit | default: 10 %}
|
55
|
+
{% for post in posts limit: posts_limit %}
|
47
56
|
<entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
|
48
|
-
|
49
|
-
|
57
|
+
{% assign post_title = post.title | smartify | strip_html | normalize_whitespace | xml_escape %}
|
58
|
+
|
59
|
+
<title type="html">{{ post_title }}</title>
|
60
|
+
<link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post_title }}" />
|
50
61
|
<published>{{ post.date | date_to_xmlschema }}</published>
|
51
62
|
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
|
52
63
|
<id>{{ post.id | absolute_url | xml_escape }}</id>
|
53
|
-
|
64
|
+
{% assign excerpt_only = post.feed.excerpt_only | default: site.feed.excerpt_only %}
|
65
|
+
{% unless excerpt_only %}
|
66
|
+
<content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
|
67
|
+
{% endunless %}
|
54
68
|
|
55
69
|
{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
|
56
70
|
{% assign post_author = site.data.authors[post_author] | default: post_author %}
|
@@ -70,6 +84,10 @@
|
|
70
84
|
|
71
85
|
{% if post.category %}
|
72
86
|
<category term="{{ post.category | xml_escape }}" />
|
87
|
+
{% elsif post.categories %}
|
88
|
+
{% for category in post.categories %}
|
89
|
+
<category term="{{ category | xml_escape }}" />
|
90
|
+
{% endfor %}
|
73
91
|
{% endif %}
|
74
92
|
|
75
93
|
{% for tag in post.tags %}
|
@@ -86,6 +104,7 @@
|
|
86
104
|
{% assign post_image = post_image | absolute_url %}
|
87
105
|
{% endunless %}
|
88
106
|
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="{{ post_image | xml_escape }}" />
|
107
|
+
<media:content medium="image" url="{{ post_image | xml_escape }}" xmlns:media="http://search.yahoo.com/mrss/" />
|
89
108
|
{% endif %}
|
90
109
|
</entry>
|
91
110
|
{% endfor %}
|
@@ -17,6 +17,7 @@ module JekyllFeed
|
|
17
17
|
@site.pages << make_page(path, :collection => name, :category => category)
|
18
18
|
end
|
19
19
|
end
|
20
|
+
generate_feed_by_tag if config["tags"] && !@site.tags.empty?
|
20
21
|
end
|
21
22
|
|
22
23
|
private
|
@@ -69,6 +70,32 @@ module JekyllFeed
|
|
69
70
|
@collections
|
70
71
|
end
|
71
72
|
|
73
|
+
def generate_feed_by_tag
|
74
|
+
tags_config = config["tags"]
|
75
|
+
tags_config = {} unless tags_config.is_a?(Hash)
|
76
|
+
|
77
|
+
except = tags_config["except"] || []
|
78
|
+
only = tags_config["only"] || @site.tags.keys
|
79
|
+
tags_pool = only - except
|
80
|
+
tags_path = tags_config["path"] || "/feed/by_tag/"
|
81
|
+
|
82
|
+
generate_tag_feed(tags_pool, tags_path)
|
83
|
+
end
|
84
|
+
|
85
|
+
def generate_tag_feed(tags_pool, tags_path)
|
86
|
+
tags_pool.each do |tag|
|
87
|
+
# allow only tags with basic alphanumeric characters and underscore to keep
|
88
|
+
# feed path simple.
|
89
|
+
next if %r![^a-zA-Z0-9_]!.match?(tag)
|
90
|
+
|
91
|
+
Jekyll.logger.info "Jekyll Feed:", "Generating feed for posts tagged #{tag}"
|
92
|
+
path = "#{tags_path}#{tag}.xml"
|
93
|
+
next if file_exists?(path)
|
94
|
+
|
95
|
+
@site.pages << make_page(path, :tags => tag)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
72
99
|
# Path to feed.xml template file
|
73
100
|
def feed_source_path
|
74
101
|
@feed_source_path ||= File.expand_path "feed.xml", __dir__
|
@@ -85,7 +112,7 @@ module JekyllFeed
|
|
85
112
|
|
86
113
|
# Generates contents for a file
|
87
114
|
|
88
|
-
def make_page(file_path, collection: "posts", category: nil)
|
115
|
+
def make_page(file_path, collection: "posts", category: nil, tags: nil)
|
89
116
|
PageWithoutAFile.new(@site, __dir__, "", file_path).tap do |file|
|
90
117
|
file.content = feed_template
|
91
118
|
file.data.merge!(
|
@@ -93,7 +120,8 @@ module JekyllFeed
|
|
93
120
|
"sitemap" => false,
|
94
121
|
"xsl" => file_exists?("feed.xslt.xml"),
|
95
122
|
"collection" => collection,
|
96
|
-
"category" => category
|
123
|
+
"category" => category,
|
124
|
+
"tags" => tags
|
97
125
|
)
|
98
126
|
file.output
|
99
127
|
end
|
data/lib/jekyll-feed/meta-tag.rb
CHANGED
@@ -7,8 +7,11 @@ module JekyllFeed
|
|
7
7
|
|
8
8
|
def render(context)
|
9
9
|
@context = context
|
10
|
-
attrs = attributes.map
|
11
|
-
|
10
|
+
attrs = attributes.map do |k, v|
|
11
|
+
v = v.to_s unless v.respond_to?(:encode)
|
12
|
+
%(#{k}=#{v.encode(:xml => :attr)})
|
13
|
+
end
|
14
|
+
"<link #{attrs.join(" ")} />"
|
12
15
|
end
|
13
16
|
|
14
17
|
private
|
data/lib/jekyll-feed/version.rb
CHANGED
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.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -120,59 +120,30 @@ dependencies:
|
|
120
120
|
- - "<"
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '2.0'
|
123
|
-
description:
|
123
|
+
description:
|
124
124
|
email:
|
125
125
|
- ben.balter@github.com
|
126
126
|
executables: []
|
127
127
|
extensions: []
|
128
|
-
extra_rdoc_files:
|
128
|
+
extra_rdoc_files:
|
129
|
+
- README.md
|
130
|
+
- History.markdown
|
131
|
+
- LICENSE.txt
|
129
132
|
files:
|
130
|
-
- ".gitignore"
|
131
|
-
- ".rspec"
|
132
|
-
- ".rubocop.yml"
|
133
|
-
- ".travis.yml"
|
134
|
-
- Gemfile
|
135
133
|
- History.markdown
|
136
134
|
- LICENSE.txt
|
137
135
|
- README.md
|
138
|
-
- Rakefile
|
139
|
-
- appveyor.yml
|
140
|
-
- jekyll-feed.gemspec
|
141
136
|
- lib/jekyll-feed.rb
|
142
137
|
- lib/jekyll-feed/feed.xml
|
143
138
|
- lib/jekyll-feed/generator.rb
|
144
139
|
- lib/jekyll-feed/meta-tag.rb
|
145
140
|
- lib/jekyll-feed/page-without-a-file.rb
|
146
141
|
- lib/jekyll-feed/version.rb
|
147
|
-
- script/bootstrap
|
148
|
-
- script/cibuild
|
149
|
-
- script/fmt
|
150
|
-
- script/release
|
151
|
-
- script/test
|
152
|
-
- spec/fixtures/_collection/2018-01-01-collection-doc.md
|
153
|
-
- spec/fixtures/_collection/2018-01-02-collection-category-doc.md
|
154
|
-
- spec/fixtures/_config.yml
|
155
|
-
- spec/fixtures/_data/authors.yml
|
156
|
-
- spec/fixtures/_drafts/2015-01-12-a-draft.md
|
157
|
-
- spec/fixtures/_layouts/some_default.html
|
158
|
-
- spec/fixtures/_posts/2013-12-12-dec-the-second.md
|
159
|
-
- spec/fixtures/_posts/2014-03-02-march-the-second.md
|
160
|
-
- spec/fixtures/_posts/2014-03-04-march-the-fourth.md
|
161
|
-
- spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md
|
162
|
-
- spec/fixtures/_posts/2015-02-12-strip-newlines.md
|
163
|
-
- spec/fixtures/_posts/2015-05-12-liquid.md
|
164
|
-
- spec/fixtures/_posts/2015-05-12-pre.html
|
165
|
-
- spec/fixtures/_posts/2015-05-18-author-detail.md
|
166
|
-
- spec/fixtures/_posts/2015-08-08-stuck-in-the-middle.html
|
167
|
-
- spec/fixtures/_posts/2016-04-25-author-reference.md
|
168
|
-
- spec/fixtures/feed.xslt.xml
|
169
|
-
- spec/jekyll-feed_spec.rb
|
170
|
-
- spec/spec_helper.rb
|
171
142
|
homepage: https://github.com/jekyll/jekyll-feed
|
172
143
|
licenses:
|
173
144
|
- MIT
|
174
145
|
metadata: {}
|
175
|
-
post_install_message:
|
146
|
+
post_install_message:
|
176
147
|
rdoc_options: []
|
177
148
|
require_paths:
|
178
149
|
- lib
|
@@ -188,26 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
159
|
version: '0'
|
189
160
|
requirements: []
|
190
161
|
rubygems_version: 3.0.3
|
191
|
-
signing_key:
|
162
|
+
signing_key:
|
192
163
|
specification_version: 4
|
193
164
|
summary: A Jekyll plugin to generate an Atom feed of your Jekyll posts
|
194
|
-
test_files:
|
195
|
-
- spec/fixtures/_collection/2018-01-01-collection-doc.md
|
196
|
-
- spec/fixtures/_collection/2018-01-02-collection-category-doc.md
|
197
|
-
- spec/fixtures/_config.yml
|
198
|
-
- spec/fixtures/_data/authors.yml
|
199
|
-
- spec/fixtures/_drafts/2015-01-12-a-draft.md
|
200
|
-
- spec/fixtures/_layouts/some_default.html
|
201
|
-
- spec/fixtures/_posts/2013-12-12-dec-the-second.md
|
202
|
-
- spec/fixtures/_posts/2014-03-02-march-the-second.md
|
203
|
-
- spec/fixtures/_posts/2014-03-04-march-the-fourth.md
|
204
|
-
- spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md
|
205
|
-
- spec/fixtures/_posts/2015-02-12-strip-newlines.md
|
206
|
-
- spec/fixtures/_posts/2015-05-12-liquid.md
|
207
|
-
- spec/fixtures/_posts/2015-05-12-pre.html
|
208
|
-
- spec/fixtures/_posts/2015-05-18-author-detail.md
|
209
|
-
- spec/fixtures/_posts/2015-08-08-stuck-in-the-middle.html
|
210
|
-
- spec/fixtures/_posts/2016-04-25-author-reference.md
|
211
|
-
- spec/fixtures/feed.xslt.xml
|
212
|
-
- spec/jekyll-feed_spec.rb
|
213
|
-
- spec/spec_helper.rb
|
165
|
+
test_files: []
|
data/.gitignore
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
/vendor
|
2
|
-
/.bundle/
|
3
|
-
/.yardoc
|
4
|
-
/Gemfile.lock
|
5
|
-
/_yardoc/
|
6
|
-
/coverage/
|
7
|
-
/doc/
|
8
|
-
/pkg/
|
9
|
-
/spec/reports/
|
10
|
-
/tmp/
|
11
|
-
*.bundle
|
12
|
-
*.so
|
13
|
-
*.o
|
14
|
-
*.a
|
15
|
-
mkmf.log
|
16
|
-
*.gem
|
17
|
-
Gemfile.lock
|
18
|
-
spec/dest
|
19
|
-
.bundle
|
20
|
-
spec/fixtures/.jekyll-metadata
|
21
|
-
spec/fixtures/.jekyll-cache
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require: rubocop-jekyll
|
2
|
-
|
3
|
-
inherit_gem:
|
4
|
-
rubocop-jekyll: .rubocop.yml
|
5
|
-
|
6
|
-
AllCops:
|
7
|
-
TargetRubyVersion: 2.4
|
8
|
-
Include:
|
9
|
-
- lib/**/*.rb
|
10
|
-
|
11
|
-
Exclude:
|
12
|
-
- .gitignore
|
13
|
-
- .rspec
|
14
|
-
- .rubocop.yml
|
15
|
-
- .travis.yml
|
16
|
-
|
17
|
-
- Gemfile.lock
|
18
|
-
- History.markdown
|
19
|
-
- LICENSE.txt
|
20
|
-
- README.md
|
21
|
-
|
22
|
-
- script/**/*
|
23
|
-
- vendor/**/*
|
24
|
-
|
25
|
-
Naming/MemoizedInstanceVariableName:
|
26
|
-
Exclude:
|
27
|
-
- lib/jekyll-feed/page-without-a-file.rb
|
data/.travis.yml
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
sudo: false
|
4
|
-
rvm:
|
5
|
-
- 2.6
|
6
|
-
- 2.4
|
7
|
-
env:
|
8
|
-
global:
|
9
|
-
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
10
|
-
before_install:
|
11
|
-
- gem update --system
|
12
|
-
- gem install bundler
|
13
|
-
before_script: bundle update
|
14
|
-
script: script/cibuild
|
15
|
-
notifications:
|
16
|
-
email: false
|
17
|
-
deploy:
|
18
|
-
provider: rubygems
|
19
|
-
api_key:
|
20
|
-
secure: qz0q6ur0kGo03jjLdoAak6WcEAwxX2r9LG3DVrhOrcfoFipkuW+uwR0et4tpK8uFrz0P9y7eTIKOb0XCXeIsIXWj6R5benpRGr2U8m9A+tE/jxviBFUaxaokte0lqWiX1fEyhRmW3zvcdLQ47Vd2EwTNaq6ZmPulmEe9gS0rBQghyclakGlZ17LI7oGgiNL9SQ335Yqa1qJklTHYHbodWQ3Z07v7VN2jxqi3WH6NacT5gUGp5iCNCLLa8+jpKr4uONNIoy6/geAWdqtvgGUE8oTjIWDoJarrknJpqfx9Rd0KLDzkyneAigHDYPW60QtrE6GGpK/+TF1pF4DzdK2EgTWqGFnZf8ehfnxmtHVl2Xq/DPr6hS8Q/f+ut4ioMzBQxPD0hfh8/EOMYKsO8mOuOlYTiZXC7iuGyvFUOl2hnBgWA99t+I0NNB06qFp3ZxIjolEc3zjzc9f1a5HUXlEut5V8nqvCwbctNiTVpT8ZEWlsQlyRUnr9cIMUTEfLgQ+v6DnvAJBMO1EILq6liB5qfutjNhzhlREt7P/ZdppGsAzWpgt0q2PafqVoPe62WR3+/8Lj2ErMr034xSSqZVNcBS0mbdvW6k3jaABo1VJ4XuHm6/yDuemWzWb7kdG9/14+IIJMW1VuaWcmnCnB6gxjkCW3Dm2ftYiN7Rfn3AUz/nU=
|
21
|
-
gem: jekyll-feed
|
22
|
-
on:
|
23
|
-
tags: true
|
24
|
-
repo: jekyll/jekyll-feed
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/appveyor.yml
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
version: "{build}"
|
2
|
-
clone_depth: 5
|
3
|
-
build: off
|
4
|
-
|
5
|
-
environment:
|
6
|
-
NOKOGIRI_USE_SYSTEM_LIBRARIES: true
|
7
|
-
matrix:
|
8
|
-
- RUBY_FOLDER_VER: "26"
|
9
|
-
- RUBY_FOLDER_VER: "24"
|
10
|
-
|
11
|
-
install:
|
12
|
-
- SET PATH=C:\Ruby%RUBY_FOLDER_VER%-x64\bin;%PATH%
|
13
|
-
- bundle install --retry 5 --jobs=%NUMBER_OF_PROCESSORS% --clean --path vendor\bundle
|
14
|
-
|
15
|
-
test_script:
|
16
|
-
- ruby --version
|
17
|
-
- gem --version
|
18
|
-
- bundler --version
|
19
|
-
- bash ./script/test
|
20
|
-
|
21
|
-
cache:
|
22
|
-
# If one of the files after the right arrow changes, cache will be invalidated
|
23
|
-
- 'vendor\bundle -> appveyor.yml, Gemfile, jekyll-feed.gemspec'
|
data/jekyll-feed.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path("lib", __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "jekyll-feed/version"
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "jekyll-feed"
|
9
|
-
spec.version = Jekyll::Feed::VERSION
|
10
|
-
spec.authors = ["Ben Balter"]
|
11
|
-
spec.email = ["ben.balter@github.com"]
|
12
|
-
spec.summary = "A Jekyll plugin to generate an Atom feed of your Jekyll posts"
|
13
|
-
spec.homepage = "https://github.com/jekyll/jekyll-feed"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r!^bin/!) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r!^(test|spec|features)/!)
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.required_ruby_version = ">= 2.4.0"
|
22
|
-
|
23
|
-
spec.add_dependency "jekyll", ">= 3.7", "< 5.0"
|
24
|
-
spec.add_development_dependency "bundler"
|
25
|
-
spec.add_development_dependency "nokogiri", "~> 1.6"
|
26
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
-
spec.add_development_dependency "rubocop-jekyll", "~> 0.5"
|
29
|
-
spec.add_development_dependency "typhoeus", ">= 0.7", "< 2.0"
|
30
|
-
end
|
data/script/bootstrap
DELETED
data/script/cibuild
DELETED
data/script/fmt
DELETED
data/script/release
DELETED
data/script/test
DELETED
data/spec/fixtures/_config.yml
DELETED
data/spec/fixtures/feed.xslt.xml
DELETED
File without changes
|
data/spec/jekyll-feed_spec.rb
DELETED
@@ -1,474 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "spec_helper"
|
4
|
-
|
5
|
-
describe(JekyllFeed) do
|
6
|
-
let(:overrides) { {} }
|
7
|
-
let(:config) do
|
8
|
-
Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
|
9
|
-
"full_rebuild" => true,
|
10
|
-
"source" => source_dir,
|
11
|
-
"destination" => dest_dir,
|
12
|
-
"show_drafts" => true,
|
13
|
-
"url" => "http://example.org",
|
14
|
-
"name" => "My awesome site",
|
15
|
-
"author" => {
|
16
|
-
"name" => "Dr. Jekyll",
|
17
|
-
},
|
18
|
-
"collections" => {
|
19
|
-
"my_collection" => { "output" => true },
|
20
|
-
"other_things" => { "output" => false },
|
21
|
-
},
|
22
|
-
}, overrides))
|
23
|
-
end
|
24
|
-
let(:site) { Jekyll::Site.new(config) }
|
25
|
-
let(:contents) { File.read(dest_dir("feed.xml")) }
|
26
|
-
let(:context) { make_context(:site => site) }
|
27
|
-
let(:feed_meta) { Liquid::Template.parse("{% feed_meta %}").render!(context, {}) }
|
28
|
-
before(:each) do
|
29
|
-
site.process
|
30
|
-
end
|
31
|
-
|
32
|
-
it "has no layout" do
|
33
|
-
expect(contents).not_to match(%r!\ATHIS IS MY LAYOUT!)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "creates a feed.xml file" do
|
37
|
-
expect(Pathname.new(dest_dir("feed.xml"))).to exist
|
38
|
-
end
|
39
|
-
|
40
|
-
it "doesn't have multiple new lines or trailing whitespace" do
|
41
|
-
expect(contents).to_not match %r!\s+\n!
|
42
|
-
expect(contents).to_not match %r!\n{2,}!
|
43
|
-
end
|
44
|
-
|
45
|
-
it "puts all the posts in the feed.xml file" do
|
46
|
-
expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html"
|
47
|
-
expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html"
|
48
|
-
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
|
49
|
-
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
|
50
|
-
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
|
51
|
-
end
|
52
|
-
|
53
|
-
it "does not include assets or any static files that aren't .html" do
|
54
|
-
expect(contents).not_to match "http://example.org/images/hubot.png"
|
55
|
-
expect(contents).not_to match "http://example.org/feeds/atom.xml"
|
56
|
-
end
|
57
|
-
|
58
|
-
it "preserves linebreaks in preformatted text in posts" do
|
59
|
-
expect(contents).to match "Line 1\nLine 2\nLine 3"
|
60
|
-
end
|
61
|
-
|
62
|
-
it "supports post author name as an object" do
|
63
|
-
expect(contents).to match %r!<author>\s*<name>Ben</name>\s*<email>ben@example\.com</email>\s*<uri>http://ben\.balter\.com</uri>\s*</author>!
|
64
|
-
end
|
65
|
-
|
66
|
-
it "supports post author name as a string" do
|
67
|
-
expect(contents).to match %r!<author>\s*<name>Pat</name>\s*</author>!
|
68
|
-
end
|
69
|
-
|
70
|
-
it "does not output author tag no author is provided" do
|
71
|
-
expect(contents).not_to match %r!<author>\s*<name></name>\s*</author>!
|
72
|
-
end
|
73
|
-
|
74
|
-
it "does use author reference with data from _data/authors.yml" do
|
75
|
-
expect(contents).to match %r!<author>\s*<name>Garth</name>\s*<email>example@mail\.com</email>\s*<uri>http://garthdb\.com</uri>\s*</author>!
|
76
|
-
end
|
77
|
-
|
78
|
-
it "converts markdown posts to HTML" do
|
79
|
-
expect(contents).to match %r!<p>March the second\!</p>!
|
80
|
-
end
|
81
|
-
|
82
|
-
it "uses last_modified_at where available" do
|
83
|
-
expect(contents).to match %r!<updated>2015-05-12T13:27:59\+00:00</updated>!
|
84
|
-
end
|
85
|
-
|
86
|
-
it "replaces newlines in posts to spaces" do
|
87
|
-
expect(contents).to match '<title type="html">The plugin will properly strip newlines.</title>'
|
88
|
-
end
|
89
|
-
|
90
|
-
it "renders Liquid inside posts" do
|
91
|
-
expect(contents).to match "Liquid is rendered."
|
92
|
-
expect(contents).not_to match "Liquid is not rendered."
|
93
|
-
end
|
94
|
-
|
95
|
-
it "includes the item image" do
|
96
|
-
expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/image.png" />')
|
97
|
-
expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://cdn.example.org/absolute.png?h=188&w=250" />')
|
98
|
-
expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/object-image.png" />')
|
99
|
-
end
|
100
|
-
|
101
|
-
context "parsing" do
|
102
|
-
let(:feed) { RSS::Parser.parse(contents) }
|
103
|
-
|
104
|
-
it "outputs an RSS feed" do
|
105
|
-
expect(feed.feed_type).to eql("atom")
|
106
|
-
expect(feed.feed_version).to eql("1.0")
|
107
|
-
expect(feed.encoding).to eql("UTF-8")
|
108
|
-
expect(feed.lang).to be_nil
|
109
|
-
expect(feed.valid?).to eql(true)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "outputs the link" do
|
113
|
-
expect(feed.link.href).to eql("http://example.org/feed.xml")
|
114
|
-
end
|
115
|
-
|
116
|
-
it "outputs the generator" do
|
117
|
-
expect(feed.generator.content).to eql("Jekyll")
|
118
|
-
expect(feed.generator.version).to eql(Jekyll::VERSION)
|
119
|
-
end
|
120
|
-
|
121
|
-
it "includes the items" do
|
122
|
-
expect(feed.items.count).to eql(10)
|
123
|
-
end
|
124
|
-
|
125
|
-
it "includes item contents" do
|
126
|
-
post = feed.items.last
|
127
|
-
expect(post.title.content).to eql("Dec The Second")
|
128
|
-
expect(post.link.href).to eql("http://example.org/news/2013/12/12/dec-the-second.html")
|
129
|
-
expect(post.published.content).to eql(Time.parse("2013-12-12"))
|
130
|
-
end
|
131
|
-
|
132
|
-
it "includes the item's excerpt" do
|
133
|
-
post = feed.items.last
|
134
|
-
expect(post.summary.content).to eql("Foo")
|
135
|
-
end
|
136
|
-
|
137
|
-
it "doesn't include the item's excerpt if blank" do
|
138
|
-
post = feed.items.first
|
139
|
-
expect(post.summary).to be_nil
|
140
|
-
end
|
141
|
-
|
142
|
-
context "with site.lang set" do
|
143
|
-
lang = "en_US"
|
144
|
-
let(:overrides) { { "lang" => lang } }
|
145
|
-
it "outputs a valid feed" do
|
146
|
-
expect(feed.feed_type).to eql("atom")
|
147
|
-
expect(feed.feed_version).to eql("1.0")
|
148
|
-
expect(feed.encoding).to eql("UTF-8")
|
149
|
-
expect(feed.valid?).to eql(true)
|
150
|
-
end
|
151
|
-
|
152
|
-
it "outputs the correct language" do
|
153
|
-
expect(feed.lang).to eql(lang)
|
154
|
-
end
|
155
|
-
|
156
|
-
it "sets the language of entries" do
|
157
|
-
post = feed.items.first
|
158
|
-
expect(post.lang).to eql(lang)
|
159
|
-
end
|
160
|
-
|
161
|
-
it "renders the feed meta" do
|
162
|
-
expected = %r!<link href="http://example.org/" rel="alternate" type="text/html" hreflang="#{lang}" />!
|
163
|
-
expect(contents).to match(expected)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
context "with site.title set" do
|
168
|
-
let(:site_title) { "My Site Title" }
|
169
|
-
let(:overrides) { { "title" => site_title } }
|
170
|
-
|
171
|
-
it "uses site.title for the title" do
|
172
|
-
expect(feed.title.content).to eql(site_title)
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
context "with site.name set" do
|
177
|
-
let(:site_name) { "My Site Name" }
|
178
|
-
let(:overrides) { { "name" => site_name } }
|
179
|
-
|
180
|
-
it "uses site.name for the title" do
|
181
|
-
expect(feed.title.content).to eql(site_name)
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
context "with site.name and site.title set" do
|
186
|
-
let(:site_title) { "My Site Title" }
|
187
|
-
let(:site_name) { "My Site Name" }
|
188
|
-
let(:overrides) { { "title" => site_title, "name" => site_name } }
|
189
|
-
|
190
|
-
it "uses site.title for the title, dropping site.name" do
|
191
|
-
expect(feed.title.content).to eql(site_title)
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
|
196
|
-
context "smartify" do
|
197
|
-
let(:site_title) { "Pat's Site" }
|
198
|
-
let(:overrides) { { "title" => site_title } }
|
199
|
-
let(:feed) { RSS::Parser.parse(contents) }
|
200
|
-
|
201
|
-
it "processes site title with SmartyPants" do
|
202
|
-
expect(feed.title.content).to eql("Pat’s Site")
|
203
|
-
end
|
204
|
-
end
|
205
|
-
|
206
|
-
context "validation" do
|
207
|
-
it "validates" do
|
208
|
-
skip "Typhoeus couldn't find the 'libcurl' module on Windows" if Gem.win_platform?
|
209
|
-
# See https://validator.w3.org/docs/api.html
|
210
|
-
url = "https://validator.w3.org/feed/check.cgi?output=soap12"
|
211
|
-
response = Typhoeus.post(url, :body => { :rawdata => contents }, :accept_encoding => "gzip")
|
212
|
-
pending "Something went wrong with the W3 validator" unless response.success?
|
213
|
-
result = Nokogiri::XML(response.body)
|
214
|
-
result.remove_namespaces!
|
215
|
-
|
216
|
-
result.css("warning").each do |warning|
|
217
|
-
# Quiet a warning that results from us passing the feed as a string
|
218
|
-
next if warning.css("text").text =~ %r!Self reference doesn't match document location!
|
219
|
-
|
220
|
-
# Quiet expected warning that results from blank summary test case
|
221
|
-
next if warning.css("text").text =~ %r!(content|summary) should not be blank!
|
222
|
-
|
223
|
-
# Quiet expected warning about multiple posts with same updated time
|
224
|
-
next if warning.css("text").text =~ %r!Two entries with the same value for atom:updated!
|
225
|
-
|
226
|
-
warn "Validation warning: #{warning.css("text").text} on line #{warning.css("line").text} column #{warning.css("column").text}"
|
227
|
-
end
|
228
|
-
|
229
|
-
errors = result.css("error").map do |error|
|
230
|
-
"Validation error: #{error.css("text").text} on line #{error.css("line").text} column #{error.css("column").text}"
|
231
|
-
end
|
232
|
-
|
233
|
-
expect(result.css("validity").text).to eql("true"), errors.join("\n")
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
context "with a baseurl" do
|
238
|
-
let(:overrides) do
|
239
|
-
{ "baseurl" => "/bass" }
|
240
|
-
end
|
241
|
-
|
242
|
-
it "correctly adds the baseurl to the posts" do
|
243
|
-
expect(contents).to match "http://example.org/bass/updates/2014/03/04/march-the-fourth.html"
|
244
|
-
expect(contents).to match "http://example.org/bass/news/2014/03/02/march-the-second.html"
|
245
|
-
expect(contents).to match "http://example.org/bass/news/2013/12/12/dec-the-second.html"
|
246
|
-
end
|
247
|
-
|
248
|
-
it "renders the feed meta" do
|
249
|
-
expected = 'href="http://example.org/bass/feed.xml"'
|
250
|
-
expect(feed_meta).to include(expected)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
context "feed meta" do
|
255
|
-
it "renders the feed meta" do
|
256
|
-
expected = '<link type="application/atom+xml" rel="alternate" href="http://example.org/feed.xml" title="My awesome site" />'
|
257
|
-
expect(feed_meta).to eql(expected)
|
258
|
-
end
|
259
|
-
|
260
|
-
context "with a blank site name" do
|
261
|
-
let(:config) do
|
262
|
-
Jekyll.configuration(
|
263
|
-
"source" => source_dir,
|
264
|
-
"destination" => dest_dir,
|
265
|
-
"url" => "http://example.org"
|
266
|
-
)
|
267
|
-
end
|
268
|
-
|
269
|
-
it "does not output blank title" do
|
270
|
-
expect(feed_meta).not_to include("title=")
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
context "changing the feed path" do
|
276
|
-
let(:overrides) do
|
277
|
-
{
|
278
|
-
"feed" => {
|
279
|
-
"path" => "atom.xml",
|
280
|
-
},
|
281
|
-
}
|
282
|
-
end
|
283
|
-
|
284
|
-
it "should write to atom.xml" do
|
285
|
-
expect(Pathname.new(dest_dir("atom.xml"))).to exist
|
286
|
-
end
|
287
|
-
|
288
|
-
it "renders the feed meta with custom feed path" do
|
289
|
-
expected = 'href="http://example.org/atom.xml"'
|
290
|
-
expect(feed_meta).to include(expected)
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
context "changing the file path via collection meta" do
|
295
|
-
let(:overrides) do
|
296
|
-
{
|
297
|
-
"feed" => {
|
298
|
-
"collections" => {
|
299
|
-
"posts" => {
|
300
|
-
"path" => "atom.xml",
|
301
|
-
},
|
302
|
-
},
|
303
|
-
},
|
304
|
-
}
|
305
|
-
end
|
306
|
-
|
307
|
-
it "should write to atom.xml" do
|
308
|
-
expect(Pathname.new(dest_dir("atom.xml"))).to exist
|
309
|
-
end
|
310
|
-
|
311
|
-
it "renders the feed meta with custom feed path" do
|
312
|
-
expected = 'href="http://example.org/atom.xml"'
|
313
|
-
expect(feed_meta).to include(expected)
|
314
|
-
end
|
315
|
-
end
|
316
|
-
|
317
|
-
context "feed stylesheet" do
|
318
|
-
it "includes the stylesheet" do
|
319
|
-
expect(contents).to include('<?xml-stylesheet type="text/xml" href="http://example.org/feed.xslt.xml"?>')
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
context "with site.lang set" do
|
324
|
-
let(:overrides) { { "lang" => "en-US" } }
|
325
|
-
|
326
|
-
it "should set the language" do
|
327
|
-
expect(contents).to match 'type="text/html" hreflang="en-US" />'
|
328
|
-
end
|
329
|
-
end
|
330
|
-
|
331
|
-
context "with post.lang set" do
|
332
|
-
it "should set the language for that entry" do
|
333
|
-
expect(contents).to match '<entry xml:lang="en">'
|
334
|
-
expect(contents).to match '<entry>'
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
|
-
context "categories" do
|
339
|
-
context "with top-level post categories" do
|
340
|
-
let(:overrides) do
|
341
|
-
{
|
342
|
-
"feed" => { "categories" => ["news"] },
|
343
|
-
}
|
344
|
-
end
|
345
|
-
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
|
346
|
-
|
347
|
-
it "outputs the primary feed" do
|
348
|
-
expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html"
|
349
|
-
expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html"
|
350
|
-
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
|
351
|
-
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
|
352
|
-
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
|
353
|
-
end
|
354
|
-
|
355
|
-
it "outputs the category feed" do
|
356
|
-
expect(news_feed).to match '<title type="html">My awesome site | News</title>'
|
357
|
-
expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html"
|
358
|
-
expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html"
|
359
|
-
expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
|
360
|
-
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
|
361
|
-
end
|
362
|
-
end
|
363
|
-
|
364
|
-
context "with collection-level post categories" do
|
365
|
-
let(:overrides) do
|
366
|
-
{
|
367
|
-
"feed" => {
|
368
|
-
"collections" => {
|
369
|
-
"posts" => {
|
370
|
-
"categories" => ["news"],
|
371
|
-
},
|
372
|
-
},
|
373
|
-
},
|
374
|
-
}
|
375
|
-
end
|
376
|
-
let(:news_feed) { File.read(dest_dir("feed/news.xml")) }
|
377
|
-
|
378
|
-
it "outputs the primary feed" do
|
379
|
-
expect(contents).to match "http://example.org/updates/2014/03/04/march-the-fourth.html"
|
380
|
-
expect(contents).to match "http://example.org/news/2014/03/02/march-the-second.html"
|
381
|
-
expect(contents).to match "http://example.org/news/2013/12/12/dec-the-second.html"
|
382
|
-
expect(contents).to match "http://example.org/2015/08/08/stuck-in-the-middle.html"
|
383
|
-
expect(contents).to_not match "http://example.org/2016/02/09/a-draft.html"
|
384
|
-
end
|
385
|
-
|
386
|
-
it "outputs the category feed" do
|
387
|
-
expect(news_feed).to match '<title type="html">My awesome site | News</title>'
|
388
|
-
expect(news_feed).to match "http://example.org/news/2014/03/02/march-the-second.html"
|
389
|
-
expect(news_feed).to match "http://example.org/news/2013/12/12/dec-the-second.html"
|
390
|
-
expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
|
391
|
-
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
|
392
|
-
end
|
393
|
-
end
|
394
|
-
end
|
395
|
-
|
396
|
-
context "collections" do
|
397
|
-
let(:collection_feed) { File.read(dest_dir("feed/collection.xml")) }
|
398
|
-
|
399
|
-
context "when initialized as an array" do
|
400
|
-
let(:overrides) do
|
401
|
-
{
|
402
|
-
"collections" => {
|
403
|
-
"collection" => {
|
404
|
-
"output" => true,
|
405
|
-
},
|
406
|
-
},
|
407
|
-
"feed" => { "collections" => ["collection"] },
|
408
|
-
}
|
409
|
-
end
|
410
|
-
|
411
|
-
it "outputs the collection feed" do
|
412
|
-
expect(collection_feed).to match '<title type="html">My awesome site | Collection</title>'
|
413
|
-
expect(collection_feed).to match "http://example.org/collection/2018-01-01-collection-doc.html"
|
414
|
-
expect(collection_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html"
|
415
|
-
expect(collection_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
|
416
|
-
expect(collection_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
|
417
|
-
end
|
418
|
-
end
|
419
|
-
|
420
|
-
context "with categories" do
|
421
|
-
let(:overrides) do
|
422
|
-
{
|
423
|
-
"collections" => {
|
424
|
-
"collection" => {
|
425
|
-
"output" => true,
|
426
|
-
},
|
427
|
-
},
|
428
|
-
"feed" => {
|
429
|
-
"collections" => {
|
430
|
-
"collection" => {
|
431
|
-
"categories" => ["news"],
|
432
|
-
},
|
433
|
-
},
|
434
|
-
},
|
435
|
-
}
|
436
|
-
end
|
437
|
-
let(:news_feed) { File.read(dest_dir("feed/collection/news.xml")) }
|
438
|
-
|
439
|
-
it "outputs the collection category feed" do
|
440
|
-
expect(news_feed).to match '<title type="html">My awesome site | Collection | News</title>'
|
441
|
-
expect(news_feed).to match "http://example.org/collection/2018-01-02-collection-category-doc.html"
|
442
|
-
expect(news_feed).to_not match "http://example.org/collection/2018-01-01-collection-doc.html"
|
443
|
-
expect(news_feed).to_not match "http://example.org/updates/2014/03/04/march-the-fourth.html"
|
444
|
-
expect(news_feed).to_not match "http://example.org/2015/08/08/stuck-in-the-middle.html"
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
|
-
context "with a custom path" do
|
449
|
-
let(:overrides) do
|
450
|
-
{
|
451
|
-
"collections" => {
|
452
|
-
"collection" => {
|
453
|
-
"output" => true,
|
454
|
-
},
|
455
|
-
},
|
456
|
-
"feed" => {
|
457
|
-
"collections" => {
|
458
|
-
"collection" => {
|
459
|
-
"categories" => ["news"],
|
460
|
-
"path" => "custom.xml",
|
461
|
-
},
|
462
|
-
},
|
463
|
-
},
|
464
|
-
}
|
465
|
-
end
|
466
|
-
|
467
|
-
it "should write to the custom path" do
|
468
|
-
expect(Pathname.new(dest_dir("custom.xml"))).to exist
|
469
|
-
expect(Pathname.new(dest_dir("feed/collection.xml"))).to_not exist
|
470
|
-
expect(Pathname.new(dest_dir("feed/collection/news.xml"))).to exist
|
471
|
-
end
|
472
|
-
end
|
473
|
-
end
|
474
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "jekyll"
|
4
|
-
require "typhoeus" unless Gem.win_platform?
|
5
|
-
require "nokogiri"
|
6
|
-
require "rss"
|
7
|
-
require File.expand_path("../lib/jekyll-feed", __dir__)
|
8
|
-
|
9
|
-
Jekyll.logger.log_level = :error
|
10
|
-
|
11
|
-
RSpec.configure do |config|
|
12
|
-
config.run_all_when_everything_filtered = true
|
13
|
-
config.filter_run :focus
|
14
|
-
config.order = "random"
|
15
|
-
|
16
|
-
SOURCE_DIR = File.expand_path("fixtures", __dir__)
|
17
|
-
DEST_DIR = File.expand_path("dest", __dir__)
|
18
|
-
|
19
|
-
def source_dir(*files)
|
20
|
-
File.join(SOURCE_DIR, *files)
|
21
|
-
end
|
22
|
-
|
23
|
-
def dest_dir(*files)
|
24
|
-
File.join(DEST_DIR, *files)
|
25
|
-
end
|
26
|
-
|
27
|
-
def make_context(registers = {})
|
28
|
-
Liquid::Context.new({}, {}, { :site => site }.merge(registers))
|
29
|
-
end
|
30
|
-
end
|