bridgetown-feed 1.1.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -6
- data/CHANGELOG.md +25 -0
- data/Gemfile +0 -5
- data/README.md +24 -10
- data/bridgetown-feed.gemspec +3 -3
- data/lib/bridgetown-feed.rb +1 -7
- data/lib/bridgetown-feed/builder.rb +49 -0
- data/lib/bridgetown-feed/feed.xml +8 -4
- data/lib/bridgetown-feed/generator.rb +9 -8
- data/lib/bridgetown-feed/version.rb +1 -1
- metadata +11 -12
- data/History.markdown +0 -9
- data/lib/bridgetown-feed/meta-tag.rb +0 -41
- data/lib/bridgetown-feed/page-without-a-file.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f131469df79b55a8819c8786c67a43dee989af1f25a17eac87be38d4b716855
|
4
|
+
data.tar.gz: e4947533d8fcd65a9039ea3887a5feda1d4eaece77ca3ea9b48cd9027ec098f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cef92281ae526b0bc5e7390d267aafc7f7253afaf672a5168f743bfe58856e49d49075141f50a1841d69bdbec61d6bfc764b3baf50d7988da84c5761885d00a
|
7
|
+
data.tar.gz: 51484a2e4497f8279b6bfe7e2e1973befbb38e682de5451da947c5e253df90463f1e0e662b4c98df5626e66ebeaebe8532a8b4e34b0506ded2d0b7a377cc02ee
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require: rubocop-
|
1
|
+
require: rubocop-bridgetown
|
2
2
|
|
3
3
|
inherit_gem:
|
4
|
-
rubocop-
|
4
|
+
rubocop-bridgetown: .rubocop.yml
|
5
5
|
|
6
6
|
AllCops:
|
7
|
-
TargetRubyVersion: 2.
|
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
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 2.0.1 / 2021-06-04
|
4
|
+
|
5
|
+
* Fix bug where resources' relative URLs weren't included properly
|
6
|
+
|
7
|
+
## 2.0.0 / 2021-04-17
|
8
|
+
|
9
|
+
* New release with helper to support Ruby templates like ERB
|
10
|
+
|
11
|
+
## 1.1.3 / 2020-11-05
|
12
|
+
|
13
|
+
* Add `template_engine: liquid` to the feed XML so it plays well with Bridgetown 0.18+
|
14
|
+
|
15
|
+
## 1.1.2 / 2020-05-01
|
16
|
+
|
17
|
+
Update to require a minimum Ruby version of 2.5.
|
18
|
+
|
19
|
+
## 1.1.1 / 2020-04-19
|
20
|
+
|
21
|
+
Update to use `_data/site_metadata.yml` in line with the rest of the ecosystem.
|
22
|
+
|
23
|
+
## 1.0.0 / 2020-04-09
|
24
|
+
|
25
|
+
Use Bridgetown gem and rename to bridgetown-feed.
|
data/Gemfile
CHANGED
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
|
-
|
19
|
+
The plugin exposes a helper tag to expose the appropriate meta tags to support automated discovery of your feed.
|
20
20
|
|
21
|
-
|
21
|
+
Simply place `feed_meta` someplace in your layout's `<head>` section to output the necessary metadata.
|
22
22
|
|
23
|
-
|
23
|
+
```liquid
|
24
|
+
<!-- layout.liquid -->
|
25
|
+
{% feed_meta %}
|
26
|
+
```
|
24
27
|
|
25
|
-
|
28
|
+
```erb
|
29
|
+
<!-- layout.erb -->
|
30
|
+
<%= feed_meta %>
|
31
|
+
```
|
32
|
+
|
33
|
+
### Atom is nice and all, but what about JSON Feed?
|
34
|
+
|
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/
|
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:
|
@@ -194,6 +204,10 @@ feed:
|
|
194
204
|
The same flag can be used directly in post file. It will be disable `<content>` tag for selected post.
|
195
205
|
Settings in post file has higher priority than in config file.
|
196
206
|
|
207
|
+
## Testing
|
208
|
+
|
209
|
+
* Run `bundle exec rspec` to run the test suite
|
210
|
+
* Or run `script/cibuild` to validate with Rubocop and test with rspec together
|
197
211
|
|
198
212
|
## Contributing
|
199
213
|
|
data/bridgetown-feed.gemspec
CHANGED
@@ -15,14 +15,14 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.test_files = spec.files.grep(%r!^spec/!)
|
16
16
|
spec.require_paths = ["lib"]
|
17
17
|
|
18
|
-
spec.required_ruby_version = ">= 2.
|
18
|
+
spec.required_ruby_version = ">= 2.5.0"
|
19
19
|
|
20
|
-
spec.add_dependency "bridgetown", ">= 0.
|
20
|
+
spec.add_dependency "bridgetown", ">= 0.20", "< 2.0"
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler"
|
23
23
|
spec.add_development_dependency "nokogiri", "~> 1.6"
|
24
24
|
spec.add_development_dependency "rake", "~> 12.0"
|
25
25
|
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
-
spec.add_development_dependency "rubocop-
|
26
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
|
27
27
|
spec.add_development_dependency "typhoeus", ">= 0.7", "< 2.0"
|
28
28
|
end
|
data/lib/bridgetown-feed.rb
CHANGED
@@ -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
|
@@ -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
|
@@ -9,7 +9,6 @@
|
|
9
9
|
<updated>{{ site.time | date_to_xmlschema }}</updated>
|
10
10
|
<id>{{ page.url | absolute_url | xml_escape }}</id>
|
11
11
|
|
12
|
-
<!-- {{ site.metadata | jsonify }} -->
|
13
12
|
{% assign title = site.metadata.title | default: site.metadata.name %}
|
14
13
|
{% if page.collection != "posts" %}
|
15
14
|
{% assign collection = page.collection | capitalize %}
|
@@ -40,20 +39,25 @@
|
|
40
39
|
</author>
|
41
40
|
{% endif %}
|
42
41
|
|
43
|
-
{% assign
|
42
|
+
{% assign feed_collection = collections[page.collection] %}
|
43
|
+
{% if site.uses_resource %}
|
44
|
+
{% find posts where feed_collection.resources, draft != true %}
|
45
|
+
{% else %}
|
46
|
+
{% assign posts = feed_collection.docs | where_exp: "post", "post.draft != true" | sort: "date" | reverse %}
|
47
|
+
{% endif %}
|
44
48
|
{% if page.category %}
|
45
49
|
{% assign posts = posts | where: "category",page.category %}
|
46
50
|
{% endif %}
|
47
51
|
{% for post in posts limit: 10 %}
|
48
52
|
<entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
|
49
53
|
<title type="html">{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
|
50
|
-
<link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
|
54
|
+
<link href="{{ post.relative_url | default: post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
|
51
55
|
<published>{{ post.date | date_to_xmlschema }}</published>
|
52
56
|
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
|
53
57
|
<id>{{ post.id | absolute_url | xml_escape }}</id>
|
54
58
|
{% assign excerpt_only = post.feed.excerpt_only | default: site.feed.excerpt_only %}
|
55
59
|
{% unless excerpt_only %}
|
56
|
-
<content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
|
60
|
+
<content type="html" xml:base="{{ post.relative_url | default: post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
|
57
61
|
{% endunless %}
|
58
62
|
|
59
63
|
{% 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(:
|
13
|
+
path = feed_path(collection: name, category: category)
|
14
14
|
next if file_exists?(path)
|
15
15
|
|
16
|
-
@site.pages << make_page(path, :
|
16
|
+
@site.pages << make_page(path, collection: name, category: category)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -85,14 +85,15 @@ module BridgetownFeed
|
|
85
85
|
# Generates contents for a file
|
86
86
|
|
87
87
|
def make_page(file_path, collection: "posts", category: nil)
|
88
|
-
|
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"
|
92
|
-
"
|
93
|
-
"
|
94
|
-
"
|
95
|
-
"
|
91
|
+
"layout" => "none",
|
92
|
+
"template_engine" => "liquid",
|
93
|
+
"sitemap" => false,
|
94
|
+
"xsl" => file_exists?("feed.xslt.xml"),
|
95
|
+
"collection" => collection,
|
96
|
+
"category" => category
|
96
97
|
)
|
97
98
|
file.output
|
98
99
|
end
|
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:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bridgetown Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-04 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.
|
19
|
+
version: '0.20'
|
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.
|
29
|
+
version: '0.20'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.0'
|
@@ -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-
|
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.
|
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.
|
102
|
+
version: '0.2'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: typhoeus
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,17 +129,16 @@ files:
|
|
129
129
|
- ".gitignore"
|
130
130
|
- ".rspec"
|
131
131
|
- ".rubocop.yml"
|
132
|
+
- CHANGELOG.md
|
132
133
|
- Gemfile
|
133
|
-
- History.markdown
|
134
134
|
- LICENSE.txt
|
135
135
|
- README.md
|
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:
|
@@ -153,14 +152,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
152
|
requirements:
|
154
153
|
- - ">="
|
155
154
|
- !ruby/object:Gem::Version
|
156
|
-
version: 2.
|
155
|
+
version: 2.5.0
|
157
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
157
|
requirements:
|
159
158
|
- - ">="
|
160
159
|
- !ruby/object:Gem::Version
|
161
160
|
version: '0'
|
162
161
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
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
|
data/History.markdown
DELETED
@@ -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
|