bunto-feed 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 30a97230cea8d61d0b6cef250d9a531c15c6dcce
4
+ data.tar.gz: 67c650b54599fa72890adc73d30e8e9a14cf523c
5
+ SHA512:
6
+ metadata.gz: c62c0f95f391d3a41d9f285fc902b11e951c973e74ef11bc317bc786ebc9c820dec8bf9e275a391cd8a8773219663d646ec09b492c919b99a0da8b27bda714f1
7
+ data.tar.gz: 1e135aeaf990fc848a5c23ae90f76e7b564a45817f90fca9abf5429a395055c9421fa12d405ec7468842566844d29a6320b5dab1c76c5ba5466079f097d44a2c
@@ -0,0 +1,20 @@
1
+ /vendor
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ *.gem
17
+ Gemfile.lock
18
+ spec/dest
19
+ .bundle
20
+ spec/fixtures/.bunto-metadata
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
4
+ - 2.1
5
+ - 2.0
6
+ matrix:
7
+ include:
8
+ - # Ruby 1.9
9
+ rvm: 1.9
10
+ env: BUNTO_VERSION=1.0
11
+ env:
12
+ global:
13
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
14
+ matrix:
15
+ - BUNTO_VERSION=2.0
16
+ - BUNTO_VERSION=1.0
17
+ cache: bundler
18
+ sudo: false
19
+ before_script: bundle update
20
+ script: ./script/cibuild
21
+ notifications:
22
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ if ENV["BUNTO_VERSION"]
5
+ gem "bunto", "~> #{ENV["BUNTO_VERSION"]}"
6
+ end
@@ -0,0 +1,3 @@
1
+ ## 1.0.0 / 2015-02-08
2
+
3
+ * Birthday!
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016-present Ben Balter
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ # Bunto Feed plugin
2
+
3
+ A Bunto plugin to generate an Atom (RSS-like) feed of your Bunto posts
4
+
5
+ [![Build Status](https://travis-ci.org/bunto/bunto-feed.svg)](https://travis-ci.org/bunto/bunto-feed) [![Gem Version](https://badge.fury.io/rb/bunto-feed.svg)](http://badge.fury.io/rb/bunto-feed)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your site's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'bunto-feed'
13
+ ```
14
+
15
+ And then add this line to your site's `_config.yml`:
16
+
17
+ ```yml
18
+ gems:
19
+ - bunto-feed
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ The plugin will automatically generate an Atom feed at `/feed.xml`.
25
+
26
+ ### Optional configuration options
27
+
28
+ The plugin will automatically use any of the following configuration variables, if they are present in your site's `_config.yml` file.
29
+
30
+ * `name` - The title of the site, e.g., "My awesome site"
31
+ * `description` - A longer description of what your site is about, e.g., "Where I blog about Bunto and other awesome things"
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` - Your name, e.g., "Dr. Bunto." This can be a string (with the author's name), or an object with the following properties:
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
37
+
38
+ ### Already have a feed path?
39
+
40
+ Do you already have an existing feed someplace other than `/feed.xml`, but are on a host like GitHub Pages that doesn't support machine-friendly redirects? If you simply swap out `bunto-feed` for your existing template, your existing subscribers won't continue to get updates. Instead, you can specify a non-default path via your site's config.
41
+
42
+ ```yml
43
+ feed:
44
+ path: atom.xml
45
+ ```
46
+
47
+ To note, you shouldn't have to do this unless you already have a feed you're using, and you can't or wish not to redirect existing subscribers.
48
+
49
+ ### Optional front matter
50
+
51
+ The plugin will use the following post metadata, automatically generated by Bunto, which you can override via a post's YAML front matter:
52
+
53
+ * `date`
54
+ * `title`
55
+ * `excerpt`
56
+ * `id`
57
+ * `category`
58
+ * `tags`
59
+
60
+ Additionally, the plugin will use the following values, if present in a post's YAML front matter:
61
+
62
+ * `author` - The author of the post, e.g., "Dr. Bunto". 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.
63
+
64
+ ### Meta tags
65
+
66
+ 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.
67
+
68
+ ## Why Atom, and not RSS?
69
+
70
+ Great question. In short, Atom is a better format. Think of it like RSS 3.0.
71
+
72
+ ## Contributing
73
+
74
+ 1. Fork it (https://github.com/bunto/bunto-feed/fork)
75
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
76
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
77
+ 4. Push to the branch (`git push origin my-new-feature`)
78
+ 5. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "bunto-feed"
5
+ spec.version = "1.0.0"
6
+ spec.authors = ["Ben Balter", "Suriyaa Kudo"]
7
+ spec.email = ["ben.balter@github.com", "SuriyaaKudoIsc@users.noreply.github.com"]
8
+ spec.summary = "A Bunto plugin to generate an Atom feed of your Bunto posts"
9
+ spec.homepage = "https://github.com/bunto/bunto-feed"
10
+ spec.license = "MIT"
11
+
12
+ spec.files = `git ls-files -z`.split("\x0")
13
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
+ spec.require_paths = ["lib"]
16
+
17
+ spec.add_development_dependency "bunto"
18
+ spec.add_development_dependency "bundler", "~> 1.6"
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency "rspec", "~> 3.0"
21
+ spec.add_development_dependency "typhoeus", "~> 0.7"
22
+ spec.add_development_dependency "nokogiri", "~> 1.6"
23
+ end
@@ -0,0 +1,4 @@
1
+ require "bunto/feed_meta_tag"
2
+ require "bunto/bunto-feed"
3
+ require "bunto/page_without_a_file"
4
+ require "bunto/strip_whitespace"
@@ -0,0 +1,51 @@
1
+ require "fileutils"
2
+
3
+ module Bunto
4
+ class BuntoFeed < Bunto::Generator
5
+ safe true
6
+ priority :lowest
7
+
8
+ # Main plugin action, called by Bunto-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.exists? @site.in_source_dir(path)
46
+ else
47
+ File.exists? Bunto.sanitized_path(@site.source, path)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,33 @@
1
+ module Bunto
2
+ class FeedMetaTag < Liquid::Tag
3
+
4
+ def render(context)
5
+ @context = context
6
+ "<link type=\"application/atom+xml\" rel=\"alternate\" href=\"#{url}/#{path}\" title=\"#{config["name"]}\" />"
7
+ end
8
+
9
+ private
10
+
11
+ def config
12
+ @context.registers[:site].config
13
+ end
14
+
15
+ def path
16
+ if config["feed"] && config["feed"]["path"]
17
+ config["feed"]["path"]
18
+ else
19
+ "feed.xml"
20
+ end
21
+ end
22
+
23
+ def url
24
+ if config["url"]
25
+ URI.join(config["url"], config["baseurl"])
26
+ elsif config["github"] && config["github"]["url"]
27
+ config["github"]["url"]
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ Liquid::Template.register_tag("feed_meta", Bunto::FeedMetaTag)
@@ -0,0 +1,7 @@
1
+ module Bunto
2
+ class PageWithoutAFile < Page
3
+ def read_yaml(*)
4
+ @data ||= {}
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ # The `strip` filter was added to Liquid in version 3
2
+ # Bunto did not require Liquid 3 until Bunto 1.0.0
3
+ # This shim is needed for compatibility with Bunto 1.x
4
+
5
+ module Bunto
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(Bunto::StripWhitespace)
15
+ end
@@ -0,0 +1,83 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ {% if site.url %}
3
+ {% assign url_base = site.url | append: site.baseurl %}
4
+ {% else %}
5
+ {% assign url_base = site.github.url %}
6
+ {% endif %}
7
+ <feed xmlns="http://www.w3.org/2005/Atom">
8
+ <generator uri="http://bunto.isc" version="{{ bunto.version }}">Bunto</generator>
9
+ <link href="{{ page.url | prepend: url_base }}" rel="self" type="application/atom+xml" />
10
+ <link href="{{ url_base }}/" rel="alternate" type="text/html" />
11
+ <updated>{{ site.time | date_to_xmlschema }}</updated>
12
+ <id>{{ url_base | xml_escape }}/</id>
13
+
14
+ {% if site.title %}
15
+ <title>{{ site.title | xml_escape }}</title>
16
+ {% elsif site.name %}
17
+ <title>{{ site.name | xml_escape }}</title>
18
+ {% endif %}
19
+
20
+ {% if site.description %}
21
+ <subtitle>{{ site.description | xml_escape }}</subtitle>
22
+ {% endif %}
23
+
24
+ {% if site.author %}
25
+ <author>
26
+ {% if site.author.name %}
27
+ <name>{{ site.author.name | xml_escape }}</name>
28
+ {% else %}
29
+ <name>{{ site.author | xml_escape }}</name>
30
+ {% endif %}
31
+ {% if site.author.email %}
32
+ <email>{{ site.author.email | xml_escape }}</email>
33
+ {% endif %}
34
+ {% if site.author.uri %}
35
+ <uri>{{ site.author.uri | xml_escape }}</uri>
36
+ {% endif %}
37
+ </author>
38
+ {% endif %}
39
+
40
+ {% for post in site.posts limit: 10 %}
41
+ <entry>
42
+ <title>{{ post.title | markdownify | strip_html | replace: '\n', ' ' | strip | xml_escape }}</title>
43
+ <link href="{{ post.url | prepend: url_base }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
44
+ <published>{{ post.date | date_to_xmlschema }}</published>
45
+ {% if post.last_modified_at %}
46
+ <updated>{{ post.last_modified_at | date_to_xmlschema }}</updated>
47
+ {% else %}
48
+ <updated>{{ post.date | date_to_xmlschema }}</updated>
49
+ {% endif %}
50
+
51
+ <id>{{ post.id | prepend: url_base | xml_escape }}</id>
52
+ <content type="html" xml:base="{{ post.url | prepend: url_base | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
53
+
54
+ {% if post.author %}
55
+ <author>
56
+ {% if post.author.name %}
57
+ <name>{{ post.author.name | xml_escape }}</name>
58
+ {% else %}
59
+ <name>{{ post.author | xml_escape }}</name>
60
+ {% endif %}
61
+ {% if post.author.email %}
62
+ <email>{{ post.author.email | xml_escape }}</email>
63
+ {% endif %}
64
+ {% if post.author.uri %}
65
+ <uri>{{ post.author.uri | xml_escape }}</uri>
66
+ {% endif %}
67
+ </author>
68
+ {% endif %}
69
+
70
+ {% if post.category %}
71
+ <category term="{{ post.category | xml_escape }}" />
72
+ {% endif %}
73
+
74
+ {% for tag in post.tags %}
75
+ <category term="{{ tag | xml_escape }}" />
76
+ {% endfor %}
77
+
78
+ {% if post.excerpt and post.excerpt != empty %}
79
+ <summary>{{ post.excerpt | strip_html | replace: '\n', ' ' | strip | xml_escape }}</summary>
80
+ {% endif %}
81
+ </entry>
82
+ {% endfor %}
83
+ </feed>
@@ -0,0 +1,3 @@
1
+ #! /bin/bash
2
+
3
+ bundle install
@@ -0,0 +1,6 @@
1
+ #! /bin/bash
2
+
3
+ set -e
4
+
5
+ bundle exec rspec
6
+ bundle exec rake build
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+ # Tag and push a release.
3
+
4
+ set -e
5
+
6
+ script/cibuild
7
+ bundle exec rake release
@@ -0,0 +1,220 @@
1
+ require 'spec_helper'
2
+
3
+ describe(Bunto::BuntoFeed) do
4
+ let(:overrides) { Hash.new }
5
+ let(:config) do
6
+ Bunto.configuration(Bunto::Utils.deep_merge_hashes({
7
+ "full_rebuild" => true,
8
+ "source" => source_dir,
9
+ "destination" => dest_dir,
10
+ "url" => "http://example.org",
11
+ "name" => "My awesome site",
12
+ "author" => {
13
+ "name" => "Dr. Bunto"
14
+ },
15
+ "collections" => {
16
+ "my_collection" => { "output" => true },
17
+ "other_things" => { "output" => false }
18
+ }
19
+ }, overrides))
20
+ end
21
+ let(:site) { Bunto::Site.new(config) }
22
+ let(:contents) { File.read(dest_dir("feed.xml")) }
23
+ before(:each) do
24
+ site.process
25
+ end
26
+
27
+ it "has no layout" do
28
+ expect(contents).not_to match(/\ATHIS IS MY LAYOUT/)
29
+ end
30
+
31
+ it "creates a feed.xml file" do
32
+ expect(Pathname.new(dest_dir("feed.xml"))).to exist
33
+ end
34
+
35
+ it "doesn't have multiple new lines or trailing whitespace" do
36
+ expect(contents).to_not match /\s+\n/
37
+ expect(contents).to_not match /\n{2,}/
38
+ end
39
+
40
+ it "puts all the posts in the feed.xml file" do
41
+ expect(contents).to match /http:\/\/example\.org\/2014\/03\/04\/march-the-fourth\.html/
42
+ expect(contents).to match /http:\/\/example\.org\/2014\/03\/02\/march-the-second\.html/
43
+ expect(contents).to match /http:\/\/example\.org\/2013\/12\/12\/dec-the-second\.html/
44
+ end
45
+
46
+ it "does not include assets or any static files that aren't .html" do
47
+ expect(contents).not_to match /http:\/\/example\.org\/images\/hubot\.png/
48
+ expect(contents).not_to match /http:\/\/example\.org\/feeds\/atom\.xml/
49
+ end
50
+
51
+ it "preserves linebreaks in preformatted text in posts" do
52
+ expect(contents).to match /Line 1\nLine 2\nLine 3/
53
+ end
54
+
55
+ it "supports post author name as an object" do
56
+ expect(contents).to match /<author>\s*<name>Ben<\/name>\s*<email>ben@example.com<\/email>\s*<uri>http:\/\/ben.balter.com<\/uri>\s*<\/author>/
57
+ end
58
+
59
+ it "supports post author name as a string" do
60
+ expect(contents).to match /<author>\s*<name>Pat<\/name>\s*<\/author>/
61
+ end
62
+
63
+ it "does not output author tag no author is provided" do
64
+ expect(contents).not_to match /<author>\s*<name><\/name>\s*<\/author>/
65
+ end
66
+
67
+ it "converts markdown posts to HTML" do
68
+ expect(contents).to match /&lt;p&gt;March the second!&lt;\/p&gt;/
69
+ end
70
+
71
+ it "converts uses last_modified_at where available" do
72
+ expect(contents).to match /<updated>2015-05-12T13:27:59\+00:00<\/updated>/
73
+ end
74
+
75
+ it "replaces newlines in posts to spaces" do
76
+ expect(contents).to match /<title>The plugin will properly strip newlines.<\/title>/
77
+ end
78
+
79
+ it "renders Liquid inside posts" do
80
+ expect(contents).to match /Liquid is rendered\./
81
+ expect(contents).not_to match /Liquid is not rendered\./
82
+ end
83
+
84
+ context "parsing" do
85
+ let(:feed) { RSS::Parser.parse(contents) }
86
+
87
+ it "outputs an RSS feed" do
88
+ expect(feed.feed_type).to eql("atom")
89
+ expect(feed.feed_version).to eql("1.0")
90
+ expect(feed.encoding).to eql("UTF-8")
91
+ end
92
+
93
+ it "outputs the link" do
94
+ expect(feed.link.href).to eql("http://example.org/feed.xml")
95
+ end
96
+
97
+ it "outputs the generator" do
98
+ expect(feed.generator.content).to eql("Bunto")
99
+ expect(feed.generator.version).to eql(Bunto::VERSION)
100
+ end
101
+
102
+ it "includes the items" do
103
+ expect(feed.items.count).to eql(8)
104
+ end
105
+
106
+ it "includes item contents" do
107
+ post = feed.items.last
108
+ expect(post.title.content).to eql("Dec The Second")
109
+ expect(post.link.href).to eql("http://example.org/2013/12/12/dec-the-second.html")
110
+ expect(post.published.content).to eql(Time.parse("2013-12-12"))
111
+ end
112
+
113
+ it "includes the item's excerpt" do
114
+ post = feed.items.last
115
+ expect(post.summary.content).to eql("Foo")
116
+ end
117
+
118
+ it "doesn't include the item's excerpt if blank" do
119
+ post = feed.items.first
120
+ expect(post.summary).to be_nil
121
+ end
122
+
123
+ context "with site.title set" do
124
+ let(:site_title) { "My Site Title" }
125
+ let(:overrides) { {"title" => site_title} }
126
+
127
+ it "uses site.title for the title" do
128
+ expect(feed.title.content).to eql(site_title)
129
+ end
130
+ end
131
+
132
+ context "with site.name set" do
133
+ let(:site_name) { "My Site Name" }
134
+ let(:overrides) { {"name" => site_name} }
135
+
136
+ it "uses site.name for the title" do
137
+ expect(feed.title.content).to eql(site_name)
138
+ end
139
+ end
140
+
141
+ context "with site.name and site.title set" do
142
+ let(:site_title) { "My Site Title" }
143
+ let(:site_name) { "My Site Name" }
144
+ let(:overrides) { {"title" => site_title, "name" => site_name} }
145
+
146
+ it "uses site.title for the title, dropping site.name" do
147
+ expect(feed.title.content).to eql(site_title)
148
+ end
149
+ end
150
+ end
151
+
152
+ context "validation" do
153
+ it "validates" do
154
+ # See https://validator.w3.org/docs/api.html
155
+ url = "https://validator.w3.org/feed/check.cgi?output=soap12"
156
+ response = Typhoeus.post(url, body: { rawdata: contents }, accept_encoding: "gzip")
157
+ pending "Something went wrong with the W3 validator" unless response.success?
158
+ result = Nokogiri::XML(response.body)
159
+ result.remove_namespaces!
160
+
161
+ result.css("warning").each do |warning|
162
+ # Quiet a warning that results from us passing the feed as a string
163
+ next if warning.css("text").text =~ /Self reference doesn't match document location/
164
+ warn "Validation warning: #{warning.css("text").text} on line #{warning.css("line").text} column #{warning.css("column").text}"
165
+ end
166
+
167
+ errors = result.css("error").map do |error|
168
+ "Validation error: #{error.css("text").text} on line #{error.css("line").text} column #{error.css("column").text}"
169
+ end
170
+
171
+ expect(result.css("validity").text).to eql("true"), errors.join("\n")
172
+ end
173
+ end
174
+
175
+ context "with a baseurl" do
176
+ let(:overrides) do
177
+ { "baseurl" => "/bass" }
178
+ end
179
+
180
+ it "correctly adds the baseurl to the posts" do
181
+ expect(contents).to match /http:\/\/example\.org\/bass\/2014\/03\/04\/march-the-fourth\.html/
182
+ expect(contents).to match /http:\/\/example\.org\/bass\/2014\/03\/02\/march-the-second\.html/
183
+ expect(contents).to match /http:\/\/example\.org\/bass\/2013\/12\/12\/dec-the-second\.html/
184
+ end
185
+
186
+ it "renders the feed meta" do
187
+ index = File.read(dest_dir("index.html"))
188
+ expected = '<link type="application/atom+xml" rel="alternate" href="http://example.org/bass/feed.xml" title="My awesome site" />'
189
+ expect(index).to include(expected)
190
+ end
191
+ end
192
+
193
+ context "feed meta" do
194
+ it "renders the feed meta" do
195
+ index = File.read(dest_dir("index.html"))
196
+ expected = '<link type="application/atom+xml" rel="alternate" href="http://example.org/feed.xml" title="My awesome site" />'
197
+ expect(index).to include(expected)
198
+ end
199
+ end
200
+
201
+ context "changing the feed path" do
202
+ let(:overrides) do
203
+ {
204
+ "feed" => {
205
+ "path" => "atom.xml"
206
+ }
207
+ }
208
+ end
209
+
210
+ it "should write to atom.xml" do
211
+ expect(Pathname.new(dest_dir("atom.xml"))).to exist
212
+ end
213
+
214
+ it "renders the feed meta with custom feed path" do
215
+ index = File.read(dest_dir("index.html"))
216
+ expected = '<link type="application/atom+xml" rel="alternate" href="http://example.org/atom.xml" title="My awesome site" />'
217
+ expect(index).to include(expected)
218
+ end
219
+ end
220
+ end
@@ -0,0 +1,9 @@
1
+ timezone: UTC
2
+
3
+ defaults:
4
+ -
5
+ scope:
6
+ path: ""
7
+ type: page
8
+ values:
9
+ layout: some_default
@@ -0,0 +1,11 @@
1
+ ---
2
+ ---
3
+ <html>
4
+ <head>
5
+ {% feed_meta %}
6
+ </head>
7
+ <body>
8
+ THIS IS MY LAYOUT
9
+ {{ content }}
10
+ </body>
11
+ </html>
@@ -0,0 +1,5 @@
1
+ ---
2
+ excerpt: "Foo"
3
+ ---
4
+
5
+ # December the twelfth, actually.
@@ -0,0 +1,4 @@
1
+ ---
2
+ ---
3
+
4
+ March the second!
@@ -0,0 +1,6 @@
1
+ ---
2
+ tags:
3
+ - '"/><VADER>'
4
+ ---
5
+
6
+ March the fourth!
@@ -0,0 +1,5 @@
1
+ ---
2
+ last_modified_at: 2015-05-12T13:27:59+00:00
3
+ ---
4
+
5
+ Please don't modify this file. It's modified time is important.
@@ -0,0 +1,6 @@
1
+ ---
2
+ title:
3
+ The plugin
4
+ will properly
5
+ strip newlines.
6
+ ---
@@ -0,0 +1,7 @@
1
+ ---
2
+ ---
3
+
4
+ {% capture liquidstring %}
5
+ Liquid is not rendered.
6
+ {% endcapture %}
7
+ {{ liquidstring | replace:'not ','' }}
@@ -0,0 +1,7 @@
1
+ ---
2
+ author: Pat
3
+ ---
4
+
5
+ <pre>Line 1
6
+ Line 2
7
+ Line 3</pre>
@@ -0,0 +1,9 @@
1
+ ---
2
+ excerpt: ""
3
+ author:
4
+ name: Ben
5
+ uri: "http://ben.balter.com"
6
+ email: ben@example.com
7
+ ---
8
+
9
+ # December the twelfth, actually.
@@ -0,0 +1,4 @@
1
+ ---
2
+ ---
3
+
4
+ HERE IS MY SITE I AM SO EXCITED TO BE USING GITHUB PAGES
@@ -0,0 +1,24 @@
1
+ require 'bunto'
2
+ require 'typhoeus'
3
+ require 'nokogiri'
4
+ require 'rss'
5
+ require File.expand_path('../lib/bunto-feed', File.dirname(__FILE__))
6
+
7
+ Bunto.logger.log_level = :error
8
+
9
+ RSpec.configure do |config|
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+ config.order = 'random'
13
+
14
+ SOURCE_DIR = File.expand_path("../fixtures", __FILE__)
15
+ DEST_DIR = File.expand_path("../dest", __FILE__)
16
+
17
+ def source_dir(*files)
18
+ File.join(SOURCE_DIR, *files)
19
+ end
20
+
21
+ def dest_dir(*files)
22
+ File.join(DEST_DIR, *files)
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bunto-feed
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Balter
8
+ - Suriyaa Kudo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-02-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bunto
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.6'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.6'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: typhoeus
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.7'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.7'
84
+ - !ruby/object:Gem::Dependency
85
+ name: nokogiri
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1.6'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.6'
98
+ description:
99
+ email:
100
+ - ben.balter@github.com
101
+ - SuriyaaKudoIsc@users.noreply.github.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - ".rspec"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - History.markdown
111
+ - LICENSE.txt
112
+ - README.md
113
+ - Rakefile
114
+ - bunto-feed.gemspec
115
+ - lib/bunto-feed.rb
116
+ - lib/bunto/bunto-feed.rb
117
+ - lib/bunto/feed_meta_tag.rb
118
+ - lib/bunto/page_without_a_file.rb
119
+ - lib/bunto/strip_whitespace.rb
120
+ - lib/feed.xml
121
+ - script/bootstrap
122
+ - script/cibuild
123
+ - script/release
124
+ - spec/bunto-feed_spec.rb
125
+ - spec/fixtures/_config.yml
126
+ - spec/fixtures/_layouts/some_default.html
127
+ - spec/fixtures/_posts/2013-12-12-dec-the-second.md
128
+ - spec/fixtures/_posts/2014-03-02-march-the-second.md
129
+ - spec/fixtures/_posts/2014-03-04-march-the-fourth.md
130
+ - spec/fixtures/_posts/2015-01-18-bunto-last-modified-at.md
131
+ - spec/fixtures/_posts/2015-02-12-strip-newlines.md
132
+ - spec/fixtures/_posts/2015-05-12-liquid.md
133
+ - spec/fixtures/_posts/2015-05-12-pre.html
134
+ - spec/fixtures/_posts/2015-05-18-author-detail.md
135
+ - spec/fixtures/index.html
136
+ - spec/spec_helper.rb
137
+ homepage: https://github.com/bunto/bunto-feed
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.2.2
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: A Bunto plugin to generate an Atom feed of your Bunto posts
161
+ test_files:
162
+ - spec/bunto-feed_spec.rb
163
+ - spec/fixtures/_config.yml
164
+ - spec/fixtures/_layouts/some_default.html
165
+ - spec/fixtures/_posts/2013-12-12-dec-the-second.md
166
+ - spec/fixtures/_posts/2014-03-02-march-the-second.md
167
+ - spec/fixtures/_posts/2014-03-04-march-the-fourth.md
168
+ - spec/fixtures/_posts/2015-01-18-bunto-last-modified-at.md
169
+ - spec/fixtures/_posts/2015-02-12-strip-newlines.md
170
+ - spec/fixtures/_posts/2015-05-12-liquid.md
171
+ - spec/fixtures/_posts/2015-05-12-pre.html
172
+ - spec/fixtures/_posts/2015-05-18-author-detail.md
173
+ - spec/fixtures/index.html
174
+ - spec/spec_helper.rb