README.markdown in activity_feed-2.0.0 vs README.markdown in activity_feed-2.1.0
- old
+ new
@@ -1,8 +1,8 @@
# ActivityFeed
-Activity feeds backed by Redis. Activity feeds may also be referred to as timelines or
+Activity feeds backed by Redis. Activity feeds may also be referred to as timelines or
news feeds.
## Compatibility
The gem has been built and tested under Ruby 1.8.7 and Ruby 1.9.3.
@@ -13,11 +13,11 @@
or:
`gem 'activity_feed'`
-Make sure your redis server is running! Redis configuration is outside the scope of this README, but
+Make sure your redis server is running! Redis configuration is outside the scope of this README, but
check out the [Redis documentation](http://redis.io/documentation).
## Configuration
### Basic configuration options
@@ -52,11 +52,11 @@
require 'mongoid'
module ActivityFeed
module Mongoid
class Item
- include ::Mongoid::Document
+ include ::Mongoid::Document
include ::Mongoid::Timestamps
field :user_id, type: String
validates_presence_of :user_id
@@ -68,11 +68,11 @@
field :icon, type: String
field :sticky, type: Boolean
index :user_id
- after_save :update_item_in_activity_feed
+ after_save :update_item_in_activity_feed
private
def update_item_in_activity_feed
ActivityFeed.update_item(self.user_id, self.id, self.updated_at.to_i)
@@ -93,12 +93,12 @@
## Usage
### Developing an Activity Feed for an Individual
Below is a complete example using Mongoid as our persistent storage for activity feed items.
-The example uses callbacks to update and remove items from the activity feed. As this example
-uses the `updated_at` time of the item, updated items will "bubble up" to the top of the
+The example uses callbacks to update and remove items from the activity feed. As this example
+uses the `updated_at` time of the item, updated items will "bubble up" to the top of the
activity feed.
```ruby
# Configure Mongoid
require 'mongoid'
@@ -109,11 +109,11 @@
# Create a class for activity feed items
module ActivityFeed
module Mongoid
class Item
- include ::Mongoid::Document
+ include ::Mongoid::Document
include ::Mongoid::Timestamps
field :user_id, type: String
validates_presence_of :user_id
@@ -155,38 +155,38 @@
configuration.item_loader = Proc.new { |id| ActivityFeed::Mongoid::Item.find(id) }
end
# Create a couple of activity feed items
activity_item_1 = ActivityFeed::Mongoid::Item.create(
- :user_id => 'david',
+ :user_id => 'david',
:nickname => 'David Czarnecki',
:type => 'some_activity',
:title => 'Great activity',
:text => 'This is text for the activity feed item',
:url => 'http://url.com'
)
activity_item_2 = ActivityFeed::Mongoid::Item.create(
- :user_id => 'david',
+ :user_id => 'david',
:nickname => 'David Czarnecki',
:type => 'some_activity',
:title => 'Another great activity',
:text => 'This is some other text for the activity feed item',
:url => 'http://url.com'
)
# Pull up the activity feed
feed = ActivityFeed.feed('david', 1)
- => [#<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000004, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:08:22 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Another great activity", text: "This is some other text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>, #<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000003, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:08:22 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Great activity", text: "This is text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>]
+ => [#<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000004, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:08:22 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Another great activity", text: "This is some other text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>, #<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000003, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:08:22 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Great activity", text: "This is text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>]
# Update an actitivity feed item
activity_item_1.text = 'Updated some text for the activity feed item'
activity_item_1.save
# Pull up the activity feed item and notice that the item you updated has "bubbled up" to the top of the feed
feed = ActivityFeed.feed('david', 1)
- => [#<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000003, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:11:27 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Great activity", text: "Updated some text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>, #<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000004, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:08:22 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Another great activity", text: "This is some other text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>]
+ => [#<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000003, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:11:27 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Great activity", text: "Updated some text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>, #<ActivityFeed::Mongoid::Item _id: 4fe0ce26421aa91fc2000004, _type: nil, created_at: 2012-06-19 19:08:22 UTC, updated_at: 2012-06-19 19:08:22 UTC, user_id: "david", nickname: "David Czarnecki", type: "some_activity", title: "Another great activity", text: "This is some other text for the activity feed item", url: "http://url.com", icon: nil, sticky: nil>]
```
### Developing an Aggregate Activity Feed for an Individual
```ruby
@@ -199,11 +199,11 @@
# Create a class for activity feed items
module ActivityFeed
module Mongoid
class Item
- include ::Mongoid::Document
+ include ::Mongoid::Document
include ::Mongoid::Timestamps
field :user_id, type: String
validates_presence_of :user_id
@@ -249,11 +249,11 @@
another_item = ActivityFeed::Mongoid::Item.create(
:user_id => 'unknown',
:text => "This is from unknown's activity feed"
)
- sleep(1)
+ sleep(1)
ActivityFeed.aggregate_item('david', another_item.id, another_item.updated_at.to_i)
end
# Pull up the aggregate activity feed
@@ -270,12 +270,12 @@
#<ActivityFeed::Mongoid::Item _id: 4fe2891b8bb895b795000001, _type: nil, created_at: 2012-06-21 02:38:19 UTC, updated_at: 2012-06-21 02:38:19 UTC, user_id: "david", text: "This is from david's activity feed">]
```
## ActivityFeed Caveats
-`ActivityFeed.remove_item` can ONLY remove items from a single user's activity feed. If you allow activity feed
-items to be deleted from a user's activity feed, you will need to propagate that delete out to all the other
+`ActivityFeed.remove_item` can ONLY remove items from a single user's activity feed. If you allow activity feed
+items to be deleted from a user's activity feed, you will need to propagate that delete out to all the other
feeds in which that activity feed item may have been aggregated.
## ActivityFeed method summary
```ruby
@@ -286,9 +286,10 @@
ActivityFeed.remove_item(user_id, item_id)
# Feed-related
ActivityFeed.feed(user_id, page, aggregate = ActivityFeed.aggregate)
+ActivityFeed.full_feed(user_id, aggregate = ActivityFeed.aggregate)
ActivityFeed.feed_between_timestamps(user_id, starting_timestamp, ending_timestamp, aggregate = ActivityFeed.aggregate)
ActivityFeed.total_pages_in_feed(user_id, aggregate = ActivityFeed.aggregate, page_size = ActivityFeed.page_size)
ActivityFeed.total_items_in_feed(user_id, aggregate = ActivityFeed.aggregate)
ActivityFeed.trim_feed(user_id, starting_timestamp, ending_timestamp, aggregate = ActivityFeed.aggregate)
ActivityFeed.remove_feeds(user_id)
\ No newline at end of file