diff --git a/lib/community_hub_plugin/hub.rb b/lib/community_hub_plugin/hub.rb index 4e1d01e..5c0a122 100644 --- a/lib/community_hub_plugin/hub.rb +++ b/lib/community_hub_plugin/hub.rb @@ -6,6 +6,7 @@ class CommunityHubPlugin::Hub < Folder settings_items :proxy_url, :type => :string, :default => 'http://161.148.1.167:3128' # Remember to use add the port, in case needed. settings_items :twitter_enabled, :type => :boolean, :default => false settings_items :hashtags_twitter, :type => :string, :default => "participa.br,participabr,arenanetmundial,netmundial" + settings_items :twitter_token_file, :type => :string, :default => "twurlrc_mariajoseopinto" settings_items :facebook_enabled, :type => :boolean, :default => false settings_items :facebook_page_id, :type => :string, :default => "participabr" settings_items :facebook_pooling_time, :type => :integer, :default => 5 # Time in seconds diff --git a/lib/community_hub_plugin/listener.rb b/lib/community_hub_plugin/listener.rb index 2b974f5..8cb2af4 100644 --- a/lib/community_hub_plugin/listener.rb +++ b/lib/community_hub_plugin/listener.rb @@ -5,7 +5,8 @@ class CommunityHubPlugin::Listener class << self def twitter_service(hub) - Twurl::Stream.run(hub, nil, hub.hashtags_twitter, File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc', hub.proxy_url) + hub.twitter_token_file ||= 'twurlrc' + Twurl::Stream.run(hub, nil, hub.hashtags_twitter, File.dirname(__FILE__) + '/../../tweeter_stream/config/' + hub.twitter_token_file, hub.proxy_url) end def facebook_service(hub) diff --git a/tweeter_stream/lib/twurl/request_controller.rb b/tweeter_stream/lib/twurl/request_controller.rb index 7a946c2..27ce699 100755 --- a/tweeter_stream/lib/twurl/request_controller.rb +++ b/tweeter_stream/lib/twurl/request_controller.rb @@ -17,6 +17,10 @@ module Twurl client.perform_request_from_options(options) { |response| chunk_begining = "" puts "Connecting to tweeter stream: " + response.inspect + if response.inspect.to_s.include?('HTTPClientError 420') + puts "<<<<<>>>>>" + return + end response.read_body { |chunk| chunk = chunk_begining + chunk chunk_complete = false @@ -39,11 +43,11 @@ module Twurl comment.source = options.page comment.body = comment_text comment.author_id = options.author_id - #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation + #Attention please, don't remove + ' ')[0..-2] it is used for UTF8 validation comment.name = ic.iconv(parsed["user"]["name"] + ' ')[0..-2] + puts "@#{comment.name} " +_('said') + ": #{comment.body}" comment.email = 'admin@localhost.local' comment.save! - puts "@#{comment.name} " +_('said') + ": #{comment_text}" end rescue => e puts "Erro gravando comentário twitter #{e.inspect}" diff --git a/views/cms/community_hub_plugin/_hub.rhtml b/views/cms/community_hub_plugin/_hub.rhtml index b925359..d5d70d2 100644 --- a/views/cms/community_hub_plugin/_hub.rhtml +++ b/views/cms/community_hub_plugin/_hub.rhtml @@ -25,6 +25,8 @@

<%= required labelled_form_field(_('Twitter\'s Hashtags, comma separated words
(example: participa.br,participabr,arenanetmundial,netmundial'), text_field(:article, :hashtags_twitter)) %>

+ <%= required labelled_form_field(_('Twitter\'s token file
use "twurlrc_mariajoseopinto" for production and "twurlrc" for development and test'), text_field(:article, :twitter_token_file)) %>
+
<%= _('Facebook Settings:') %>
-- libgit2 0.21.2