Skip to content

Commit 5954714

Browse files
author
Matt Swanson
committed
update title with unread count. robustify feed fetching a bit.
1 parent 52fd5bc commit 5954714

10 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎Gemfile‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ gem "bcrypt-ruby"
1212
gem "feedzirra", github: "swanson/feedzirra"
1313
gem "loofah"
1414
gem "nokogiri"
15-
1615
gem "feedbag", github: "dwillis/feedbag"
1716

1817
group :production do

‎Gemfile.lock‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ GIT
1919

2020
GIT
2121
remote: git://github.com/swanson/feedzirra.git
22-
revision: 48e45278f77be8352482eb00bee727cb1ca17864
22+
revision: 3d4767670b24b4de617ab9bcbd1ac9786cb30183
2323
specs:
2424
feedzirra (0.2.0.rc2)
2525
curb (~> 0.8.1)
@@ -52,7 +52,7 @@ GEM
5252
delayed_job_active_record (0.4.4)
5353
activerecord (>= 2.1.0, < 4)
5454
delayed_job (~> 3.0)
55-
diff-lcs (1.2.3)
55+
diff-lcs (1.2.4)
5656
eventmachine (1.0.3)
5757
faker (1.1.2)
5858
i18n (~> 0.5)
@@ -76,7 +76,7 @@ GEM
7676
racksh (1.0.0)
7777
rack (>= 1.0)
7878
rack-test (>= 0.5)
79-
raindrops (0.10.0)
79+
raindrops (0.11.0)
8080
rake (10.0.4)
8181
rspec (2.13.0)
8282
rspec-core (~> 2.13.0)

‎app/commands/feeds/find_new_stories.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def new_stories
1010
@raw_feed.last_modified < @last_fetched
1111

1212
stories = []
13-
@raw_feed.stories.each do |story|
13+
@raw_feed.entries.each do |story|
1414
break if @latest_url && story.url == @latest_url
1515

1616
stories << story unless story.published &&

‎app/public/js/app.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ $(document).ready(function() {
3535
$(".story-lead", this).fadeOut(1000);
3636
$(".story-body-container", this).stop().show();
3737

38-
//$.post("/mark_as_read", { story_id: $this.data("id") })
39-
// .fail(function() { alert("something broke!"); });
38+
$.post("/mark_as_read", { story_id: $this.data("id") })
39+
.fail(function() { alert("something broke!"); });
4040
});
4141

4242
$("#mark-all").click(function(e) {

‎app/repositories/story_repository.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def self.add(entry, feed)
88
author: entry.author,
99
body: StoryRepository.extract_content(entry),
1010
is_read: false,
11-
published: entry.published)
11+
published: entry.published || Time.now)
1212
end
1313

1414
def self.fetch(id)

‎app/tasks/fetch_feed.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ def fetch
2222
FeedRepository.update_last_fetched(@feed, raw_feed.last_modified)
2323
rescue Exception => ex
2424
puts "Something went wrong when parsing #{@feed.url}"
25-
puts ex, ex.backtrace
25+
puts raw_feed.inspect
26+
puts ex
27+
puts
2628
end
2729
end
2830

‎app/views/index.erb‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
<% content_for :title do %>
2+
<% unless @unread_stories.empty? %>
3+
<%= "(#{@unread_stories.count})" %>
4+
<% end %>
5+
<% end %>
6+
17
<div id="action-bar">
28
<div class="row-fluid">
39
<div class="pull-left">

‎app/views/layout.erb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>stringer | your rss buddy</title>
4+
<title>
5+
<%= yield_content :title %>
6+
stringer | your rss buddy
7+
</title>
58
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
69

710
<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">

‎spec/commands/find_new_stories_spec.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
it "should return stories that are new based on published date" do
1818
new_story = stub(published: Time.new(2013, 1, 5))
1919
old_story = stub(published: Time.new(2013, 1, 1))
20-
feed = stub(last_modified: Time.new(2013, 1, 5), stories: [new_story, old_story])
20+
feed = stub(last_modified: Time.new(2013, 1, 5), entries: [new_story, old_story])
2121

2222
result = FindNewStories.new(feed, Time.new(2013, 1, 3)).new_stories
2323
result.should eq [new_story]
@@ -28,7 +28,7 @@
2828
it "should check all stories and compare published time" do
2929
new_story = stub(published: Time.new(2013, 1, 5))
3030
old_story = stub(published: Time.new(2013, 1, 1))
31-
feed = stub(last_modified: nil, stories: [new_story, old_story])
31+
feed = stub(last_modified: nil, entries: [new_story, old_story])
3232

3333
result = FindNewStories.new(feed, Time.new(2013, 1, 3)).new_stories
3434
result.should eq [new_story]
@@ -39,7 +39,7 @@
3939
it "should scan until matching the last url" do
4040
new_story = stub(published: nil, url: "http://blog.com/new-story")
4141
old_story = stub(published: nil, url: "http://blog.com/old-story")
42-
feed = stub(last_modified: nil, stories: [new_story, old_story])
42+
feed = stub(last_modified: nil, entries: [new_story, old_story])
4343

4444
result = FindNewStories.new(feed, Time.new(2013, 1, 3), "http://blog.com/old-story").new_stories
4545
result.should eq [new_story]

‎spec/controllers/stories_controller_spec.rb‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
app_require "controllers/stories_controller"
44

55
describe "StoriesController" do
6-
before { }
7-
86
let(:story_one) { StoryFactory.build }
97
let(:story_two) { StoryFactory.build }
108
let(:stories) { [story_one, story_two] }

0 commit comments

Comments
 (0)