jekyll-feed 0.8.0 → 0.9.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: 31ec255441efdec76e24a57228ad15d4df8792aa
4
- data.tar.gz: 771f380686b7c6b1f988924ad385abc7e45c044a
3
+ metadata.gz: dd1897a15ad66d115a4e4fba2981d29bf41b5c87
4
+ data.tar.gz: da12a240d6bca1c5e4fd64b24864c783d85ffd77
5
5
  SHA512:
6
- metadata.gz: 4f380d4240ccedfe0d193b5ec88cf10feabae1bd948c982340fc078b1fb3653784c3be9188d42923978a67dc13d3be086d306fc324101cdc610dcd36530c664a
7
- data.tar.gz: 85c8856882d47079feb5cedbb44975d077c48a6291e6ae181fc924952292fd02b8c1b09d60d3a561cb2b59cbafe281ea5a254b1be71864b2904b7b90cd8fef50
6
+ metadata.gz: c8b68581ece18c4615341881ee3ade2c33f87cbd38eb93c0085589b2f9e44b677ca615596408a05422657c1f8ddef51acb588c9bc565cfdc3d46a442c72a7b1f
7
+ data.tar.gz: 6a0fe34bcb0044dac585c0f552981ad781a54a6e8cd1c62d4c58d25a9b594f5133b2eac01286a58d2760bb43b30221ce0912e85bce3ec57a15439d8af0632fca
data/.travis.yml CHANGED
@@ -1,12 +1,20 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2
3
+ - 2.2
4
4
  env:
5
5
  global:
6
- - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
6
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
7
7
  cache: bundler
8
8
  sudo: false
9
9
  before_script: bundle update
10
- script: ./script/cibuild
10
+ script: "./script/cibuild"
11
11
  notifications:
12
12
  email: false
13
+ deploy:
14
+ provider: rubygems
15
+ api_key:
16
+ secure: qz0q6ur0kGo03jjLdoAak6WcEAwxX2r9LG3DVrhOrcfoFipkuW+uwR0et4tpK8uFrz0P9y7eTIKOb0XCXeIsIXWj6R5benpRGr2U8m9A+tE/jxviBFUaxaokte0lqWiX1fEyhRmW3zvcdLQ47Vd2EwTNaq6ZmPulmEe9gS0rBQghyclakGlZ17LI7oGgiNL9SQ335Yqa1qJklTHYHbodWQ3Z07v7VN2jxqi3WH6NacT5gUGp5iCNCLLa8+jpKr4uONNIoy6/geAWdqtvgGUE8oTjIWDoJarrknJpqfx9Rd0KLDzkyneAigHDYPW60QtrE6GGpK/+TF1pF4DzdK2EgTWqGFnZf8ehfnxmtHVl2Xq/DPr6hS8Q/f+ut4ioMzBQxPD0hfh8/EOMYKsO8mOuOlYTiZXC7iuGyvFUOl2hnBgWA99t+I0NNB06qFp3ZxIjolEc3zjzc9f1a5HUXlEut5V8nqvCwbctNiTVpT8ZEWlsQlyRUnr9cIMUTEfLgQ+v6DnvAJBMO1EILq6liB5qfutjNhzhlREt7P/ZdppGsAzWpgt0q2PafqVoPe62WR3+/8Lj2ErMr034xSSqZVNcBS0mbdvW6k3jaABo1VJ4XuHm6/yDuemWzWb7kdG9/14+IIJMW1VuaWcmnCnB6gxjkCW3Dm2ftYiN7Rfn3AUz/nU=
17
+ gem: jekyll-feed
18
+ on:
19
+ tags: true
20
+ repo: jekyll/jekyll-feed
data/History.markdown CHANGED
@@ -1,3 +1,23 @@
1
+ ## 0.9.0 / 2017-02-16
2
+
3
+ ### Minor Enhancements
4
+
5
+ * Use absolute_url to generate the feed_meta url (#150)
6
+ * Make feed stylesheet optional (#149)
7
+ * Use new `normalize_whitespace` filter (#143)
8
+ * Feed entries must contain <author> (#152)
9
+ * Remove trailing slash from feed ID (#159)
10
+
11
+ ### Development Fixes
12
+
13
+ * Simplify minify regular expression (#141)
14
+ * Namespace as JekyllFeed (#151)
15
+ * rubocop -a (#160)
16
+
17
+ ### Bug Fixes
18
+
19
+ * Filter out drafts before limit (#154)
20
+
1
21
  ## 0.8.0 / 2016-10-06
2
22
 
3
23
  * Use filters to clean up Liquid template (#134)
data/README.md CHANGED
@@ -122,6 +122,10 @@ The plugin exposes a helper tag to expose the appropriate meta tags to support a
122
122
 
123
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
124
 
125
+ ### Custom styling
126
+
127
+ Want to style what your feed looks like in the browser? Simply add an XSLT at `/feed.xslt.xml` and Jekyll Feed will link to the stylesheet.
128
+
125
129
  ## Why Atom, and not RSS?
126
130
 
127
131
  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).
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.8.0"
5
+ spec.version = "0.9.0"
6
6
  spec.authors = ["Ben Balter"]
7
7
  spec.email = ["ben.balter@github.com"]
8
8
  spec.summary = "A Jekyll plugin to generate an Atom feed of your Jekyll posts"
data/lib/jekyll-feed.rb CHANGED
@@ -1,3 +1,10 @@
1
- require "jekyll/feed_meta_tag"
2
- require "jekyll/jekyll-feed"
3
- require "jekyll/page_without_a_file"
1
+ require "jekyll"
2
+ require "fileutils"
3
+ require "jekyll-feed/generator"
4
+
5
+ module JekyllFeed
6
+ autoload :MetaTag, "jekyll-feed/meta-tag"
7
+ autoload :PageWithoutAFile, "jekyll-feed/page-without-a-file.rb"
8
+ end
9
+
10
+ Liquid::Template.register_tag "feed_meta", JekyllFeed::MetaTag
@@ -1,11 +1,13 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
- <?xml-stylesheet type="text/xml" href="{{ '/feed.xslt.xml' | absolute_url }}"?>
2
+ {% if page.xsl %}
3
+ <?xml-stylesheet type="text/xml" href="{{ '/feed.xslt.xml' | absolute_url }}"?>
4
+ {% endif %}
3
5
  <feed xmlns="http://www.w3.org/2005/Atom"{% if site.lang %} xml:lang="{{ site.lang }}"{% endif %}>
4
6
  <generator uri="http://jekyllrb.com" version="{{ jekyll.version }}">Jekyll</generator>
5
7
  <link href="{{ page.url | absolute_url }}" rel="self" type="application/atom+xml" />
6
8
  <link href="{{ '/' | absolute_url }}" rel="alternate" type="text/html" {% if site.lang %}hreflang="{{ site.lang }}" {% endif %}/>
7
9
  <updated>{{ site.time | date_to_xmlschema }}</updated>
8
- <id>{{ '/' | absolute_url | xml_escape }}/</id>
10
+ <id>{{ '/' | absolute_url | xml_escape }}</id>
9
11
 
10
12
  {% if site.title %}
11
13
  <title type="html">{{ site.title | smartify | xml_escape }}</title>
@@ -29,10 +31,10 @@
29
31
  </author>
30
32
  {% endif %}
31
33
 
32
- {% for post in site.posts limit: 10 %}
33
- {% unless post.draft %}
34
+ {% assign posts = site.posts | where_exp: "post", "post.draft != true" %}
35
+ {% for post in posts limit: 10 %}
34
36
  <entry{% if post.lang %} xml:lang="{{ post.lang }}"{% endif %}>
35
- <title type="html">{{ post.title | smartify | strip_html | replace: '\n', ' ' | strip | xml_escape }}</title>
37
+ <title type="html">{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
36
38
  <link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
37
39
  <published>{{ post.date | date_to_xmlschema }}</published>
38
40
  <updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
@@ -45,17 +47,15 @@
45
47
  {% assign post_author_uri = post_author.uri | default: nil %}
46
48
  {% assign post_author_name = post_author.name | default: post_author %}
47
49
 
48
- {% if post_author %}
49
- <author>
50
- <name>{{ post_author_name | xml_escape }}</name>
51
- {% if post_author_email %}
52
- <email>{{ post_author_email | xml_escape }}</email>
53
- {% endif %}
54
- {% if post_author_uri %}
55
- <uri>{{ post_author_uri | xml_escape }}</uri>
56
- {% endif %}
57
- </author>
58
- {% endif %}
50
+ <author>
51
+ <name>{{ post_author_name | default: "" | xml_escape }}</name>
52
+ {% if post_author_email %}
53
+ <email>{{ post_author_email | xml_escape }}</email>
54
+ {% endif %}
55
+ {% if post_author_uri %}
56
+ <uri>{{ post_author_uri | xml_escape }}</uri>
57
+ {% endif %}
58
+ </author>
59
59
 
60
60
  {% if post.category %}
61
61
  <category term="{{ post.category | xml_escape }}" />
@@ -66,7 +66,7 @@
66
66
  {% endfor %}
67
67
 
68
68
  {% if post.excerpt and post.excerpt != empty %}
69
- <summary type="html">{{ post.excerpt | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
69
+ <summary type="html">{{ post.excerpt | strip_html | normalize_whitespace | xml_escape }}</summary>
70
70
  {% endif %}
71
71
 
72
72
  {% assign post_image = post.image.path | default: post.image %}
@@ -77,6 +77,5 @@
77
77
  <media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="{{ post_image }}" />
78
78
  {% endif %}
79
79
  </entry>
80
- {% endunless %}
81
80
  {% endfor %}
82
81
  </feed>
@@ -1,23 +1,23 @@
1
- require "fileutils"
2
-
3
- module Jekyll
4
- class JekyllFeed < Jekyll::Generator
1
+ module JekyllFeed
2
+ class Generator < Jekyll::Generator
5
3
  safe true
6
4
  priority :lowest
7
5
 
8
6
  # Main plugin action, called by Jekyll-core
9
7
  def generate(site)
10
8
  @site = site
11
- unless file_exists?(feed_path)
12
- @site.pages << content_for_file(feed_path, feed_source_path)
13
- end
14
- unless file_exists?(xslt_path)
15
- @site.pages << content_for_file(xslt_path, xslt_source_path)
16
- end
9
+ return if file_exists?(feed_path)
10
+ @site.pages << content_for_file(feed_path, feed_source_path)
17
11
  end
18
12
 
19
13
  private
20
14
 
15
+ # Matches all whitespace that follows
16
+ # 1. A '>', which closes an XML tag or
17
+ # 2. A '}', which closes a Liquid tag
18
+ # We will strip all of this whitespace to minify the template
19
+ MINIFY_REGEX = %r!(?<=>|})\s+!
20
+
21
21
  # Path to feed from config, or feed.xml for default
22
22
  def feed_path
23
23
  if @site.config["feed"] && @site.config["feed"]["path"]
@@ -27,19 +27,9 @@ module Jekyll
27
27
  end
28
28
  end
29
29
 
30
- # Path to feed stylesheet from config
31
- def xslt_path
32
- "feed.xslt.xml"
33
- end
34
-
35
30
  # Path to feed.xml template file
36
31
  def feed_source_path
37
- File.expand_path "../feed.xml", File.dirname(__FILE__)
38
- end
39
-
40
- # Path to the feed.xslt.xml template file
41
- def xslt_source_path
42
- File.expand_path "../feed.xslt.xml", File.dirname(__FILE__)
32
+ File.expand_path "./feed.xml", File.dirname(__FILE__)
43
33
  end
44
34
 
45
35
  # Checks if a file already exists in the site source
@@ -54,9 +44,10 @@ module Jekyll
54
44
  # Generates contents for a file
55
45
  def content_for_file(file_path, file_source_path)
56
46
  file = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", file_path)
57
- file.content = File.read(file_source_path).gsub(%r!(?<\!")\s+([<{])!, '\1')
47
+ file.content = File.read(file_source_path).gsub(MINIFY_REGEX, "")
58
48
  file.data["layout"] = nil
59
49
  file.data["sitemap"] = false
50
+ file.data["xsl"] = file_exists?("feed.xslt.xml")
60
51
  file.output
61
52
  file
62
53
  end
@@ -1,5 +1,8 @@
1
- module Jekyll
2
- class FeedMetaTag < Liquid::Tag
1
+ module JekyllFeed
2
+ class MetaTag < Liquid::Tag
3
+ # Use Jekyll's native relative_url filter
4
+ include Jekyll::Filters::URLFilters
5
+
3
6
  def render(context)
4
7
  @context = context
5
8
  attrs = attributes.map { |k, v| %(#{k}="#{v}") }.join(" ")
@@ -16,8 +19,8 @@ module Jekyll
16
19
  {
17
20
  :type => "application/atom+xml",
18
21
  :rel => "alternate",
19
- :href => "#{url}/#{path}",
20
- :title => title
22
+ :href => absolute_url(path),
23
+ :title => title,
21
24
  }.keep_if { |_, v| v }
22
25
  end
23
26
 
@@ -29,18 +32,8 @@ module Jekyll
29
32
  end
30
33
  end
31
34
 
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
35
  def title
41
36
  config["title"] || config["name"]
42
37
  end
43
38
  end
44
39
  end
45
-
46
- Liquid::Template.register_tag("feed_meta", Jekyll::FeedMetaTag)
@@ -1,5 +1,5 @@
1
- module Jekyll
2
- class PageWithoutAFile < Page
1
+ module JekyllFeed
2
+ class PageWithoutAFile < Jekyll::Page
3
3
  def read_yaml(*)
4
4
  @data ||= {}
5
5
  end
File without changes
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe(Jekyll::JekyllFeed) do
3
+ describe(JekyllFeed) do
4
4
  let(:overrides) { Hash.new }
5
5
  let(:config) do
6
6
  Jekyll.configuration(Jekyll::Utils.deep_merge_hashes({
@@ -35,9 +35,6 @@ 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
39
  it "doesn't have multiple new lines or trailing whitespace" do
43
40
  expect(contents).to_not match /\s+\n/
@@ -48,6 +45,7 @@ describe(Jekyll::JekyllFeed) do
48
45
  expect(contents).to match /http:\/\/example\.org\/2014\/03\/04\/march-the-fourth\.html/
49
46
  expect(contents).to match /http:\/\/example\.org\/2014\/03\/02\/march-the-second\.html/
50
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"
51
49
  expect(contents).to_not match /http:\/\/example\.org\/2016\/02\/09\/a-draft\.html/
52
50
  end
53
51
 
@@ -118,7 +116,7 @@ describe(Jekyll::JekyllFeed) do
118
116
  end
119
117
 
120
118
  it "includes the items" do
121
- expect(feed.items.count).to eql(9)
119
+ expect(feed.items.count).to eql(10)
122
120
  end
123
121
 
124
122
  it "includes item contents" do
@@ -265,7 +263,7 @@ describe(Jekyll::JekyllFeed) do
265
263
  end
266
264
 
267
265
  context "feed stylesheet" do
268
- it "includes a default stylesheet" do
266
+ it "includes the stylesheet" do
269
267
  expect(contents).to include('<?xml-stylesheet type="text/xml" href="http://example.org/feed.xslt.xml"?>')
270
268
  end
271
269
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-feed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.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-10-06 00:00:00.000000000 Z
11
+ date: 2017-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -125,12 +125,11 @@ files:
125
125
  - README.md
126
126
  - Rakefile
127
127
  - jekyll-feed.gemspec
128
- - lib/feed.xml
129
- - lib/feed.xslt.xml
130
128
  - lib/jekyll-feed.rb
131
- - lib/jekyll/feed_meta_tag.rb
132
- - lib/jekyll/jekyll-feed.rb
133
- - lib/jekyll/page_without_a_file.rb
129
+ - lib/jekyll-feed/feed.xml
130
+ - lib/jekyll-feed/generator.rb
131
+ - lib/jekyll-feed/meta-tag.rb
132
+ - lib/jekyll-feed/page-without-a-file.rb
134
133
  - script/bootstrap
135
134
  - script/cibuild
136
135
  - script/release
@@ -146,7 +145,9 @@ files:
146
145
  - spec/fixtures/_posts/2015-05-12-liquid.md
147
146
  - spec/fixtures/_posts/2015-05-12-pre.html
148
147
  - spec/fixtures/_posts/2015-05-18-author-detail.md
148
+ - spec/fixtures/_posts/2015-08-08-stuck-in-the-middle.html
149
149
  - spec/fixtures/_posts/2016-04-25-author-reference.md
150
+ - spec/fixtures/feed.xslt.xml
150
151
  - spec/jekyll-feed_spec.rb
151
152
  - spec/spec_helper.rb
152
153
  homepage: https://github.com/jekyll/jekyll-feed
@@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
170
  version: '0'
170
171
  requirements: []
171
172
  rubyforge_project:
172
- rubygems_version: 2.6.7
173
+ rubygems_version: 2.4.5
173
174
  signing_key:
174
175
  specification_version: 4
175
176
  summary: A Jekyll plugin to generate an Atom feed of your Jekyll posts
@@ -186,6 +187,8 @@ test_files:
186
187
  - spec/fixtures/_posts/2015-05-12-liquid.md
187
188
  - spec/fixtures/_posts/2015-05-12-pre.html
188
189
  - spec/fixtures/_posts/2015-05-18-author-detail.md
190
+ - spec/fixtures/_posts/2015-08-08-stuck-in-the-middle.html
189
191
  - spec/fixtures/_posts/2016-04-25-author-reference.md
192
+ - spec/fixtures/feed.xslt.xml
190
193
  - spec/jekyll-feed_spec.rb
191
194
  - spec/spec_helper.rb
data/lib/feed.xslt.xml DELETED
@@ -1,41 +0,0 @@
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>