jekyll-feed 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80c0827ec88c28865d0417d28b5f06173934edcf
4
- data.tar.gz: 1439eced789aac13552f0894f43df74f3ec6302b
3
+ metadata.gz: 42b66d68627e46afebafbc2c4ad469c7004f7de1
4
+ data.tar.gz: 25c6ae75817b2b04df23be3b96784e315e1a96e6
5
5
  SHA512:
6
- metadata.gz: a9aa3eb03c7e39204916bc4aa3156826d2de45a0c61673697fb26c96527d421e5149be4b0c43da8bde2f9fb2a2de298dc23614084d1f30972ea87243aa7978dd
7
- data.tar.gz: e95dccf7210adf25351e95049e6a09b2fd0758e40a3eb9e7a8956ad12f0614e89eea211a08ad61b757156a385bf6662bd0a73720601865ded6f583aba077632a
6
+ metadata.gz: 2c670c4f552516f4001f948b13a9335202662994f053e8b22f5b8304c0566c18302dc06387574b2713c320eb5cbf122ba5379233eff24b0fa5a8b8abdd811be3
7
+ data.tar.gz: 685e0605447eb2b4e0b02afad01a419bbdfbffbd68c063ae239b87721352c109115201878538963bab0d1e4aaeeb2239f4980ccca6603c4eaef498d6e01cd5b0
@@ -1,3 +1,10 @@
1
+ ## 0.6.0 / 2016-07-08
2
+
3
+ * Cleanup `post_author` logic (#113)
4
+ * Add XML stylesheet example with XSLT (#119)
5
+ * DRY up and add more doc (#120)
6
+ * Use smartify filter (#117)
7
+
1
8
  ## 0.5.1 / 2016-04-18
2
9
 
3
10
  * Fix mangling of whitespace when `site.lang` is set (#110)
data/README.md CHANGED
@@ -112,12 +112,16 @@ There are several ways to convey author-specific information. Author information
112
112
  author: benbalter
113
113
  ```
114
114
 
115
- * `image` - URL of an image that is representative of the post.
115
+ * `image` - URL of an image that is representative of the post.
116
116
 
117
117
  ### Meta tags
118
118
 
119
119
  The plugin exposes a helper tag to expose the appropriate meta tags to support automated discovery of your feed. Simply place `{% feed_meta %}` someplace in your template's `<head>` section, to output the necessary metadata.
120
120
 
121
+ ### SmartyPants
122
+
123
+ The plugin uses [Jekyll's `smartify` filter](https://jekyllrb.com/docs/templates/) for processing the site title and post titles. This will translate plain ASCII punctuation into "smart" typographic punctuation. This will not render or strip any Markdown you may be using in a title.
124
+
121
125
  ## Why Atom, and not RSS?
122
126
 
123
127
  Great question. In short, Atom is a better format. Think of it like RSS 3.0. For more information, see [this discussion on why we chose Atom over RSS 2.0](https://github.com/jekyll/jekyll-rss-feed/issues/2).
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "jekyll-feed"
5
- spec.version = "0.5.1"
5
+ spec.version = "0.6.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,7 +14,7 @@ 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", ">= 3.0.0", "< 3.2.0"
17
+ spec.add_development_dependency "jekyll", ">= 3.1.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"
@@ -1,4 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
+ <?xml-stylesheet type="text/xml" href="{{ url_base }}/feed.xslt.xml"?>
2
3
  {% if site.url %}
3
4
  {% assign url_base = site.url | append: site.baseurl %}
4
5
  {% else %}
@@ -12,9 +13,9 @@
12
13
  <id>{{ url_base | xml_escape }}/</id>
13
14
 
14
15
  {% if site.title %}
15
- <title>{{ site.title | xml_escape }}</title>
16
+ <title>{{ site.title | smartify | xml_escape }}</title>
16
17
  {% elsif site.name %}
17
- <title>{{ site.name | xml_escape }}</title>
18
+ <title>{{ site.name | smartify | xml_escape }}</title>
18
19
  {% endif %}
19
20
 
20
21
  {% if site.description %}
@@ -40,7 +41,7 @@
40
41
  {% for post in site.posts limit: 10 %}
41
42
  {% unless post.draft %}
42
43
  <entry{% if post.lang %} xml:lang="{{ post.lang }}"{% endif %}>
43
- <title>{{ post.title | markdownify | strip_html | replace: '\n', ' ' | strip | xml_escape }}</title>
44
+ <title>{{ post.title | smartify | strip_html | replace: '\n', ' ' | strip | xml_escape }}</title>
44
45
  <link href="{{ post.url | prepend: url_base }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
45
46
  <published>{{ post.date | date_to_xmlschema }}</published>
46
47
  {% if post.last_modified_at %}
@@ -53,28 +54,14 @@
53
54
  <content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
54
55
 
55
56
  {% assign post_author = post.author | default: post.authors[0] | default: site.author %}
56
- {% assign post_author_email = false %}
57
- {% assign post_author_uri = false %}
57
+ {% assign post_author = site.data.authors[post_author] | default: post_author %}
58
+ {% assign post_author_email = post_author.email | default: nil %}
59
+ {% assign post_author_uri = post_author.uri | default: nil %}
60
+ {% assign post_author_name = post_author.name | default: post_author %}
61
+
58
62
  {% 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 %}
71
- {% endif %}
72
- {% endif %}
73
- {% if post_author.name %}
74
- {% assign post_author = post_author.name %}
75
- {% endif %}
76
63
  <author>
77
- <name>{{ post_author | xml_escape }}</name>
64
+ <name>{{ post_author_name | xml_escape }}</name>
78
65
  {% if post_author_email %}
79
66
  <email>{{ post_author_email | xml_escape }}</email>
80
67
  {% endif %}
@@ -0,0 +1,41 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <xsl:transform version="1.0"
3
+ xmlns:a="http://www.w3.org/2005/Atom"
4
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
+ >
6
+
7
+ <xsl:strip-space elements="*"/>
8
+ <xsl:output method="text"/>
9
+
10
+ <xsl:template match="*"/>
11
+
12
+ <xsl:template match="a:feed">
13
+ <xsl:text>Atom Feed: </xsl:text><xsl:value-of select="a:id"/>
14
+ <xsl:text>&#10;</xsl:text>
15
+ <xsl:apply-templates/>
16
+ </xsl:template>
17
+
18
+ <xsl:template match="a:entry">
19
+ <xsl:text> ----------------------------------------&#10;</xsl:text>
20
+ <xsl:text> Feed entry: </xsl:text><xsl:value-of select="a:id"/>
21
+ <xsl:text>&#10;</xsl:text>
22
+ <xsl:apply-templates/>
23
+ </xsl:template>
24
+
25
+ <xsl:template match="a:title">
26
+ <xsl:if test="parent::a:entry">
27
+ <xsl:value-of select="' '"/>
28
+ </xsl:if>
29
+ <xsl:value-of select="local-name()"/>: <xsl:apply-templates/>
30
+ <xsl:text>&#10;</xsl:text>
31
+ </xsl:template>
32
+
33
+ <xsl:template match="a:published|a:updated">
34
+ <xsl:if test="parent::a:entry">
35
+ <xsl:value-of select="' '"/>
36
+ </xsl:if>
37
+ <xsl:value-of select="local-name()"/>: <xsl:apply-templates/>
38
+ <xsl:text>&#10;</xsl:text>
39
+ </xsl:template>
40
+
41
+ </xsl:transform>
@@ -9,15 +9,18 @@ module Jekyll
9
9
  def generate(site)
10
10
  @site = site
11
11
  @site.config["time"] = Time.new
12
- unless feed_exists?
13
- @site.pages << feed_content
12
+ unless file_exists?(feed_path)
13
+ @site.pages << content_for_file(feed_path, feed_source_path)
14
+ end
15
+ unless file_exists?(xslt_path)
16
+ @site.pages << content_for_file(xslt_path, xslt_source_path)
14
17
  end
15
18
  end
16
19
 
17
20
  private
18
21
 
19
22
  # Path to feed from config, or feed.xml for default
20
- def path
23
+ def feed_path
21
24
  if @site.config["feed"] && @site.config["feed"]["path"]
22
25
  @site.config["feed"]["path"]
23
26
  else
@@ -25,27 +28,38 @@ module Jekyll
25
28
  end
26
29
  end
27
30
 
31
+ # Path to feed stylesheet from config
32
+ def xslt_path
33
+ "feed.xslt.xml"
34
+ end
35
+
28
36
  # Path to feed.xml template file
29
- def source_path
37
+ def feed_source_path
30
38
  File.expand_path "../feed.xml", File.dirname(__FILE__)
31
39
  end
32
40
 
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
41
+ # Path to the feed.xslt.xml template file
42
+ def xslt_source_path
43
+ File.expand_path "../feed.xslt.xml", File.dirname(__FILE__)
40
44
  end
41
45
 
42
- # Checks if a feed already exists in the site source
43
- def feed_exists?
46
+ # Checks if a file already exists in the site source
47
+ def file_exists?(file_path)
44
48
  if @site.respond_to?(:in_source_dir)
45
- File.exist? @site.in_source_dir(path)
49
+ File.exist? @site.in_source_dir(file_path)
46
50
  else
47
- File.exist? Jekyll.sanitized_path(@site.source, path)
51
+ File.exist? Jekyll.sanitized_path(@site.source, file_path)
48
52
  end
49
53
  end
54
+
55
+ # Generates contents for a file
56
+ def content_for_file(file_path, file_source_path)
57
+ file = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", file_path)
58
+ file.content = File.read(file_source_path).gsub(/(?<!\")\s+([<{])/, '\1')
59
+ file.data["layout"] = nil
60
+ file.data["sitemap"] = false
61
+ file.output
62
+ file
63
+ end
50
64
  end
51
65
  end
@@ -0,0 +1,5 @@
1
+ garthdb:
2
+ name: Garth
3
+ twitter: garthdb
4
+ uri: "http://garthdb.com"
5
+ email: example@mail.com
@@ -0,0 +1,6 @@
1
+ ---
2
+ excerpt: ""
3
+ author: garthdb
4
+ ---
5
+
6
+ # April the twenty-fifth?
@@ -35,6 +35,10 @@ describe(Jekyll::JekyllFeed) do
35
35
  expect(Pathname.new(dest_dir("feed.xml"))).to exist
36
36
  end
37
37
 
38
+ it "creates a feed.xslt.xml file" do
39
+ expect(Pathname.new(dest_dir("feed.xslt.xml"))).to exist
40
+ end
41
+
38
42
  it "doesn't have multiple new lines or trailing whitespace" do
39
43
  expect(contents).to_not match /\s+\n/
40
44
  expect(contents).to_not match /\n{2,}/
@@ -68,6 +72,10 @@ describe(Jekyll::JekyllFeed) do
68
72
  expect(contents).not_to match /<author>\s*<name><\/name>\s*<\/author>/
69
73
  end
70
74
 
75
+ it "does use author reference with data from _data/authors.yml" do
76
+ expect(contents).to match /<author>\s*<name>Garth<\/name>\s*<email>example@mail.com<\/email>\s*<uri>http:\/\/garthdb.com<\/uri>\s*<\/author>/
77
+ end
78
+
71
79
  it "converts markdown posts to HTML" do
72
80
  expect(contents).to match /&lt;p&gt;March the second!&lt;\/p&gt;/
73
81
  end
@@ -109,7 +117,7 @@ describe(Jekyll::JekyllFeed) do
109
117
  end
110
118
 
111
119
  it "includes the items" do
112
- expect(feed.items.count).to eql(8)
120
+ expect(feed.items.count).to eql(9)
113
121
  end
114
122
 
115
123
  it "includes item contents" do
@@ -158,6 +166,16 @@ describe(Jekyll::JekyllFeed) do
158
166
  end
159
167
  end
160
168
 
169
+ context "smartify" do
170
+ let(:site_title) { "Pat's Site" }
171
+ let(:overrides) { { "title" => site_title } }
172
+ let(:feed) { RSS::Parser.parse(contents) }
173
+
174
+ it "processes site title with SmartyPants" do
175
+ expect(feed.title.content).to eql("Pat’s Site")
176
+ end
177
+ end
178
+
161
179
  context "validation" do
162
180
  it "validates" do
163
181
  # See https://validator.w3.org/docs/api.html
@@ -245,6 +263,12 @@ describe(Jekyll::JekyllFeed) do
245
263
  end
246
264
  end
247
265
 
266
+ context "feed stylesheet" do
267
+ it "includes a default stylesheet" do
268
+ expect(contents).to include('<?xml-stylesheet type="text/xml" href="/feed.xslt.xml"?>')
269
+ end
270
+ end
271
+
248
272
  context "with site.lang set" do
249
273
  let(:overrides) { { "lang" => "en-US" } }
250
274
 
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.5.1
4
+ version: 0.6.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: 2016-04-18 00:00:00.000000000 Z
11
+ date: 2016-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 3.0.0
19
+ version: 3.1.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 3.2.0
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 3.0.0
29
+ version: 3.1.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.2.0
@@ -132,6 +132,7 @@ files:
132
132
  - Rakefile
133
133
  - jekyll-feed.gemspec
134
134
  - lib/feed.xml
135
+ - lib/feed.xslt.xml
135
136
  - lib/jekyll-feed.rb
136
137
  - lib/jekyll/feed_meta_tag.rb
137
138
  - lib/jekyll/jekyll-feed.rb
@@ -141,6 +142,7 @@ files:
141
142
  - script/cibuild
142
143
  - script/release
143
144
  - spec/fixtures/_config.yml
145
+ - spec/fixtures/_data/authors.yml
144
146
  - spec/fixtures/_drafts/2015-01-12-a-draft.md
145
147
  - spec/fixtures/_layouts/some_default.html
146
148
  - spec/fixtures/_posts/2013-12-12-dec-the-second.md
@@ -151,6 +153,7 @@ files:
151
153
  - spec/fixtures/_posts/2015-05-12-liquid.md
152
154
  - spec/fixtures/_posts/2015-05-12-pre.html
153
155
  - spec/fixtures/_posts/2015-05-18-author-detail.md
156
+ - spec/fixtures/_posts/2016-04-25-author-reference.md
154
157
  - spec/jekyll-feed_spec.rb
155
158
  - spec/spec_helper.rb
156
159
  homepage: https://github.com/jekyll/jekyll-feed
@@ -173,12 +176,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
176
  version: '0'
174
177
  requirements: []
175
178
  rubyforge_project:
176
- rubygems_version: 2.5.1
179
+ rubygems_version: 2.4.8
177
180
  signing_key:
178
181
  specification_version: 4
179
182
  summary: A Jekyll plugin to generate an Atom feed of your Jekyll posts
180
183
  test_files:
181
184
  - spec/fixtures/_config.yml
185
+ - spec/fixtures/_data/authors.yml
182
186
  - spec/fixtures/_drafts/2015-01-12-a-draft.md
183
187
  - spec/fixtures/_layouts/some_default.html
184
188
  - spec/fixtures/_posts/2013-12-12-dec-the-second.md
@@ -189,5 +193,6 @@ test_files:
189
193
  - spec/fixtures/_posts/2015-05-12-liquid.md
190
194
  - spec/fixtures/_posts/2015-05-12-pre.html
191
195
  - spec/fixtures/_posts/2015-05-18-author-detail.md
196
+ - spec/fixtures/_posts/2016-04-25-author-reference.md
192
197
  - spec/jekyll-feed_spec.rb
193
198
  - spec/spec_helper.rb