stream_rails 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -10
- data/lib/stream_rails/activity.rb +10 -1
- data/lib/stream_rails/enrich.rb +1 -1
- data/lib/stream_rails/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d3432a8955f14a1c5bc68728636624f4e32feb7
|
4
|
+
data.tar.gz: 07c4acdc2ece3b24277052b51547a07095f335fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a03aafb8e658cc99d5808dc1ca1d56e2012ae647eefd26bd126b4b63a6ca74f3d026ea253bb56027a888e89e54192c74a4ddd4227c3981ce8e00999baa8a998f
|
7
|
+
data.tar.gz: 791fd74c07194ecbf7fdff17419531b1b71cdadc841a6e3df751c84bf34d2c0568c3b9ae7a8e6bac6d9b47b8ad3af60e7fe81ea1ce94e05c0e677f1e8ca68701
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ Stream Rails
|
|
6
6
|
|
7
7
|
This package helps you create activity streams & newsfeeds with Ruby on Rails and [GetStream.io](https://getstream.io).
|
8
8
|
|
9
|
-
###Activity Streams & Newsfeeds
|
9
|
+
### Activity Streams & Newsfeeds
|
10
10
|
|
11
11
|
![](https://dvqg2dogggmn6.cloudfront.net/images/mood-home.png)
|
12
12
|
|
@@ -52,11 +52,15 @@ You can check out our example app built using this library on Github [https://gi
|
|
52
52
|
|
53
53
|
You can install ```stream_rails``` as you would any other gem:
|
54
54
|
|
55
|
-
```
|
55
|
+
```
|
56
|
+
gem install stream_rails
|
57
|
+
```
|
56
58
|
|
57
59
|
or in your Gemfile:
|
58
60
|
|
59
|
-
```
|
61
|
+
```
|
62
|
+
gem 'stream_rails'
|
63
|
+
```
|
60
64
|
|
61
65
|
|
62
66
|
### Setup
|
@@ -76,6 +80,9 @@ StreamRails.configure do |config|
|
|
76
80
|
# If you use custom feed names, e.g.: timeline_flat, timeline_aggregated,
|
77
81
|
# use this, otherwise omit:
|
78
82
|
config.news_feeds = { flat: "timeline_flat", aggregated: "timeline_aggregated" }
|
83
|
+
# Point to the notifications feed group providing the name, omit if you don't
|
84
|
+
# have a notifications feed
|
85
|
+
config.notification_feed = "notification"
|
79
86
|
end
|
80
87
|
```
|
81
88
|
|
@@ -265,7 +272,7 @@ class Pin < ActiveRecord::Base
|
|
265
272
|
|
266
273
|
def activity_notify
|
267
274
|
if self.is_retweet
|
268
|
-
[feed_manager.get_notification_feed(self.parent.user_id)]
|
275
|
+
[StreamRails.feed_manager.get_notification_feed(self.parent.user_id)]
|
269
276
|
end
|
270
277
|
end
|
271
278
|
|
@@ -290,7 +297,7 @@ class Follow < ActiveRecord::Base
|
|
290
297
|
as_activity
|
291
298
|
|
292
299
|
def activity_notify
|
293
|
-
[feed_manager.get_notification_feed(self.target_id)]
|
300
|
+
[StreamRails.feed_manager.get_notification_feed(self.target_id)]
|
294
301
|
end
|
295
302
|
|
296
303
|
def activity_object
|
@@ -301,12 +308,17 @@ end
|
|
301
308
|
```
|
302
309
|
|
303
310
|
####Follow a feed
|
304
|
-
|
311
|
+
|
312
|
+
In order to populate newsfeeds, you need to notify the system about follow relationships.
|
313
|
+
|
314
|
+
The current user's flat and aggregated feeds will follow the `target_user`'s user feed, with the following code:
|
305
315
|
|
306
316
|
```
|
307
317
|
StreamRails.feed_manager.follow_user(user_id, target_id)
|
308
318
|
```
|
309
319
|
|
320
|
+
![](http://i.imgur.com/bLywmPj.png)
|
321
|
+
|
310
322
|
### Showing the newsfeed
|
311
323
|
|
312
324
|
####Activity enrichment
|
@@ -347,25 +359,30 @@ The ```render_activity``` view helper will render the activity by picking the pa
|
|
347
359
|
The helper will automatically send ```activity``` to the local scope of the partial; additional parameters can be send as well as use different layouts, and prefix the name
|
348
360
|
|
349
361
|
|
350
|
-
|
362
|
+
e.g. renders the activity partial using the ```small_activity``` layout:
|
351
363
|
|
352
364
|
```
|
353
365
|
<%= render_activity activity, :layout => "small_activity" %>
|
354
366
|
```
|
355
367
|
|
356
|
-
|
357
|
-
eg. prefixes the name of the template with "notification_"
|
368
|
+
e.g. prefixes the name of the template with "notification_":
|
358
369
|
|
359
370
|
```
|
360
371
|
<%= render_activity activity, :prefix => "notification_" %>
|
361
372
|
```
|
362
373
|
|
363
|
-
|
374
|
+
e.g. adds the extra_var to the partial scope:
|
364
375
|
|
365
376
|
```
|
366
377
|
<%= render_activity activity, :locals => {:extra_var => 42} %>
|
367
378
|
```
|
368
379
|
|
380
|
+
e.g. renders the activity partial using the `notifications` partial root, which will render the partial with the path `notifications/#{ACTIVITY_VERB}`
|
381
|
+
|
382
|
+
```
|
383
|
+
<%= render_activity activity, :partial_root => "notifications" %>
|
384
|
+
```
|
385
|
+
|
369
386
|
####Pagination
|
370
387
|
|
371
388
|
For simple pagination you can use the [stream-ruby API](https://github.com/getstream/stream-ruby),
|
@@ -47,7 +47,11 @@ module StreamRails
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def activity_object
|
50
|
-
fail NotImplementedError,
|
50
|
+
fail NotImplementedError, "Activity models must define `#activity_object` - missing on `#{self.class}`"
|
51
|
+
end
|
52
|
+
|
53
|
+
def activity_target
|
54
|
+
nil
|
51
55
|
end
|
52
56
|
|
53
57
|
def activity_verb
|
@@ -62,6 +66,10 @@ module StreamRails
|
|
62
66
|
StreamRails.create_reference(self)
|
63
67
|
end
|
64
68
|
|
69
|
+
def activity_target_id
|
70
|
+
StreamRails.create_reference(activity_target) if activity_target
|
71
|
+
end
|
72
|
+
|
65
73
|
def activity_notify
|
66
74
|
end
|
67
75
|
|
@@ -83,6 +91,7 @@ module StreamRails
|
|
83
91
|
verb: activity_verb,
|
84
92
|
object: activity_object_id,
|
85
93
|
foreign_id: activity_foreign_id,
|
94
|
+
target: activity_target_id,
|
86
95
|
time: activity_time
|
87
96
|
}
|
88
97
|
activity[:to] = activity_notify.map(&:id) unless activity_notify.nil?
|
data/lib/stream_rails/enrich.rb
CHANGED
data/lib/stream_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stream_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tommaso Barbugli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: '2.4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: '2.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activerecord
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,7 +151,7 @@ dependencies:
|
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '4.29'
|
153
153
|
description:
|
154
|
-
email:
|
154
|
+
email: tommaso@getstream.io
|
155
155
|
executables: []
|
156
156
|
extensions: []
|
157
157
|
extra_rdoc_files:
|
@@ -171,7 +171,7 @@ files:
|
|
171
171
|
- lib/stream_rails/sync_policies.rb
|
172
172
|
- lib/stream_rails/utils/view_helpers.rb
|
173
173
|
- lib/stream_rails/version.rb
|
174
|
-
homepage: http://github.com/
|
174
|
+
homepage: http://github.com/GetStream/stream-rails
|
175
175
|
licenses:
|
176
176
|
- Apache-2.0
|
177
177
|
metadata: {}
|
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
191
191
|
version: '0'
|
192
192
|
requirements: []
|
193
193
|
rubyforge_project:
|
194
|
-
rubygems_version: 2.
|
194
|
+
rubygems_version: 2.5.1
|
195
195
|
signing_key:
|
196
196
|
specification_version: 4
|
197
197
|
summary: A gem that provides a client interface for getstream.io
|