Skip to content

Commit 1e59d4e

Browse files
committed
Merge branch 'master' into update-last-fetched-on-prune
Conflicts: app/repositories/feed_repository.rb spec/repositories/feed_repository_spec.rb
2 parents 700bb4c + a7d10b7 commit 1e59d4e

File tree

28 files changed

+286
-155
lines changed

28 files changed

+286
-155
lines changed

app/controllers/stories_controller.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ class Stringer < Sinatra::Base
88
erb :index
99
end
1010

11+
get "/feed/:feed_id" do
12+
@feed = FeedRepository.fetch(params[:feed_id])
13+
14+
@stories = StoryRepository.feed(params[:feed_id])
15+
@unread_stories = @stories.find_all {|story| !story.is_read }
16+
17+
erb :feed
18+
end
19+
1120
get "/archive" do
1221
@read_stories = StoryRepository.read(params[:page])
1322

app/models/feed.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ def status_bubble
1818
status
1919
end
2020

21+
def unread_stories
22+
stories.where('is_read = ?', false)
23+
end
24+
25+
def has_unread_stories
26+
unread_stories.any?
27+
end
28+
2129
def as_fever_json
2230
{
2331
id: self.id,

app/public/css/styles.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,10 @@ li.feed .feed-title a {
317317
text-decoration: none;
318318
}
319319

320+
li.feed .feed-unread {
321+
font-weight: bold;
322+
}
323+
320324
li.feed .feed-title a:hover {
321325
color: #7F8281;
322326
}
@@ -576,3 +580,9 @@ li.blank {
576580
text-decoration: none;
577581
margin: 0 7px;
578582
}
583+
584+
#feed-title {
585+
margin-bottom: 10px;
586+
font-size: 28px;
587+
text-align: center;
588+
}
5.2 KB
Loading

app/public/img/favicon.png

-2.43 KB
Loading

app/public/js/app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ var StoryView = Backbone.View.extend({
100100
},
101101

102102
render: function() {
103-
this.$el.html(this.template(this.model.toJSON()));
103+
var jsonModel = this.model.toJSON();
104+
this.$el.html(this.template(jsonModel));
105+
if (jsonModel.is_read) {
106+
this.$el.addClass('read');
107+
}
104108
return this;
105109
},
106110

app/repositories/feed_repository.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
class FeedRepository
44
MIN_YEAR = 1970
55

6+
def self.fetch(id)
7+
Feed.find(id)
8+
end
9+
610
def self.fetch_by_ids(ids)
711
Feed.where(id: ids)
812
end
@@ -34,3 +38,4 @@ def self.valid_timestamp?(new_timestamp, current_timestamp)
3438
(current_timestamp.nil? || new_timestamp > current_timestamp)
3539
end
3640
end
41+

app/repositories/story_repository.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ def self.unread_since_id(since_id)
4343
unread.where('id > ?', since_id)
4444
end
4545

46+
def self.feed(feed_id)
47+
Story.where('feed_id = ?', feed_id).order("published desc").includes(:feed)
48+
end
49+
4650
def self.read(page = 1)
4751
Story.where(is_read: true).includes(:feed)
4852
.order("published desc").page(page).per_page(20)

app/views/feed.erb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<% content_for :title do %>
2+
<% unless @unread_stories.empty? %>
3+
<%= "(#{@unread_stories.count})" %>
4+
<% end %>
5+
<% end %>
6+
7+
<div id="action-bar">
8+
<%= render_partial :action_bar, { stories: @unread_stories } %>
9+
</div>
10+
11+
<div id="feed-title">
12+
<%= @feed.name %>
13+
</div>
14+
15+
<%= render_js :stories, { stories: @stories } %>
16+
17+
<div id="stories">
18+
<ul id="story-list">
19+
</ul>
20+
</div>

app/views/layout.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
99
<meta name="viewport" content="width=device-width, initial-scale=1" />
1010
<link rel="shortcut icon" href="/img/favicon.png">
11+
<link rel="apple-touch-icon-precomposed" href="/img/apple-touch-icon-precomposed.png">
1112
<link href="//fonts.googleapis.com/css?family=Lato:300,400,700,900,400italic" rel="stylesheet" type="text/css">
1213

1314
<%= yield_content :head %>

0 commit comments

Comments
 (0)