Implement a read flag, mark unread items in the ui
+ unread count
This commit is contained in:
parent
c24799fed2
commit
a4c8be72a7
14 changed files with 43 additions and 18 deletions
|
@ -2,10 +2,11 @@
|
||||||
|
|
||||||
* Handle relative URLs in Atom feed.
|
* Handle relative URLs in Atom feed.
|
||||||
(http://www.rfc1149.net/blog/2010/12/27/feed-and-relative-links/)
|
(http://www.rfc1149.net/blog/2010/12/27/feed-and-relative-links/)
|
||||||
* Update a single feed manually and mark the new feeds in the db
|
|
||||||
* Rake task to update all feeds at once
|
* Rake task to update all feeds at once
|
||||||
* Detect an RSS link in a given website URL
|
* Detect an RSS link in a given website URL
|
||||||
|
* Add an optional manual title to the imported feed
|
||||||
|
* Collapse the opened item again
|
||||||
|
* Make the UI consistend (read/unread items)
|
||||||
|
|
||||||
=== Low priority
|
=== Low priority
|
||||||
|
|
||||||
|
@ -16,4 +17,3 @@
|
||||||
|
|
||||||
=== Broken feeds with feedzirra
|
=== Broken feeds with feedzirra
|
||||||
|
|
||||||
* http://blog.fefe.de/rss.xml
|
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
@import "config";
|
@import "config";
|
||||||
|
|
||||||
|
a.unread {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
li.item {
|
li.item {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
@import "config";
|
@import "config";
|
||||||
|
|
||||||
aside {
|
aside {
|
||||||
width: 250px;
|
width: 350px;
|
||||||
float: left;
|
float: left;
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
|
|
|
@ -10,6 +10,12 @@ class FeedsController < ApplicationController
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def refresh
|
||||||
|
@feed = Feed.find(params[:id])
|
||||||
|
@feed.fetch!
|
||||||
|
redirect_to :action => :show, :notice => "Add the feed"
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@feed = Feed.import(params[:feed][:url])
|
@feed = Feed.import(params[:feed][:url])
|
||||||
redirect_to :action => :index, :notice => "Add the feed"
|
redirect_to :action => :index, :notice => "Add the feed"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
class ItemsController < ApplicationController
|
class ItemsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@item = Item.find(params[:id])
|
@item = Item.find(params[:id])
|
||||||
|
@item.read
|
||||||
render :layout => false
|
render :layout => false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
require "pp"
|
|
||||||
|
|
||||||
class Feed < ActiveRecord::Base
|
class Feed < ActiveRecord::Base
|
||||||
has_many :items, :dependent => :destroy
|
has_many :items, :dependent => :destroy
|
||||||
has_many :errors, :dependent => :destroy
|
has_many :errors, :dependent => :destroy
|
||||||
|
|
|
@ -6,6 +6,9 @@ class Item < ActiveRecord::Base
|
||||||
|
|
||||||
default_scope order("published_at DESC")
|
default_scope order("published_at DESC")
|
||||||
scope :recent, limit(10)
|
scope :recent, limit(10)
|
||||||
|
scope :unread, where(:read_at => nil)
|
||||||
|
|
||||||
|
#attr_accessible :read_at
|
||||||
|
|
||||||
def self.create_from_feed_entry!(feed_entry)
|
def self.create_from_feed_entry!(feed_entry)
|
||||||
feed_entry.sanitize!
|
feed_entry.sanitize!
|
||||||
|
@ -19,6 +22,10 @@ class Item < ActiveRecord::Base
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def read
|
||||||
|
update_attribute(:read_at, Time.now)
|
||||||
|
end
|
||||||
|
|
||||||
def <=>(other)
|
def <=>(other)
|
||||||
self.published_at <=> other.published_at
|
self.published_at <=> other.published_at
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,14 @@
|
||||||
<ul id="feed_list">
|
<ul id="feed_list">
|
||||||
<% @feeds.each do |feed| %>
|
<% @feeds.each do |feed| %>
|
||||||
|
<% unread_count = feed.items.unread.size %>
|
||||||
<li>
|
<li>
|
||||||
(<%= link_to "del", feed_path(feed), :remote => true, :method => :delete, :class => "delete_feed button", :confirm => "Delete this feed?" %>,
|
(<%= link_to "del", feed_path(feed), :remote => true, :method => :delete, :class => "delete_feed button", :confirm => "Delete this feed?" %>,
|
||||||
<%= link_to "err", errors_feed_path(feed), :remote => true, :class => "button", :update => "feed_content" %>)
|
<%= link_to "err", errors_feed_path(feed), :remote => true, :class => "button", :update => "feed_content" %>,
|
||||||
<%= link_to feed.title, feed_path(feed), :remote => true, :update => "feed_content" %>
|
<%= link_to "up", refresh_feed_path(feed), :remote => true, :class => "button", :method => :post, :update => "feed_content" %>)
|
||||||
|
|
||||||
|
<% r = unread_count.zero? ? "read" : "unread" %>
|
||||||
|
<%= link_to feed.title, feed_path(feed), :remote => true, :update => "feed_content", :class => r %>
|
||||||
|
[<%= unread_count %>]
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
<% @feed.items.each do |item| %>
|
<% @feed.items.each do |item| %>
|
||||||
<li class="item">
|
<li class="item">
|
||||||
<%= link_to raw(item.title), item_path(item), :remote => true %>
|
<% r = item.read_at.nil? ? "unread" : "read" %>
|
||||||
|
<%= link_to raw(item.title), item_path(item), :remote => true, :class => r %>
|
||||||
<em class="date_published"><%= time_ago_in_words(item.published_at) %></em> <em class="author">by <%= item.author %></em>
|
<em class="date_published"><%= time_ago_in_words(item.published_at) %></em> <em class="author">by <%= item.author %></em>
|
||||||
<article></article>
|
<article></article>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -17,6 +17,7 @@ FeedFu::Application.routes.draw do
|
||||||
get :import
|
get :import
|
||||||
end
|
end
|
||||||
member do
|
member do
|
||||||
|
post :refresh
|
||||||
get :errors
|
get :errors
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
class AddErrorField < ActiveRecord::Migration
|
class AddErrorField < ActiveRecord::Migration
|
||||||
def up
|
def change
|
||||||
add_column :feeds, :has_errors, :boolean, :default => false
|
add_column :feeds, :has_errors, :boolean, :default => false
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
|
||||||
remove_column :feeds, :has_errors
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
5
db/migrate/20130110204625_add_read_flag_to_items.rb
Normal file
5
db/migrate/20130110204625_add_read_flag_to_items.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddReadFlagToItems < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :items, :read_at, :timestamp, :default => nil
|
||||||
|
end
|
||||||
|
end
|
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20130110200633) do
|
ActiveRecord::Schema.define(:version => 20130110204625) do
|
||||||
|
|
||||||
create_table "errors", :force => true do |t|
|
create_table "errors", :force => true do |t|
|
||||||
t.integer "feed_id"
|
t.integer "feed_id"
|
||||||
|
@ -38,6 +38,7 @@ ActiveRecord::Schema.define(:version => 20130110200633) do
|
||||||
t.integer "feed_id"
|
t.integer "feed_id"
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
|
t.datetime "read_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Reference in a new issue