-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Atom (RSS) feed about latest project changes (pull #351)
This adds support for an Atom (RSS) feed about the latest project changes. Note: This adds some spurious warnings during test from feed_test.rb. Signed-off-by: Dan Kohn <dan@dankohn.com> * Working * Add width and height * Law of Demeter * Fix autodiscovery link * feed tests * Added index Signed-off-by: Dan Kohn <dan@dankohn.com> * Better fix for intermittent Capybara error Signed-off-by: Dan Kohn <dan@dankohn.com>
- Loading branch information
1 parent
5c67ed2
commit 9638581
Showing
13 changed files
with
158 additions
and
28 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
atom_feed do |feed| | ||
feed.title('CII Best Practices BadgeApp Updated Projects') | ||
feed.updated(@projects[0].updated_at) unless @projects.empty? | ||
|
||
@projects.each do |project| | ||
feed.entry(project) do |entry| | ||
entry.title project.name.presence || '(Name Unknown)' | ||
status = "<p><b>#{project.badge_status.titleize}: " \ | ||
"#{project.badge_percentage}%</b></p>" | ||
url = project.homepage_url.presence || project.repo_url | ||
link = "<p><a href='#{url}'>#{url}</a></p>" | ||
description = markdown((project.description || '') | ||
.truncate(160, separator: ' ')) | ||
content = status + link + description | ||
entry.content(type: 'html') { entry.cdata! content } | ||
entry.author { |author| author.name(project.user_name) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class AddIndexUpdatedAt < ActiveRecord::Migration | ||
def change | ||
add_index :projects, :updated_at | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom"> | ||
<id>tag:www.example.com,2005:/feed</id> | ||
<link rel="alternate" type="text/html" href="http://www.example.com"/> | ||
<link rel="self" type="application/atom+xml" href="http://www.example.com/feed"/> | ||
<title>CII Best Practices BadgeApp Updated Projects</title> | ||
<updated>2015-03-01T12:00:00Z</updated> | ||
<entry> | ||
<id>tag:www.example.com,2005:Project/980190962</id> | ||
<published>2015-03-01T12:00:00Z</published> | ||
<updated>2015-03-01T12:00:00Z</updated> | ||
<link rel="alternate" type="text/html" href="http://www.example.com/projects/980190962"/> | ||
<title>Pathfinder OS</title> | ||
<content type="html"> | ||
<![CDATA[<p><b>In Progress: 0%</b></p><p><a href='https://www.nasa.gov'>https://www.nasa.gov</a></p><p>Operating system for Pathfinder rover</p> | ||
]]> | ||
</content> | ||
<author> | ||
<name>Test</name> | ||
</author> | ||
</entry> | ||
<entry> | ||
<id>tag:www.example.com,2005:Project/298486374</id> | ||
<published>2015-03-01T12:00:00Z</published> | ||
<updated>2015-03-01T12:00:00Z</updated> | ||
<link rel="alternate" type="text/html" href="http://www.example.com/projects/298486374"/> | ||
<title>Mars Ascent Vehicle (MAV)</title> | ||
<content type="html"> | ||
<![CDATA[<p><b>In Progress: 0%</b></p><p><a href='https://www.nasa.gov'>https://www.nasa.gov</a></p><p>Operating system for Pathfinder rover</p> | ||
]]> | ||
</content> | ||
<author> | ||
<name>Melissa Lewis</name> | ||
</author> | ||
</entry> | ||
<entry> | ||
<id>tag:www.example.com,2005:Project/832656895</id> | ||
<published>2015-03-01T12:00:00Z</published> | ||
<updated>2015-03-01T12:00:00Z</updated> | ||
<link rel="alternate" type="text/html" href="http://www.example.com/projects/832656895"/> | ||
<title>Unjustified perfect project</title> | ||
<content type="html"> | ||
<![CDATA[<p><b>Failing: 88%</b></p><p><a href='https://www.example.org'>https://www.example.org</a></p><p>The perfect project</p> | ||
]]> | ||
</content> | ||
<author> | ||
<name>Test</name> | ||
</author> | ||
</entry> | ||
<entry> | ||
<id>tag:www.example.com,2005:Project/600182345</id> | ||
<published>2015-03-01T12:00:00Z</published> | ||
<updated>2015-03-01T12:00:00Z</updated> | ||
<link rel="alternate" type="text/html" href="http://www.example.com/projects/600182345"/> | ||
<title>Justified perfect project</title> | ||
<content type="html"> | ||
<![CDATA[<p><b>Passing: 100%</b></p><p><a href='https://www.example.org'>https://www.example.org</a></p><p>The perfect project</p> | ||
]]> | ||
</content> | ||
<author> | ||
<name>Test</name> | ||
</author> | ||
</entry> | ||
</feed> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'test_helper' | ||
load 'Rakefile' | ||
|
||
class FeedTest < ActionDispatch::IntegrationTest | ||
def setup | ||
# Normalize time in order to match fixture file | ||
travel_to Time.zone.parse('2015-03-01T12:00:00') do | ||
silence_stream(STDOUT) do | ||
# anything written to STDOUT here will be silenced | ||
Rake::Task['db:schema:load'].reenable | ||
Rake::Task['db:schema:load'].invoke | ||
end | ||
Rake::Task['db:fixtures:load'].reenable | ||
Rake::Task['db:fixtures:load'].invoke | ||
end | ||
end | ||
|
||
test 'feed matches fixture file' do | ||
get feed_path | ||
assert_equal contents('feed.atom'), response.body | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Remove unused methods (stringrefinements::symbolrefinements::project#recently_updated)