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.
|
||||
(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
|
||||
* 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
|
||||
|
||||
|
@ -16,4 +17,3 @@
|
|||
|
||||
=== Broken feeds with feedzirra
|
||||
|
||||
* http://blog.fefe.de/rss.xml
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
@import "config";
|
||||
|
||||
a.unread {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
li.item {
|
||||
overflow: auto;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
@import "config";
|
||||
|
||||
aside {
|
||||
width: 250px;
|
||||
width: 350px;
|
||||
float: left;
|
||||
|
||||
ul {
|
||||
|
|
|
@ -10,6 +10,12 @@ class FeedsController < ApplicationController
|
|||
render :layout => false
|
||||
end
|
||||
|
||||
def refresh
|
||||
@feed = Feed.find(params[:id])
|
||||
@feed.fetch!
|
||||
redirect_to :action => :show, :notice => "Add the feed"
|
||||
end
|
||||
|
||||
def create
|
||||
@feed = Feed.import(params[:feed][:url])
|
||||
redirect_to :action => :index, :notice => "Add the feed"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
class ItemsController < ApplicationController
|
||||
def show
|
||||
@item = Item.find(params[:id])
|
||||
@item.read
|
||||
render :layout => false
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require "pp"
|
||||
|
||||
class Feed < ActiveRecord::Base
|
||||
has_many :items, :dependent => :destroy
|
||||
has_many :errors, :dependent => :destroy
|
||||
|
|
|
@ -6,6 +6,9 @@ class Item < ActiveRecord::Base
|
|||
|
||||
default_scope order("published_at DESC")
|
||||
scope :recent, limit(10)
|
||||
scope :unread, where(:read_at => nil)
|
||||
|
||||
#attr_accessible :read_at
|
||||
|
||||
def self.create_from_feed_entry!(feed_entry)
|
||||
feed_entry.sanitize!
|
||||
|
@ -19,6 +22,10 @@ class Item < ActiveRecord::Base
|
|||
)
|
||||
end
|
||||
|
||||
def read
|
||||
update_attribute(:read_at, Time.now)
|
||||
end
|
||||
|
||||
def <=>(other)
|
||||
self.published_at <=> other.published_at
|
||||
end
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
<ul id="feed_list">
|
||||
<% @feeds.each do |feed| %>
|
||||
<% unread_count = feed.items.unread.size %>
|
||||
<li>
|
||||
(<%= 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 feed.title, feed_path(feed), :remote => true, :update => "feed_content" %>
|
||||
(<%= 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 "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>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
<ul>
|
||||
<% @feed.items.each do |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>
|
||||
<article></article>
|
||||
</li>
|
||||
|
|
|
@ -17,6 +17,7 @@ FeedFu::Application.routes.draw do
|
|||
get :import
|
||||
end
|
||||
member do
|
||||
post :refresh
|
||||
get :errors
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
class AddErrorField < ActiveRecord::Migration
|
||||
def up
|
||||
def change
|
||||
add_column :feeds, :has_errors, :boolean, :default => false
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :feeds, :has_errors
|
||||
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.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20130110200633) do
|
||||
ActiveRecord::Schema.define(:version => 20130110204625) do
|
||||
|
||||
create_table "errors", :force => true do |t|
|
||||
t.integer "feed_id"
|
||||
|
@ -38,6 +38,7 @@ ActiveRecord::Schema.define(:version => 20130110200633) do
|
|||
t.integer "feed_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.datetime "read_at"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Reference in a new issue