Commit 331842fda432d0587defd48733ee6fafd7d3dbe9
1 parent
0012d341
Exists in
community_hub_submodule
prova de conceito do tweeter funcionando
Showing
9 changed files
with
47 additions
and
17 deletions
Show diff stats
lib/community_hub_plugin/hub.rb
1 | require File.dirname(__FILE__) + '/../../tweeter_stream/lib/twurl' | 1 | require File.dirname(__FILE__) + '/../../tweeter_stream/lib/twurl' |
2 | 2 | ||
3 | + | ||
3 | class CommunityHubPlugin::Hub < Folder | 4 | class CommunityHubPlugin::Hub < Folder |
4 | 5 | ||
5 | settings_items :hashtags_twitter, :type => :string, :default => "" | 6 | settings_items :hashtags_twitter, :type => :string, :default => "" |
6 | settings_items :promoted_users, :type => Array, :default => [] | 7 | settings_items :promoted_users, :type => Array, :default => [] |
7 | settings_items :pinned_posts, :type => Array, :default => [] | 8 | settings_items :pinned_posts, :type => Array, :default => [] |
8 | 9 | ||
9 | - def initialize(my_var) | ||
10 | - raise "ola".inspect | ||
11 | - end | 10 | + @@thread_started = false |
12 | 11 | ||
13 | def self.icon_name(article = nil) | 12 | def self.icon_name(article = nil) |
14 | 'community-hub' | 13 | 'community-hub' |
@@ -26,6 +25,27 @@ class CommunityHubPlugin::Hub < Folder | @@ -26,6 +25,27 @@ class CommunityHubPlugin::Hub < Folder | ||
26 | true | 25 | true |
27 | end | 26 | end |
28 | 27 | ||
28 | + def self.start_twitter_service(page) | ||
29 | + | ||
30 | + a = Thread.new { | ||
31 | + Twurl::Stream.run(page, 'nba', '/root/.twurlrc') | ||
32 | + } unless @@thread_started | ||
33 | + | ||
34 | + @@thread_started = true | ||
35 | + | ||
36 | +# raise page.inspect | ||
37 | + | ||
38 | +# comment = Comment.new | ||
39 | +# comment.source_id = page.id | ||
40 | +# comment.body = "Teste Evandro" | ||
41 | +# comment.author_id = "54" | ||
42 | +# comment.save! | ||
43 | + | ||
44 | + | ||
45 | +# raise "Pai #{parent.id}".inspect | ||
46 | + | ||
47 | + end | ||
48 | + | ||
29 | def view_page | 49 | def view_page |
30 | "content_viewer/hub.rhtml" | 50 | "content_viewer/hub.rhtml" |
31 | end | 51 | end |
lib/community_hub_plugin/hub_helper.rb
public/javascripts/community_hub.js
@@ -208,8 +208,8 @@ $(document).ready(function(){ | @@ -208,8 +208,8 @@ $(document).ready(function(){ | ||
208 | 208 | ||
209 | //checkUserLevel(); | 209 | //checkUserLevel(); |
210 | 210 | ||
211 | - //setInterval(checkNewLivePosts, 10000); //10 seconds interval | ||
212 | - setInterval(checkNewMediationPosts, 10000); //10 seconds interval | 211 | + setInterval(checkNewLivePosts, 10000); //10 seconds interval |
212 | + //setInterval(checkNewMediationPosts, 10000); //10 seconds interval | ||
213 | //setInterval(checkUserLevel, 10000); //10 seconds interval | 213 | //setInterval(checkUserLevel, 10000); //10 seconds interval |
214 | 214 | ||
215 | }); | 215 | }); |
tweeter_stream/lib/twurl/newjson.json
tweeter_stream/lib/twurl/request_controller.rb
@@ -18,9 +18,17 @@ module Twurl | @@ -18,9 +18,17 @@ module Twurl | ||
18 | #unless chunk.to_i.length = 0 | 18 | #unless chunk.to_i.length = 0 |
19 | begin | 19 | begin |
20 | parsed = JSON.parse(chunk) | 20 | parsed = JSON.parse(chunk) |
21 | - print "@#{parsed["user"]["name"]} said: #{parsed["text"]} \n" | 21 | +# print "@#{parsed["user"]["name"]} said: #{parsed["text"]} \n" |
22 | + comment = Comment.new | ||
23 | + comment.source_id = Stream.page.id | ||
24 | + comment.body = parsed["text"] | ||
25 | + comment.author_id = "54" | ||
26 | + comment.save! | ||
22 | rescue | 27 | rescue |
23 | - end | 28 | + end |
29 | + #raise comment.inspect | ||
30 | +# rescue | ||
31 | +# end | ||
24 | #end | 32 | #end |
25 | } | 33 | } |
26 | } | 34 | } |
tweeter_stream/lib/twurl/stream.rb
@@ -13,8 +13,9 @@ module Twurl | @@ -13,8 +13,9 @@ module Twurl | ||
13 | class << self | 13 | class << self |
14 | attr_accessor :output | 14 | attr_accessor :output |
15 | 15 | ||
16 | - def run(tags, config_file_path, proxy=nil) | 16 | + def run(page, tags, config_file_path, proxy=nil) |
17 | begin | 17 | begin |
18 | + @page = page # maybe should not be a class variable | ||
18 | @@file_path = config_file_path | 19 | @@file_path = config_file_path |
19 | Twurl.options = Options.new | 20 | Twurl.options = Options.new |
20 | Twurl.options.command = 'request' # Not necessary anymore | 21 | Twurl.options.command = 'request' # Not necessary anymore |
@@ -29,6 +30,7 @@ module Twurl | @@ -29,6 +30,7 @@ module Twurl | ||
29 | Twurl.options.path="/1.1/statuses/filter.json" | 30 | Twurl.options.path="/1.1/statuses/filter.json" |
30 | Twurl.options.host="stream.twitter.com" | 31 | Twurl.options.host="stream.twitter.com" |
31 | Twurl.options.read_timeout= 0 | 32 | Twurl.options.read_timeout= 0 |
33 | + | ||
32 | rescue NoPathFound => e | 34 | rescue NoPathFound => e |
33 | exit | 35 | exit |
34 | end | 36 | end |
@@ -39,6 +41,10 @@ module Twurl | @@ -39,6 +41,10 @@ module Twurl | ||
39 | @@file_path | 41 | @@file_path |
40 | end | 42 | end |
41 | 43 | ||
44 | + def page | ||
45 | + @page | ||
46 | + end | ||
47 | + | ||
42 | def dispatch(options) | 48 | def dispatch(options) |
43 | client = OAuthClient.load_from_options(options) | 49 | client = OAuthClient.load_from_options(options) |
44 | controller = RequestController | 50 | controller = RequestController |
tweeter_stream/nbproject/private/private.xml
views/content_viewer/hub.rhtml