Commit 8a977e755973364d86cc4af79a33de56b13af668
1 parent
839699ac
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
New option for twitter token file
Showing
4 changed files
with
11 additions
and
3 deletions
Show diff stats
plugins/community_hub/lib/community_hub_plugin/hub.rb
| @@ -6,6 +6,7 @@ class CommunityHubPlugin::Hub < Folder | @@ -6,6 +6,7 @@ class CommunityHubPlugin::Hub < Folder | ||
| 6 | settings_items :proxy_url, :type => :string, :default => 'http://161.148.1.167:3128' # Remember to use add the port, in case needed. | 6 | settings_items :proxy_url, :type => :string, :default => 'http://161.148.1.167:3128' # Remember to use add the port, in case needed. |
| 7 | settings_items :twitter_enabled, :type => :boolean, :default => false | 7 | settings_items :twitter_enabled, :type => :boolean, :default => false |
| 8 | settings_items :hashtags_twitter, :type => :string, :default => "participa.br,participabr,arenanetmundial,netmundial" | 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 | settings_items :facebook_enabled, :type => :boolean, :default => false | 10 | settings_items :facebook_enabled, :type => :boolean, :default => false |
| 10 | settings_items :facebook_page_id, :type => :string, :default => "participabr" | 11 | settings_items :facebook_page_id, :type => :string, :default => "participabr" |
| 11 | settings_items :facebook_pooling_time, :type => :integer, :default => 5 # Time in seconds | 12 | settings_items :facebook_pooling_time, :type => :integer, :default => 5 # Time in seconds |
plugins/community_hub/lib/community_hub_plugin/listener.rb
| @@ -5,7 +5,8 @@ class CommunityHubPlugin::Listener | @@ -5,7 +5,8 @@ class CommunityHubPlugin::Listener | ||
| 5 | class << self | 5 | class << self |
| 6 | 6 | ||
| 7 | def twitter_service(hub) | 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 | end | 10 | end |
| 10 | 11 | ||
| 11 | def facebook_service(hub) | 12 | def facebook_service(hub) |
plugins/community_hub/tweeter_stream/lib/twurl/request_controller.rb
| @@ -17,6 +17,10 @@ module Twurl | @@ -17,6 +17,10 @@ module Twurl | ||
| 17 | client.perform_request_from_options(options) { |response| | 17 | client.perform_request_from_options(options) { |response| |
| 18 | chunk_begining = "" | 18 | chunk_begining = "" |
| 19 | puts "Connecting to tweeter stream: " + response.inspect | 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 | response.read_body { |chunk| | 24 | response.read_body { |chunk| |
| 21 | chunk = chunk_begining + chunk | 25 | chunk = chunk_begining + chunk |
| 22 | chunk_complete = false | 26 | chunk_complete = false |
| @@ -39,11 +43,11 @@ module Twurl | @@ -39,11 +43,11 @@ module Twurl | ||
| 39 | comment.source = options.page | 43 | comment.source = options.page |
| 40 | comment.body = comment_text | 44 | comment.body = comment_text |
| 41 | comment.author_id = options.author_id | 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 | comment.name = ic.iconv(parsed["user"]["name"] + ' ')[0..-2] | 47 | comment.name = ic.iconv(parsed["user"]["name"] + ' ')[0..-2] |
| 48 | + puts "@#{comment.name} " +_('said') + ": #{comment.body}" | ||
| 44 | comment.email = 'admin@localhost.local' | 49 | comment.email = 'admin@localhost.local' |
| 45 | comment.save! | 50 | comment.save! |
| 46 | - puts "@#{comment.name} " +_('said') + ": #{comment_text}" | ||
| 47 | end | 51 | end |
| 48 | rescue => e | 52 | rescue => e |
| 49 | puts "Erro gravando comentário twitter #{e.inspect}" | 53 | puts "Erro gravando comentário twitter #{e.inspect}" |
plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml
| @@ -25,6 +25,8 @@ | @@ -25,6 +25,8 @@ | ||
| 25 | <br /><br /> | 25 | <br /><br /> |
| 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> | 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 | <br /> | 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 | <div> | 30 | <div> |
| 29 | <%= _('Facebook Settings:') %> | 31 | <%= _('Facebook Settings:') %> |
| 30 | </div> | 32 | </div> |