jekyll-feed 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +29 -0
- data/.travis.yml +0 -10
- data/History.markdown +22 -0
- data/README.md +59 -6
- data/jekyll-feed.gemspec +3 -3
- data/lib/feed.xml +39 -13
- data/lib/jekyll-feed.rb +4 -94
- data/lib/jekyll/feed_meta_tag.rb +46 -0
- data/lib/jekyll/jekyll-feed.rb +51 -0
- data/lib/jekyll/page_without_a_file.rb +7 -0
- data/lib/jekyll/strip_whitespace.rb +15 -0
- data/script/cibuild +1 -0
- data/spec/fixtures/_config.yml +0 -3
- data/spec/fixtures/_drafts/2015-01-12-a-draft.md +4 -0
- data/spec/fixtures/_posts/2013-12-12-dec-the-second.md +1 -0
- data/spec/fixtures/_posts/2014-03-02-march-the-second.md +1 -0
- data/spec/fixtures/_posts/2015-01-18-jekyll-last-modified-at.md +1 -0
- data/spec/jekyll-feed_spec.rb +39 -6
- data/spec/spec_helper.rb +4 -0
- metadata +19 -14
- data/spec/fixtures/index.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: b161ab71c3a9ab3055433f765a4d8d0a983a84a4
|
4
|
+
data.tar.gz: b6effe491af09a724eb3578f2d7a1be2967deead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07717d6f03181c1bfcfdf60d122db21d22b4f140f45783976aceea4357cf0a3ccaa5c2090c26e11aea8bc1c3dba8433e132f63c4e4a4ddf8464c656427e4828f
|
7
|
+
data.tar.gz: 8dfb4ef9faf4a6457949ec64d083ed89220c26ecce4cb2121d37a27f08934728c35517475e2cc4baffd4d59715ef6e9b13cc570ee1e0c0bf004513bd9a83621b
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
jekyll: .rubocop.yml
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 1.9
|
6
|
+
Include:
|
7
|
+
- lib/*.rb
|
8
|
+
|
9
|
+
Exclude:
|
10
|
+
- .rubocop.yml
|
11
|
+
- .codeclimate.yml
|
12
|
+
- .travis.yml
|
13
|
+
- .gitignore
|
14
|
+
- .rspec
|
15
|
+
|
16
|
+
- Gemfile.lock
|
17
|
+
- CHANGELOG.md
|
18
|
+
- readme.md
|
19
|
+
- README.md
|
20
|
+
- Readme.md
|
21
|
+
- ReadMe.md
|
22
|
+
- COPYING
|
23
|
+
- LICENSE
|
24
|
+
|
25
|
+
- test/**/*
|
26
|
+
- vendor/**/*
|
27
|
+
- features/**/*
|
28
|
+
- script/**/*
|
29
|
+
- spec/**/*
|
data/.travis.yml
CHANGED
@@ -1,19 +1,9 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
3
|
- 2.2
|
4
|
-
- 2.1
|
5
|
-
- 2.0
|
6
|
-
matrix:
|
7
|
-
include:
|
8
|
-
- # Ruby 1.9
|
9
|
-
rvm: 1.9
|
10
|
-
env: JEKYLL_VERSION=2.0
|
11
4
|
env:
|
12
5
|
global:
|
13
6
|
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
|
14
|
-
matrix:
|
15
|
-
- JEKYLL_VERSION=3.0
|
16
|
-
- JEKYLL_VERSION=2.5
|
17
7
|
cache: bundler
|
18
8
|
sudo: false
|
19
9
|
before_script: bundle update
|
data/History.markdown
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
## 0.5.0 / 2016-04-13
|
2
|
+
|
3
|
+
* Consolidate regexps for stripping whitespace (#82)
|
4
|
+
* Only test against Jekyll 3 (#99)
|
5
|
+
* Think about how i18n might work (#75)
|
6
|
+
* Find author by reference (#106)
|
7
|
+
* Drop support for Jekyll 2 (#105)
|
8
|
+
* Add support for post image (#104)
|
9
|
+
|
10
|
+
### Minor Enhancements
|
11
|
+
|
12
|
+
* Use Module#method_defined? (#83)
|
13
|
+
* Use site.title for meta tag if available (#100)
|
14
|
+
|
15
|
+
### Development Fixes
|
16
|
+
|
17
|
+
* Do not require [**jekyll-last-modified-at**](https://github.com/gjtorikian/jekyll-last-modified-at) in tests (#87)
|
18
|
+
* Add Rubocop (#81)
|
19
|
+
* Correct typo in tests (#102)
|
20
|
+
* Simplify testing feed_meta tag (#101)
|
21
|
+
* Quiet known warnings in tests (#103)
|
22
|
+
|
1
23
|
## 0.4.0 / 2015-12-30
|
2
24
|
|
3
25
|
* Feed uses `site.title`, or `site.name` if `title` doesn't exist (#72)
|
data/README.md
CHANGED
@@ -27,13 +27,10 @@ The plugin will automatically generate an Atom feed at `/feed.xml`.
|
|
27
27
|
|
28
28
|
The plugin will automatically use any of the following configuration variables, if they are present in your site's `_config.yml` file.
|
29
29
|
|
30
|
-
* `name` - The title of the site, e.g., "My awesome site"
|
30
|
+
* `title` or `name` - The title of the site, e.g., "My awesome site"
|
31
31
|
* `description` - A longer description of what your site is about, e.g., "Where I blog about Jekyll and other awesome things"
|
32
32
|
* `url` - The URL to your site, e.g., `http://example.com`. If none is provided, the plugin will try to use `site.github.url`.
|
33
|
-
* `author` -
|
34
|
-
- `name` - **Required** Display name of the author
|
35
|
-
- `email` - Email address of the author
|
36
|
-
- `uri` - Webpage where more information about the author can be found
|
33
|
+
* `author` - Global author information (see below)
|
37
34
|
|
38
35
|
### Already have a feed path?
|
39
36
|
|
@@ -59,7 +56,63 @@ The plugin will use the following post metadata, automatically generated by Jeky
|
|
59
56
|
|
60
57
|
Additionally, the plugin will use the following values, if present in a post's YAML front matter:
|
61
58
|
|
62
|
-
* `author` - The author of the post, e.g., "Dr. Jekyll". If none is given, feed readers will look to the feed author as defined in `_config.yml`. Like the feed author, this can also be an object.
|
59
|
+
* `author` - The author of the post, e.g., "Dr. Jekyll". If none is given, feed readers will look to the feed author as defined in `_config.yml`. Like the feed author, this can also be an object or a reference to an author in `_data/authors.yml` (see below).
|
60
|
+
|
61
|
+
### Author information
|
62
|
+
|
63
|
+
*TL;DR: In most cases, put `author: [your name]` in the document's front matter, for sites with multiple authors. If you need something more complicated, read on.*
|
64
|
+
|
65
|
+
There are several ways to convey author-specific information. Author information is found in the following order of priority:
|
66
|
+
|
67
|
+
1. An `author` object, in the documents's front matter, e.g.:
|
68
|
+
|
69
|
+
```yml
|
70
|
+
author:
|
71
|
+
twitter: benbalter
|
72
|
+
```
|
73
|
+
|
74
|
+
2. An `author` object, in the site's `_config.yml`, e.g.:
|
75
|
+
|
76
|
+
```yml
|
77
|
+
author:
|
78
|
+
twitter: benbalter
|
79
|
+
```
|
80
|
+
|
81
|
+
3. `site.data.authors[author]`, if an author is specified in the document's front matter, and a corresponding key exists in `site.data.authors`. E.g., you have the following in the document's front matter:
|
82
|
+
|
83
|
+
```yml
|
84
|
+
author: benbalter
|
85
|
+
```
|
86
|
+
|
87
|
+
And you have the following in `_data/authors.yml`:
|
88
|
+
|
89
|
+
```yml
|
90
|
+
benbalter:
|
91
|
+
picture: /img/benbalter.png
|
92
|
+
twitter: jekyllrb
|
93
|
+
|
94
|
+
potus:
|
95
|
+
picture: /img/potus.png
|
96
|
+
twitter: whitehouse
|
97
|
+
```
|
98
|
+
|
99
|
+
In the above example, the author `benbalter`'s Twitter handle will be resolved to `@jekyllrb`. This allows you to centralize author information in a single `_data/authors` file for site with many authors that require more than just the author's username.
|
100
|
+
|
101
|
+
*Pro-tip: If `authors` is present in the document's front matter as an array (and `author` is not), the plugin will use the first author listed.*
|
102
|
+
|
103
|
+
4. An author in the document's front matter (the simplest way), e.g.:
|
104
|
+
|
105
|
+
```yml
|
106
|
+
author: benbalter
|
107
|
+
```
|
108
|
+
|
109
|
+
5. An author in the site's `_config.yml`, e.g.:
|
110
|
+
|
111
|
+
```yml
|
112
|
+
author: benbalter
|
113
|
+
```
|
114
|
+
|
115
|
+
* `image` - URL of an image that is representative of the post.
|
63
116
|
|
64
117
|
### Meta tags
|
65
118
|
|
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.5.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"
|
@@ -14,11 +14,11 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
|
-
spec.add_development_dependency "jekyll", ">=
|
17
|
+
spec.add_development_dependency "jekyll", ">= 3.0.0", "< 3.2.0"
|
18
18
|
spec.add_development_dependency "bundler", "~> 1.6"
|
19
19
|
spec.add_development_dependency "rake", "~> 10.0"
|
20
20
|
spec.add_development_dependency "rspec", "~> 3.0"
|
21
21
|
spec.add_development_dependency "typhoeus", "~> 0.7"
|
22
22
|
spec.add_development_dependency "nokogiri", "~> 1.6"
|
23
|
-
spec.add_development_dependency "
|
23
|
+
spec.add_development_dependency "rubocop"
|
24
24
|
end
|
data/lib/feed.xml
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
{% else %}
|
5
5
|
{% assign url_base = site.github.url %}
|
6
6
|
{% endif %}
|
7
|
-
<feed xmlns="http://www.w3.org/2005/Atom">
|
7
|
+
<feed xmlns="http://www.w3.org/2005/Atom"{% if site.lang %} xml:lang="{{ site.lang }}"{% endif %}>
|
8
8
|
<generator uri="http://jekyllrb.com" version="{{ jekyll.version }}">Jekyll</generator>
|
9
9
|
<link href="{{ page.url | prepend: url_base }}" rel="self" type="application/atom+xml" />
|
10
|
-
<link href="{{ url_base }}/" rel="alternate" type="text/html" />
|
10
|
+
<link href="{{ url_base }}/" rel="alternate" type="text/html" {% if site.lang %}hreflang="{{ site.lang }}" {% endif %}/>
|
11
11
|
<updated>{{ site.time | date_to_xmlschema }}</updated>
|
12
12
|
<id>{{ url_base | xml_escape }}/</id>
|
13
13
|
|
@@ -38,7 +38,8 @@
|
|
38
38
|
{% endif %}
|
39
39
|
|
40
40
|
{% for post in site.posts limit: 10 %}
|
41
|
-
|
41
|
+
{% unless post.draft %}
|
42
|
+
<entry{% if post.lang %} xml:lang="{{ post.lang }}"{% endif %}>
|
42
43
|
<title>{{ post.title | markdownify | strip_html | replace: '\n', ' ' | strip | xml_escape }}</title>
|
43
44
|
<link href="{{ post.url | prepend: url_base }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
|
44
45
|
<published>{{ post.date | date_to_xmlschema }}</published>
|
@@ -51,18 +52,34 @@
|
|
51
52
|
<id>{{ post.id | prepend: url_base | xml_escape }}</id>
|
52
53
|
<content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
|
53
54
|
|
54
|
-
{%
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
55
|
+
{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
|
56
|
+
{% assign post_author_email = false %}
|
57
|
+
{% assign post_author_uri = false %}
|
58
|
+
{% if post_author %}
|
59
|
+
{% if post_author.email %}
|
60
|
+
{% assign post_author_email = post_author.email %}
|
61
|
+
{% else %}
|
62
|
+
{% if site.data.authors and site.data.authors[post_author] %}
|
63
|
+
{% assign post_author_email = site.data.authors[post_author].email %}
|
64
|
+
{% endif %}
|
65
|
+
{% endif %}
|
66
|
+
{% if post_author.uri %}
|
67
|
+
{% assign post_author_uri = post_author.uri %}
|
68
|
+
{% else %}
|
69
|
+
{% if site.data.authors and site.data.authors[post_author] %}
|
70
|
+
{% assign post_author_email = site.data.authors[post_author].uri %}
|
60
71
|
{% endif %}
|
61
|
-
|
62
|
-
|
72
|
+
{% endif %}
|
73
|
+
{% if post_author.name %}
|
74
|
+
{% assign post_author = post_author.name %}
|
75
|
+
{% endif %}
|
76
|
+
<author>
|
77
|
+
<name>{{ post_author | xml_escape }}</name>
|
78
|
+
{% if post_author_email %}
|
79
|
+
<email>{{ post_author_email | xml_escape }}</email>
|
63
80
|
{% endif %}
|
64
|
-
{% if
|
65
|
-
<uri>{{
|
81
|
+
{% if post_author_uri %}
|
82
|
+
<uri>{{ post_author_uri | xml_escape }}</uri>
|
66
83
|
{% endif %}
|
67
84
|
</author>
|
68
85
|
{% endif %}
|
@@ -78,6 +95,15 @@
|
|
78
95
|
{% if post.excerpt and post.excerpt != empty %}
|
79
96
|
<summary>{{ post.excerpt | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
|
80
97
|
{% endif %}
|
98
|
+
|
99
|
+
{% assign post_image = post.image %}
|
100
|
+
{% if post_image %}
|
101
|
+
{% unless post_image contains "://" %}
|
102
|
+
{% assign post_image = post_image | prepend: url_base | xml_escape %}
|
103
|
+
{% endunless %}
|
104
|
+
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="{{ post_image }}" />
|
105
|
+
{% endif %}
|
81
106
|
</entry>
|
107
|
+
{% endunless %}
|
82
108
|
{% endfor %}
|
83
109
|
</feed>
|
data/lib/jekyll-feed.rb
CHANGED
@@ -1,94 +1,4 @@
|
|
1
|
-
require "
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
def read_yaml(*)
|
6
|
-
@data ||= {}
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
module StripWhitespace
|
11
|
-
def strip(input)
|
12
|
-
input.to_s.strip
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class FeedMetaTag < Liquid::Tag
|
17
|
-
def config
|
18
|
-
@context.registers[:site].config
|
19
|
-
end
|
20
|
-
|
21
|
-
def path
|
22
|
-
if config["feed"] && config["feed"]["path"]
|
23
|
-
config["feed"]["path"]
|
24
|
-
else
|
25
|
-
"feed.xml"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def url
|
30
|
-
if config["url"]
|
31
|
-
config["url"]
|
32
|
-
elsif config["github"] && config["github"]["url"]
|
33
|
-
config["github"]["url"]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def render(context)
|
38
|
-
@context = context
|
39
|
-
"<link type=\"application/atom+xml\" rel=\"alternate\" href=\"#{url}/#{path}\" title=\"#{config["name"]}\" />"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
class JekyllFeed < Jekyll::Generator
|
44
|
-
safe true
|
45
|
-
priority :lowest
|
46
|
-
|
47
|
-
# Path to feed from config, or feed.xml for default
|
48
|
-
def path
|
49
|
-
if @site.config["feed"] && @site.config["feed"]["path"]
|
50
|
-
@site.config["feed"]["path"]
|
51
|
-
else
|
52
|
-
"feed.xml"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Main plugin action, called by Jekyll-core
|
57
|
-
def generate(site)
|
58
|
-
@site = site
|
59
|
-
@site.config["time"] = Time.new
|
60
|
-
unless feed_exists?
|
61
|
-
@site.pages << feed_content
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Path to feed.xml template file
|
66
|
-
def source_path
|
67
|
-
File.expand_path "feed.xml", File.dirname(__FILE__)
|
68
|
-
end
|
69
|
-
|
70
|
-
def feed_content
|
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
|
77
|
-
end
|
78
|
-
|
79
|
-
# Checks if a feed already exists in the site source
|
80
|
-
def feed_exists?
|
81
|
-
if @site.respond_to?(:in_source_dir)
|
82
|
-
File.exists? @site.in_source_dir(path)
|
83
|
-
else
|
84
|
-
File.exists? Jekyll.sanitized_path(@site.source, path)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
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)
|
1
|
+
require "jekyll/feed_meta_tag"
|
2
|
+
require "jekyll/jekyll-feed"
|
3
|
+
require "jekyll/page_without_a_file"
|
4
|
+
require "jekyll/strip_whitespace"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Jekyll
|
2
|
+
class FeedMetaTag < Liquid::Tag
|
3
|
+
def render(context)
|
4
|
+
@context = context
|
5
|
+
attrs = attributes.map { |k, v| %(#{k}="#{v}") }.join(' ')
|
6
|
+
"<link #{attrs} />"
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def config
|
12
|
+
@context.registers[:site].config
|
13
|
+
end
|
14
|
+
|
15
|
+
def attributes
|
16
|
+
{
|
17
|
+
:type => 'application/atom+xml',
|
18
|
+
:rel => 'alternate',
|
19
|
+
:href => "#{url}/#{path}",
|
20
|
+
:title => title
|
21
|
+
}.keep_if { |_, v| v }
|
22
|
+
end
|
23
|
+
|
24
|
+
def path
|
25
|
+
if config["feed"] && config["feed"]["path"]
|
26
|
+
config["feed"]["path"]
|
27
|
+
else
|
28
|
+
"feed.xml"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def url
|
33
|
+
if config["url"]
|
34
|
+
URI.join(config["url"], config["baseurl"])
|
35
|
+
elsif config["github"] && config["github"]["url"]
|
36
|
+
config["github"]["url"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def title
|
41
|
+
config["title"] || config["name"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Liquid::Template.register_tag("feed_meta", Jekyll::FeedMetaTag)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
class JekyllFeed < Jekyll::Generator
|
5
|
+
safe true
|
6
|
+
priority :lowest
|
7
|
+
|
8
|
+
# Main plugin action, called by Jekyll-core
|
9
|
+
def generate(site)
|
10
|
+
@site = site
|
11
|
+
@site.config["time"] = Time.new
|
12
|
+
unless feed_exists?
|
13
|
+
@site.pages << feed_content
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
# Path to feed from config, or feed.xml for default
|
20
|
+
def path
|
21
|
+
if @site.config["feed"] && @site.config["feed"]["path"]
|
22
|
+
@site.config["feed"]["path"]
|
23
|
+
else
|
24
|
+
"feed.xml"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Path to feed.xml template file
|
29
|
+
def source_path
|
30
|
+
File.expand_path "../feed.xml", File.dirname(__FILE__)
|
31
|
+
end
|
32
|
+
|
33
|
+
def feed_content
|
34
|
+
feed = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", path)
|
35
|
+
feed.content = File.read(source_path).gsub(/\s+([{<])/, '\1')
|
36
|
+
feed.data["layout"] = nil
|
37
|
+
feed.data["sitemap"] = false
|
38
|
+
feed.output
|
39
|
+
feed
|
40
|
+
end
|
41
|
+
|
42
|
+
# Checks if a feed already exists in the site source
|
43
|
+
def feed_exists?
|
44
|
+
if @site.respond_to?(:in_source_dir)
|
45
|
+
File.exist? @site.in_source_dir(path)
|
46
|
+
else
|
47
|
+
File.exist? Jekyll.sanitized_path(@site.source, path)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# The `strip` filter was added to Liquid in version 3
|
2
|
+
# Jekyll did not require Liquid 3 until Jekyll 3.0.0
|
3
|
+
# This shim is needed for compatibility with Jekyll 2.x
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
module StripWhitespace
|
7
|
+
def strip(input)
|
8
|
+
input.to_s.strip
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
unless Liquid::StandardFilters.method_defined?(:strip)
|
14
|
+
Liquid::Template.register_filter(Jekyll::StripWhitespace)
|
15
|
+
end
|
data/script/cibuild
CHANGED
data/spec/fixtures/_config.yml
CHANGED
data/spec/jekyll-feed_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe(Jekyll::JekyllFeed) do
|
|
7
7
|
"full_rebuild" => true,
|
8
8
|
"source" => source_dir,
|
9
9
|
"destination" => dest_dir,
|
10
|
+
"show_drafts" => true,
|
10
11
|
"url" => "http://example.org",
|
11
12
|
"name" => "My awesome site",
|
12
13
|
"author" => {
|
@@ -20,6 +21,8 @@ describe(Jekyll::JekyllFeed) do
|
|
20
21
|
end
|
21
22
|
let(:site) { Jekyll::Site.new(config) }
|
22
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, {}) }
|
23
26
|
before(:each) do
|
24
27
|
site.process
|
25
28
|
end
|
@@ -41,6 +44,7 @@ describe(Jekyll::JekyllFeed) do
|
|
41
44
|
expect(contents).to match /http:\/\/example\.org\/2014\/03\/04\/march-the-fourth\.html/
|
42
45
|
expect(contents).to match /http:\/\/example\.org\/2014\/03\/02\/march-the-second\.html/
|
43
46
|
expect(contents).to match /http:\/\/example\.org\/2013\/12\/12\/dec-the-second\.html/
|
47
|
+
expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/
|
44
48
|
end
|
45
49
|
|
46
50
|
it "does not include assets or any static files that aren't .html" do
|
@@ -68,7 +72,7 @@ describe(Jekyll::JekyllFeed) do
|
|
68
72
|
expect(contents).to match /<p>March the second!<\/p>/
|
69
73
|
end
|
70
74
|
|
71
|
-
it "
|
75
|
+
it "uses last_modified_at where available" do
|
72
76
|
expect(contents).to match /<updated>2015-05-12T13:27:59\+00:00<\/updated>/
|
73
77
|
end
|
74
78
|
|
@@ -81,6 +85,11 @@ describe(Jekyll::JekyllFeed) do
|
|
81
85
|
expect(contents).not_to match /Liquid is not rendered\./
|
82
86
|
end
|
83
87
|
|
88
|
+
it "includes the item image" do
|
89
|
+
expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://example.org/image.png" />')
|
90
|
+
expect(contents).to include('<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://cdn.example.org/absolute.png" />')
|
91
|
+
end
|
92
|
+
|
84
93
|
context "parsing" do
|
85
94
|
let(:feed) { RSS::Parser.parse(contents) }
|
86
95
|
|
@@ -161,6 +170,13 @@ describe(Jekyll::JekyllFeed) do
|
|
161
170
|
result.css("warning").each do |warning|
|
162
171
|
# Quiet a warning that results from us passing the feed as a string
|
163
172
|
next if warning.css("text").text =~ /Self reference doesn't match document location/
|
173
|
+
|
174
|
+
# Quiet expected warning that results from blank summary test case
|
175
|
+
next if warning.css("text").text =~ /(content|summary) should not be blank/
|
176
|
+
|
177
|
+
# Quiet expected warning about multiple posts with same updated time
|
178
|
+
next if warning.css("text").text =~ /Two entries with the same value for atom:updated/
|
179
|
+
|
164
180
|
warn "Validation warning: #{warning.css("text").text} on line #{warning.css("line").text} column #{warning.css("column").text}"
|
165
181
|
end
|
166
182
|
|
@@ -182,13 +198,31 @@ describe(Jekyll::JekyllFeed) do
|
|
182
198
|
expect(contents).to match /http:\/\/example\.org\/bass\/2014\/03\/02\/march-the-second\.html/
|
183
199
|
expect(contents).to match /http:\/\/example\.org\/bass\/2013\/12\/12\/dec-the-second\.html/
|
184
200
|
end
|
201
|
+
|
202
|
+
it "renders the feed meta" do
|
203
|
+
expected = 'href="http://example.org/bass/feed.xml"'
|
204
|
+
expect(feed_meta).to include(expected)
|
205
|
+
end
|
185
206
|
end
|
186
207
|
|
187
208
|
context "feed meta" do
|
188
209
|
it "renders the feed meta" do
|
189
|
-
index = File.read(dest_dir("index.html"))
|
190
210
|
expected = '<link type="application/atom+xml" rel="alternate" href="http://example.org/feed.xml" title="My awesome site" />'
|
191
|
-
expect(
|
211
|
+
expect(feed_meta).to eql(expected)
|
212
|
+
end
|
213
|
+
|
214
|
+
context "with a blank site name" do
|
215
|
+
let(:config) do
|
216
|
+
Jekyll.configuration({
|
217
|
+
"source" => source_dir,
|
218
|
+
"destination" => dest_dir,
|
219
|
+
"url" => "http://example.org"
|
220
|
+
})
|
221
|
+
end
|
222
|
+
|
223
|
+
it "does not output blank title" do
|
224
|
+
expect(feed_meta).not_to include('title=')
|
225
|
+
end
|
192
226
|
end
|
193
227
|
end
|
194
228
|
|
@@ -206,9 +240,8 @@ describe(Jekyll::JekyllFeed) do
|
|
206
240
|
end
|
207
241
|
|
208
242
|
it "renders the feed meta with custom feed path" do
|
209
|
-
|
210
|
-
|
211
|
-
expect(index).to include(expected)
|
243
|
+
expected = 'href="http://example.org/atom.xml"'
|
244
|
+
expect(feed_meta).to include(expected)
|
212
245
|
end
|
213
246
|
end
|
214
247
|
end
|
data/spec/spec_helper.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.5.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:
|
11
|
+
date: 2016-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 3.
|
22
|
+
version: 3.2.0
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 3.0.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 3.
|
32
|
+
version: 3.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,19 +101,19 @@ dependencies:
|
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1.6'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
104
|
+
name: rubocop
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0
|
109
|
+
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0
|
116
|
+
version: '0'
|
117
117
|
description:
|
118
118
|
email:
|
119
119
|
- ben.balter@github.com
|
@@ -123,6 +123,7 @@ extra_rdoc_files: []
|
|
123
123
|
files:
|
124
124
|
- ".gitignore"
|
125
125
|
- ".rspec"
|
126
|
+
- ".rubocop.yml"
|
126
127
|
- ".travis.yml"
|
127
128
|
- Gemfile
|
128
129
|
- History.markdown
|
@@ -132,10 +133,15 @@ files:
|
|
132
133
|
- jekyll-feed.gemspec
|
133
134
|
- lib/feed.xml
|
134
135
|
- lib/jekyll-feed.rb
|
136
|
+
- lib/jekyll/feed_meta_tag.rb
|
137
|
+
- lib/jekyll/jekyll-feed.rb
|
138
|
+
- lib/jekyll/page_without_a_file.rb
|
139
|
+
- lib/jekyll/strip_whitespace.rb
|
135
140
|
- script/bootstrap
|
136
141
|
- script/cibuild
|
137
142
|
- script/release
|
138
143
|
- spec/fixtures/_config.yml
|
144
|
+
- spec/fixtures/_drafts/2015-01-12-a-draft.md
|
139
145
|
- spec/fixtures/_layouts/some_default.html
|
140
146
|
- spec/fixtures/_posts/2013-12-12-dec-the-second.md
|
141
147
|
- spec/fixtures/_posts/2014-03-02-march-the-second.md
|
@@ -145,7 +151,6 @@ files:
|
|
145
151
|
- spec/fixtures/_posts/2015-05-12-liquid.md
|
146
152
|
- spec/fixtures/_posts/2015-05-12-pre.html
|
147
153
|
- spec/fixtures/_posts/2015-05-18-author-detail.md
|
148
|
-
- spec/fixtures/index.html
|
149
154
|
- spec/jekyll-feed_spec.rb
|
150
155
|
- spec/spec_helper.rb
|
151
156
|
homepage: https://github.com/jekyll/jekyll-feed
|
@@ -168,12 +173,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
173
|
version: '0'
|
169
174
|
requirements: []
|
170
175
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.
|
176
|
+
rubygems_version: 2.5.1
|
172
177
|
signing_key:
|
173
178
|
specification_version: 4
|
174
179
|
summary: A Jekyll plugin to generate an Atom feed of your Jekyll posts
|
175
180
|
test_files:
|
176
181
|
- spec/fixtures/_config.yml
|
182
|
+
- spec/fixtures/_drafts/2015-01-12-a-draft.md
|
177
183
|
- spec/fixtures/_layouts/some_default.html
|
178
184
|
- spec/fixtures/_posts/2013-12-12-dec-the-second.md
|
179
185
|
- spec/fixtures/_posts/2014-03-02-march-the-second.md
|
@@ -183,6 +189,5 @@ test_files:
|
|
183
189
|
- spec/fixtures/_posts/2015-05-12-liquid.md
|
184
190
|
- spec/fixtures/_posts/2015-05-12-pre.html
|
185
191
|
- spec/fixtures/_posts/2015-05-18-author-detail.md
|
186
|
-
- spec/fixtures/index.html
|
187
192
|
- spec/jekyll-feed_spec.rb
|
188
193
|
- spec/spec_helper.rb
|
data/spec/fixtures/index.html
DELETED