streamit 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +10 -0
- data/TODO +35 -0
- data/app/controllers/streamit/streams_controller.rb +26 -0
- data/app/views/streamit/streams/fetch.html.erb +3 -0
- data/config/routes.rb +5 -0
- data/lib/streamit/engine.rb +4 -3
- data/test/dummy/config/routes.rb +0 -4
- metadata +12 -7
data/Gemfile
ADDED
data/TODO
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
TODO:
|
2
|
+
- use background job like tool to process creating of streams
|
3
|
+
- customizable views
|
4
|
+
- cleanup old streams
|
5
|
+
- add more detailed documentation
|
6
|
+
|
7
|
+
class Streamit::Stream < ActiveRecord::Base
|
8
|
+
belongs_to :actor, :polymorphic => true
|
9
|
+
belongs_to :subject, :polymorphic => true
|
10
|
+
belongs_to :receiver, :polymorphic => true
|
11
|
+
end
|
12
|
+
|
13
|
+
# "he9lin started watching auction ipad 001 a minute ago"
|
14
|
+
#
|
15
|
+
# en:
|
16
|
+
# streamit:
|
17
|
+
# watching:
|
18
|
+
# create: "started watching"
|
19
|
+
|
20
|
+
class Watching < ActiveRecord::Base
|
21
|
+
belongs_to :watcher, :class_name => "User", :foreign_key => "user_id"
|
22
|
+
belongs_to :watched_item, :class_name => "Item", :foreign_key => "item_id"
|
23
|
+
|
24
|
+
stream :create, :actor => :watcher,
|
25
|
+
:receiver => :watched_item
|
26
|
+
end
|
27
|
+
|
28
|
+
# "he9lin just edited profile image just now"
|
29
|
+
#
|
30
|
+
# stream:
|
31
|
+
# stream_type: 'user.update.image_url'
|
32
|
+
#
|
33
|
+
class User < ActiveRecord::Base
|
34
|
+
stream :update, :attributes => :image_url
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class Streamit::StreamsController < ApplicationController
|
2
|
+
delegate :store, :to => Streamit
|
3
|
+
|
4
|
+
before_filter :process_params, :only => :fetch
|
5
|
+
|
6
|
+
def fetch
|
7
|
+
respond_to do |format|
|
8
|
+
format.html
|
9
|
+
format.js { render :text => render_streams_to_string }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def process_params
|
16
|
+
@streams = [:ago, :after, :limit].inject(store.scoped) do |scp, sym|
|
17
|
+
scp = scp.send(sym, params[sym]) if params[sym]
|
18
|
+
scp
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def render_streams_to_string
|
23
|
+
render_to_string(:partial => "streamit/stream", :collection => @streams)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/config/routes.rb
ADDED
data/lib/streamit/engine.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Streamit
|
2
|
-
class Engine < Rails::Engine
|
2
|
+
class Engine < ::Rails::Engine
|
3
3
|
config.streamit = ActiveSupport::OrderedOptions.new
|
4
4
|
|
5
5
|
initializer "streamit.active_record" do
|
@@ -13,5 +13,6 @@ module Streamit
|
|
13
13
|
Streamit.set_store(&app.config.streamit.set_store)
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
|
-
end
|
16
|
+
|
17
|
+
end # Engine
|
18
|
+
end # Streamit
|
data/test/dummy/config/routes.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Lin He
|
@@ -27,17 +27,22 @@ extensions: []
|
|
27
27
|
extra_rdoc_files: []
|
28
28
|
|
29
29
|
files:
|
30
|
+
- Gemfile
|
31
|
+
- README.rdoc
|
32
|
+
- MIT-LICENSE
|
33
|
+
- Rakefile
|
34
|
+
- TODO
|
35
|
+
- app/controllers/streamit/streams_controller.rb
|
36
|
+
- app/views/streamit/streams/fetch.html.erb
|
37
|
+
- config/routes.rb
|
38
|
+
- lib/streamit.rb
|
30
39
|
- lib/generators/streamit_generator.rb
|
31
40
|
- lib/generators/templates/_stream.html.erb
|
32
41
|
- lib/streamit/dsl.rb
|
33
42
|
- lib/streamit/engine.rb
|
43
|
+
- lib/streamit/store.rb
|
34
44
|
- lib/streamit/locales/en.yml
|
35
45
|
- lib/streamit/orm/active_record.rb
|
36
|
-
- lib/streamit/store.rb
|
37
|
-
- lib/streamit.rb
|
38
|
-
- MIT-LICENSE
|
39
|
-
- Rakefile
|
40
|
-
- README.rdoc
|
41
46
|
- test/dummy/app/controllers/application_controller.rb
|
42
47
|
- test/dummy/app/controllers/users_controller.rb
|
43
48
|
- test/dummy/app/models/stream.rb
|