bridgetown-feed 1.1.2 → 2.1.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
  SHA256:
3
- metadata.gz: e488ad9cbebe5602f22f03215c63806c1a925739e8828e2237db8a2c420794d4
4
- data.tar.gz: 636346800f4ec3f188a5e39531fea6e2cd154ab35e84ff086fa686d42205de0e
3
+ metadata.gz: 8d1ee5e7054b88bba714fecc3f8586682c79310b4b868e375207a8792fc288ab
4
+ data.tar.gz: aca5c23b8dc1ef3b1a16fbd806f2bf34aed21b38553e6b8544507b3675410c94
5
5
  SHA512:
6
- metadata.gz: '049abb14c26b922bc7ddb2f1f763bdea819ef1fcd7b255d1c1282d419cd8e6d1af015b7195912cb079b97ed5a4e34deb92c24d28ebc0d84600655c2c74a49ff8'
7
- data.tar.gz: e8790590488ee178db029ecb9d794e158de8f89b9a1c46b96d52b2d196430a5b8555f1b9827d3480a5c45d5b780f6f80b571bad89cb30f1eecd7e5e5aec33898
6
+ metadata.gz: fe735a12d2e9669646ff7e3e91122ed113b90d14f4302e0dfae5a4a0a172e61dc16628dc9a1d2ae6a46aca28362a8df241934c5494eb4884cccf2dba70a91b75
7
+ data.tar.gz: 5dc692945109e3eb707b39a42f39509ab5a0299d9e266f5b6478510944645c1bc07a02ddff28f1115a51b1534bbfdbba4ac262e2cbef6bd4eb25c17d7bccec1c
data/.rubocop.yml CHANGED
@@ -1,10 +1,10 @@
1
- require: rubocop-jekyll
1
+ require: rubocop-bridgetown
2
2
 
3
3
  inherit_gem:
4
- rubocop-jekyll: .rubocop.yml
4
+ rubocop-bridgetown: .rubocop.yml
5
5
 
6
6
  AllCops:
7
- TargetRubyVersion: 2.3
7
+ TargetRubyVersion: 2.5
8
8
  Include:
9
9
  - lib/**/*.rb
10
10
 
@@ -22,6 +22,3 @@ AllCops:
22
22
  - script/**/*
23
23
  - vendor/**/*
24
24
 
25
- Naming/MemoizedInstanceVariableName:
26
- Exclude:
27
- - lib/bridgetown-feed/page-without-a-file.rb
data/CHANGELOG.md CHANGED
@@ -1,6 +1,27 @@
1
- # master
1
+ # Changelog
2
2
 
3
- # 1.1.2 / 2020-05-01
3
+ ## Unreleased
4
+
5
+ ...
6
+
7
+ ## 2.1.0 / 2021-10-26
8
+
9
+ * Update test suite and ensure generated pages have the right permalink
10
+ * Switch from `site.pages` to `site.generated_pages` due to Bridgetown 1.0 API change
11
+
12
+ ## 2.0.1 / 2021-06-04
13
+
14
+ * Fix bug where resources' relative URLs weren't included properly
15
+
16
+ ## 2.0.0 / 2021-04-17
17
+
18
+ * New release with helper to support Ruby templates like ERB
19
+
20
+ ## 1.1.3 / 2020-11-05
21
+
22
+ * Add `template_engine: liquid` to the feed XML so it plays well with Bridgetown 0.18+
23
+
24
+ ## 1.1.2 / 2020-05-01
4
25
 
5
26
  Update to require a minimum Ruby version of 2.5.
6
27
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Bridgetown Feed plugin
2
2
 
3
- A Bridgetown plugin to generate an Atom (RSS-like) feed of your Bridgetown posts
3
+ A Bridgetown plugin to generate an Atom (RSS-like) feed of your Bridgetown posts and other collection documents.
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,13 +16,27 @@ Or simply add this line to your Gemfile:
16
16
  gem 'bridgetown-feed', group: "bridgetown_plugins"
17
17
  ```
18
18
 
19
- ## Usage
19
+ The plugin exposes a helper tag to expose the appropriate meta tags to support automated discovery of your feed.
20
20
 
21
- The plugin will automatically generate an Atom feed at `/feed.xml`.
21
+ Simply place `feed_meta` someplace in your layout's `<head>` section to output the necessary metadata.
22
+
23
+ ```liquid
24
+ <!-- layout.liquid -->
25
+ {% feed_meta %}
26
+ ```
27
+
28
+ ```erb
29
+ <!-- layout.erb -->
30
+ <%= feed_meta %>
31
+ ```
22
32
 
23
- ### Meta tags
33
+ ### Atom is nice and all, but what about JSON Feed?
24
34
 
25
- 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.
35
+ [It's on our roadmap.](https://github.com/bridgetownrb/bridgetown-feed/issues/1) 🙂
36
+
37
+ ## Usage
38
+
39
+ The plugin will automatically generate an Atom feed at `/feed.xml`.
26
40
 
27
41
  ### Optional configuration options
28
42
 
@@ -120,7 +134,7 @@ There are several ways to convey author-specific information. Author information
120
134
 
121
135
  ### SmartyPants
122
136
 
123
- The plugin uses [Bridgetown's `smartify` filter](https://bridgetownrb.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.
137
+ The plugin uses [Bridgetown's `smartify` filter](https://www.bridgetownrb.com/docs/liquid/filters) 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
138
 
125
139
  Bridgetown's `smartify` filter uses [kramdown](https://kramdown.gettalong.org/options.html) as a processor. Accordingly, if you do not want "smart" typographic punctuation, disabling them in kramdown in your `bridgetown.config.yml` will disable them in your feed. For example:
126
140
 
@@ -134,10 +148,6 @@ Bridgetown's `smartify` filter uses [kramdown](https://kramdown.gettalong.org/op
134
148
 
135
149
  Want to style what your feed looks like in the browser? Simply add an XSLT at `/feed.xslt.xml` and Bridgetown Feed will link to the stylesheet.
136
150
 
137
- ## Why Atom, and not RSS?
138
-
139
- 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/bridgetown/bridgetown-rss-feed/issues/2).
140
-
141
151
  ## Categories
142
152
 
143
153
  Bridgetown Feed can generate feeds for each category. Simply define which categories you'd like feeds for in your config:
@@ -17,12 +17,12 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.required_ruby_version = ">= 2.5.0"
19
19
 
20
- spec.add_dependency "bridgetown", ">= 0.6", "< 2.0"
20
+ spec.add_dependency "bridgetown", ">= 1.0.0.alpha5", "< 2.0"
21
21
 
22
22
  spec.add_development_dependency "bundler"
23
23
  spec.add_development_dependency "nokogiri", "~> 1.6"
24
- spec.add_development_dependency "rake", "~> 12.0"
24
+ spec.add_development_dependency "rake", "~> 13.0"
25
25
  spec.add_development_dependency "rspec", "~> 3.0"
26
- spec.add_development_dependency "rubocop-jekyll", "~> 0.5"
26
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
27
27
  spec.add_development_dependency "typhoeus", ">= 0.7", "< 2.0"
28
28
  end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgetownFeed
4
+ class Builder < Bridgetown::Builder
5
+ include Bridgetown::Filters::URLFilters
6
+ Context = Struct.new(:registers)
7
+
8
+ def build
9
+ @context = Context.new({ site: site })
10
+ helper "feed_meta", :generate_link_tag
11
+ liquid_tag "feed_meta", :generate_link_tag
12
+ end
13
+
14
+ def generate_link_tag(*)
15
+ attrs = attributes.map { |k, v| %(#{k}="#{v}") }.join(" ")
16
+ tag_output = "<link #{attrs} />"
17
+ tag_output.respond_to?(:html_safe) ? tag_output.html_safe : tag_output
18
+ end
19
+
20
+ private
21
+
22
+ def config
23
+ @config ||= site.config
24
+ end
25
+
26
+ def metadata
27
+ @metadata ||= site.data["site_metadata"]
28
+ end
29
+
30
+ def attributes
31
+ {
32
+ type: "application/atom+xml",
33
+ rel: "alternate",
34
+ href: absolute_url(path),
35
+ title: title,
36
+ }.keep_if { |_, v| v }
37
+ end
38
+
39
+ def path
40
+ config.dig("feed", "path") || "feed.xml"
41
+ end
42
+
43
+ def title
44
+ metadata["title"] || metadata["name"]
45
+ end
46
+ end
47
+ end
48
+
49
+ BridgetownFeed::Builder.register
@@ -39,20 +39,21 @@
39
39
  </author>
40
40
  {% endif %}
41
41
 
42
- {% assign posts = site[page.collection] | where_exp: "post", "post.draft != true" | sort: "date" | reverse %}
42
+ {% assign feed_collection = collections[page.collection] %}
43
+ {% find posts where feed_collection.resources, draft != true %}
43
44
  {% if page.category %}
44
45
  {% assign posts = posts | where: "category",page.category %}
45
46
  {% endif %}
46
47
  {% for post in posts limit: 10 %}
47
48
  <entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
48
49
  <title type="html">{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
49
- <link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
50
+ <link href="{{ post.absolute_url | default: post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
50
51
  <published>{{ post.date | date_to_xmlschema }}</published>
51
52
  <updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
52
53
  <id>{{ post.id | absolute_url | xml_escape }}</id>
53
54
  {% assign excerpt_only = post.feed.excerpt_only | default: site.feed.excerpt_only %}
54
55
  {% unless excerpt_only %}
55
- <content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
56
+ <content type="html" xml:base="{{ post.absolute_url | default: post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
56
57
  {% endunless %}
57
58
 
58
59
  {% assign post_author = post.author | default: post.authors[0] | default: site.metadata.author %}
@@ -10,10 +10,10 @@ module BridgetownFeed
10
10
  collections.each do |name, meta|
11
11
  Bridgetown.logger.info "Bridgetown Feed:", "Generating feed for #{name}"
12
12
  (meta["categories"] + [nil]).each do |category|
13
- path = feed_path(:collection => name, :category => category)
13
+ path = feed_path(collection: name, category: category)
14
14
  next if file_exists?(path)
15
15
 
16
- @site.pages << make_page(path, :collection => name, :category => category)
16
+ @site.generated_pages << make_page(path, collection: name, category: category)
17
17
  end
18
18
  end
19
19
  end
@@ -85,14 +85,16 @@ module BridgetownFeed
85
85
  # Generates contents for a file
86
86
 
87
87
  def make_page(file_path, collection: "posts", category: nil)
88
- PageWithoutAFile.new(@site, __dir__, "", file_path).tap do |file|
88
+ Bridgetown::GeneratedPage.new(@site, __dir__, "", file_path, from_plugin: true).tap do |file|
89
89
  file.content = feed_template
90
90
  file.data.merge!(
91
- "layout" => nil,
92
- "sitemap" => false,
93
- "xsl" => file_exists?("feed.xslt.xml"),
94
- "collection" => collection,
95
- "category" => category
91
+ "layout" => "none",
92
+ "permalink" => file_path,
93
+ "template_engine" => "liquid",
94
+ "sitemap" => false,
95
+ "xsl" => file_exists?("feed.xslt.xml"),
96
+ "collection" => collection,
97
+ "category" => category
96
98
  )
97
99
  file.output
98
100
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bridgetown
4
4
  module Feed
5
- VERSION = "1.1.2"
5
+ VERSION = "2.1.0"
6
6
  end
7
7
  end
@@ -2,11 +2,5 @@
2
2
 
3
3
  require "bridgetown"
4
4
  require "fileutils"
5
+ require "bridgetown-feed/builder"
5
6
  require "bridgetown-feed/generator"
6
-
7
- module BridgetownFeed
8
- autoload :MetaTag, "bridgetown-feed/meta-tag"
9
- autoload :PageWithoutAFile, "bridgetown-feed/page-without-a-file.rb"
10
- end
11
-
12
- Liquid::Template.register_tag "feed_meta", BridgetownFeed::MetaTag
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridgetown-feed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-01 00:00:00.000000000 Z
11
+ date: 2021-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bridgetown
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.6'
19
+ version: 1.0.0.alpha5
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '2.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '0.6'
29
+ version: 1.0.0.alpha5
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.0'
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '12.0'
67
+ version: '13.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '12.0'
74
+ version: '13.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -87,19 +87,19 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '3.0'
89
89
  - !ruby/object:Gem::Dependency
90
- name: rubocop-jekyll
90
+ name: rubocop-bridgetown
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '0.5'
95
+ version: '0.2'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '0.5'
102
+ version: '0.2'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: typhoeus
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -136,10 +136,9 @@ files:
136
136
  - Rakefile
137
137
  - bridgetown-feed.gemspec
138
138
  - lib/bridgetown-feed.rb
139
+ - lib/bridgetown-feed/builder.rb
139
140
  - lib/bridgetown-feed/feed.xml
140
141
  - lib/bridgetown-feed/generator.rb
141
- - lib/bridgetown-feed/meta-tag.rb
142
- - lib/bridgetown-feed/page-without-a-file.rb
143
142
  - lib/bridgetown-feed/version.rb
144
143
  homepage: https://github.com/bridgetownrb/bridgetown-feed
145
144
  licenses:
@@ -160,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
160
159
  - !ruby/object:Gem::Version
161
160
  version: '0'
162
161
  requirements: []
163
- rubygems_version: 3.0.6
162
+ rubygems_version: 3.1.4
164
163
  signing_key:
165
164
  specification_version: 4
166
165
  summary: A Bridgetown plugin to generate an Atom feed of your Bridgetown posts
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BridgetownFeed
4
- class MetaTag < Liquid::Tag
5
- # Use Bridgetown's native relative_url filter
6
- include Bridgetown::Filters::URLFilters
7
-
8
- def render(context)
9
- @context = context
10
- attrs = attributes.map { |k, v| %(#{k}="#{v}") }.join(" ")
11
- "<link #{attrs} />"
12
- end
13
-
14
- private
15
-
16
- def config
17
- @config ||= @context.registers[:site].config
18
- end
19
-
20
- def metadata
21
- @metadata ||= @context.registers[:site].data["site_metadata"]
22
- end
23
-
24
- def attributes
25
- {
26
- :type => "application/atom+xml",
27
- :rel => "alternate",
28
- :href => absolute_url(path),
29
- :title => title,
30
- }.keep_if { |_, v| v }
31
- end
32
-
33
- def path
34
- config.dig("feed", "path") || "feed.xml"
35
- end
36
-
37
- def title
38
- metadata["title"] || metadata["name"]
39
- end
40
- end
41
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module BridgetownFeed
4
- class PageWithoutAFile < Bridgetown::Page
5
- def read_yaml(*)
6
- @data ||= {}
7
- end
8
- end
9
- end