Commit 46e2d04ede01823eb67bebb1091b6ed9ee1ede62
Exists in
master
Merge branch 'AI3074-community_dashboard' of gitlab.com:participa/noosfero into …
…AI3074-community_dashboard
Showing
4 changed files
with
11 additions
and
3 deletions
Show diff stats
lib/community_hub_plugin/hub.rb
... | ... | @@ -6,6 +6,7 @@ class CommunityHubPlugin::Hub < Folder |
6 | 6 | settings_items :proxy_url, :type => :string, :default => 'http://161.148.1.167:3128' # Remember to use add the port, in case needed. |
7 | 7 | settings_items :twitter_enabled, :type => :boolean, :default => false |
8 | 8 | settings_items :hashtags_twitter, :type => :string, :default => "participa.br,participabr,arenanetmundial,netmundial" |
9 | + settings_items :twitter_token_file, :type => :string, :default => "twurlrc_mariajoseopinto" | |
9 | 10 | settings_items :facebook_enabled, :type => :boolean, :default => false |
10 | 11 | settings_items :facebook_page_id, :type => :string, :default => "participabr" |
11 | 12 | settings_items :facebook_pooling_time, :type => :integer, :default => 5 # Time in seconds | ... | ... |
lib/community_hub_plugin/listener.rb
... | ... | @@ -5,7 +5,8 @@ class CommunityHubPlugin::Listener |
5 | 5 | class << self |
6 | 6 | |
7 | 7 | def twitter_service(hub) |
8 | - Twurl::Stream.run(hub, nil, hub.hashtags_twitter, File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc', hub.proxy_url) | |
8 | + hub.twitter_token_file ||= 'twurlrc' | |
9 | + Twurl::Stream.run(hub, nil, hub.hashtags_twitter, File.dirname(__FILE__) + '/../../tweeter_stream/config/' + hub.twitter_token_file, hub.proxy_url) | |
9 | 10 | end |
10 | 11 | |
11 | 12 | def facebook_service(hub) | ... | ... |
tweeter_stream/lib/twurl/request_controller.rb
... | ... | @@ -17,6 +17,10 @@ module Twurl |
17 | 17 | client.perform_request_from_options(options) { |response| |
18 | 18 | chunk_begining = "" |
19 | 19 | puts "Connecting to tweeter stream: " + response.inspect |
20 | + if response.inspect.to_s.include?('HTTPClientError 420') | |
21 | + puts "<<<<<<Error connecting to tweeter stream, maybe need another token!!!!!>>>>>>" | |
22 | + return | |
23 | + end | |
20 | 24 | response.read_body { |chunk| |
21 | 25 | chunk = chunk_begining + chunk |
22 | 26 | chunk_complete = false |
... | ... | @@ -39,11 +43,11 @@ module Twurl |
39 | 43 | comment.source = options.page |
40 | 44 | comment.body = comment_text |
41 | 45 | comment.author_id = options.author_id |
42 | - #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation | |
46 | + #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation | |
43 | 47 | comment.name = ic.iconv(parsed["user"]["name"] + ' ')[0..-2] |
48 | + puts "@#{comment.name} " +_('said') + ": #{comment.body}" | |
44 | 49 | comment.email = 'admin@localhost.local' |
45 | 50 | comment.save! |
46 | - puts "@#{comment.name} " +_('said') + ": #{comment_text}" | |
47 | 51 | end |
48 | 52 | rescue => e |
49 | 53 | puts "Erro gravando comentário twitter #{e.inspect}" | ... | ... |
views/cms/community_hub_plugin/_hub.rhtml
... | ... | @@ -25,6 +25,8 @@ |
25 | 25 | <br /><br /> |
26 | 26 | <span><%= required labelled_form_field(_('Twitter\'s Hashtags, comma separated words<br>(example: participa.br,participabr,arenanetmundial,netmundial'), text_field(:article, :hashtags_twitter)) %></span> |
27 | 27 | <br /> |
28 | + <span><%= required labelled_form_field(_('Twitter\'s token file<br>use "twurlrc_mariajoseopinto" for production and "twurlrc" for development and test'), text_field(:article, :twitter_token_file)) %></span> | |
29 | + <br /> | |
28 | 30 | <div> |
29 | 31 | <%= _('Facebook Settings:') %> |
30 | 32 | </div> | ... | ... |