Commit 4af253484f36223a06984e2f797f704039c50555
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
#community-dashboard - merge
Showing
4 changed files
with
40 additions
and
19 deletions
Show diff stats
plugins/community_hub/facebook_stream/lib_facebook_stream.rb
| @@ -7,7 +7,7 @@ require 'json' | @@ -7,7 +7,7 @@ require 'json' | ||
| 7 | #'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' | 7 | #'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' |
| 8 | # BACKUP TOKEN 'CAAEhsewl0ZAcBAHhipXszZCURSwWLmgvceDbs9mB5baJdLriFxYMEzywmF2fvZBuThuA2Mm7QF8wPd3E6R5pVqVEnC2VhcBb4VrfAnkZC73ZC5g1NRUnKZCB2e6CaRiUBDatR2nf505PeKp7Aj5XxvTdfSqdZCsXxQFYZApPNSUUgkUWm6HwL4rp21MRJXb612sZD' | 8 | # BACKUP TOKEN 'CAAEhsewl0ZAcBAHhipXszZCURSwWLmgvceDbs9mB5baJdLriFxYMEzywmF2fvZBuThuA2Mm7QF8wPd3E6R5pVqVEnC2VhcBb4VrfAnkZC73ZC5g1NRUnKZCB2e6CaRiUBDatR2nf505PeKp7Aj5XxvTdfSqdZCsXxQFYZApPNSUUgkUWm6HwL4rp21MRJXb612sZD' |
| 9 | 9 | ||
| 10 | -def facebook_comments(hub, author_id, page_id="participabr", pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') | 10 | +def facebook_comments(hub, author_id, page_id, pooling_time, token, proxy_url) |
| 11 | 11 | ||
| 12 | #raise hub.id.inspect | 12 | #raise hub.id.inspect |
| 13 | @graph = Koala::Facebook::API.new(token) | 13 | @graph = Koala::Facebook::API.new(token) |
plugins/community_hub/lib/community_hub_plugin/hub.rb
| @@ -5,10 +5,14 @@ class CommunityHubPlugin::Hub < Folder | @@ -5,10 +5,14 @@ class CommunityHubPlugin::Hub < Folder | ||
| 5 | 5 | ||
| 6 | @@twitter_thread_started = false #change to hash | 6 | @@twitter_thread_started = false #change to hash |
| 7 | @@facebook_thread_started = false #change to hash | 7 | @@facebook_thread_started = false #change to hash |
| 8 | - | ||
| 9 | - settings_items :hashtags_twitter, :type => :string, :default => "" | ||
| 10 | - settings_items :twitter_enabled, :type => :boolean, :default => false | 8 | + |
| 9 | + settings_items :proxy_url, :type => :string, :default => 'http://161.148.1.167:312' # Remember to use add the port, if needed! | ||
| 10 | + settings_items :twitter_enabled, :type => :boolean, :default => false | ||
| 11 | + settings_items :hashtags_twitter, :type => :string, :default => "participa.br,participabr,arenanetmundial,netmundial" | ||
| 11 | settings_items :facebook_enabled, :type => :boolean, :default => false | 12 | settings_items :facebook_enabled, :type => :boolean, :default => false |
| 13 | + settings_items :facebook_page_id, :type => :string, :default => "participabr" | ||
| 14 | + settings_items :facebook_pooling_time, :type => :integer, :default => 5 # Time in seconds | ||
| 15 | + settings_items :facebook_access_token, :type => :string, :default => 'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' | ||
| 12 | settings_items :pinned_messages, :type => Array, :default => [] | 16 | settings_items :pinned_messages, :type => Array, :default => [] |
| 13 | settings_items :pinned_mediations, :type => Array, :default => [] | 17 | settings_items :pinned_mediations, :type => Array, :default => [] |
| 14 | settings_items :mediators, :type => Array, :default => [] | 18 | settings_items :mediators, :type => Array, :default => [] |
| @@ -34,10 +38,12 @@ class CommunityHubPlugin::Hub < Folder | @@ -34,10 +38,12 @@ class CommunityHubPlugin::Hub < Folder | ||
| 34 | end | 38 | end |
| 35 | 39 | ||
| 36 | def self.twitter_service(hub, action) | 40 | def self.twitter_service(hub, action) |
| 41 | + #raise hub.inspect | ||
| 42 | + #if self.twitter_enabled == false | ||
| 37 | author_id = 54 | 43 | author_id = 54 |
| 38 | if action==:start | 44 | if action==:start |
| 39 | thread = Thread.new { | 45 | thread = Thread.new { |
| 40 | - Twurl::Stream.run(hub, author_id,'#ArenaNETmundial', File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc') | 46 | + Twurl::Stream.run(hub, author_id, self.hashtags_twitter, File.dirname(__FILE__) + '/../../tweeter_stream/config/twurlrc', self.proxy_url) |
| 41 | } unless@@twitter_thread_started | 47 | } unless@@twitter_thread_started |
| 42 | @@twitter_thread_started = true | 48 | @@twitter_thread_started = true |
| 43 | end | 49 | end |
| @@ -49,7 +55,7 @@ class CommunityHubPlugin::Hub < Folder | @@ -49,7 +55,7 @@ class CommunityHubPlugin::Hub < Folder | ||
| 49 | if action==:start | 55 | if action==:start |
| 50 | #facebook_comments(page, author_id, page_id, pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') | 56 | #facebook_comments(page, author_id, page_id, pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') |
| 51 | thread = Thread.new { | 57 | thread = Thread.new { |
| 52 | - facebook_comments(hub, author_id, page_id) | 58 | + facebook_comments(hub, author_id, self.facebook_page_id, self.pooling_time, self.facebook_access_token, self.proxy_url) |
| 53 | } unless@@facebook_thread_started | 59 | } unless@@facebook_thread_started |
| 54 | @@facebook_thread_started = true | 60 | @@facebook_thread_started = true |
| 55 | end | 61 | end |
| @@ -58,4 +64,4 @@ class CommunityHubPlugin::Hub < Folder | @@ -58,4 +64,4 @@ class CommunityHubPlugin::Hub < Folder | ||
| 58 | def view_page | 64 | def view_page |
| 59 | "content_viewer/hub.rhtml" | 65 | "content_viewer/hub.rhtml" |
| 60 | end | 66 | end |
| 61 | -end | ||
| 62 | \ No newline at end of file | 67 | \ No newline at end of file |
| 68 | +end |
plugins/community_hub/tweeter_stream/lib/twurl/stream.rb
| @@ -21,7 +21,7 @@ module Twurl | @@ -21,7 +21,7 @@ module Twurl | ||
| 21 | Twurl.options.command = 'request' # Not necessary anymore | 21 | Twurl.options.command = 'request' # Not necessary anymore |
| 22 | Twurl.options.data = {"track"=>tags} | 22 | Twurl.options.data = {"track"=>tags} |
| 23 | # Twurl.options.proxy = 'http://161.148.1.167:312' # Use for production mode at SERPRO | 23 | # Twurl.options.proxy = 'http://161.148.1.167:312' # Use for production mode at SERPRO |
| 24 | - Twurl.options.proxy = proxy unless proxy.nil? | 24 | + Twurl.options.proxy = proxy unless proxy.nil? or proxy == '' |
| 25 | Twurl.options.trace = false | 25 | Twurl.options.trace = false |
| 26 | Twurl.options.headers = {} | 26 | Twurl.options.headers = {} |
| 27 | Twurl.options.subcommands=[] | 27 | Twurl.options.subcommands=[] |
plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml
| 1 | <div class='hub'> | 1 | <div class='hub'> |
| 2 | - | ||
| 3 | - <h1><%= _("HUB Settings") %></h1> | ||
| 4 | - | 2 | + <h1><%= _("HUB Settings:") %></h1> |
| 5 | <%= required_fields_message %> | 3 | <%= required_fields_message %> |
| 6 | - | ||
| 7 | <div> | 4 | <div> |
| 8 | <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> | 5 | <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> |
| 9 | </div> | 6 | </div> |
| 10 | - | ||
| 11 | <div> | 7 | <div> |
| 12 | <%= required labelled_form_field(_('Description'), text_area(:article, 'body', :style => 'width: 99%;')) %> | 8 | <%= required labelled_form_field(_('Description'), text_area(:article, 'body', :style => 'width: 99%;')) %> |
| 13 | </div> | 9 | </div> |
| 14 | - | ||
| 15 | <br /> | 10 | <br /> |
| 16 | 11 | ||
| 12 | + <div> | ||
| 13 | + <%= _('General Streaming Settings:') %> | ||
| 14 | + </div> | ||
| 15 | + <br /> | ||
| 16 | + <div> | ||
| 17 | + <%= labelled_form_field(_('Proxy URL[:port] leave blank for none (example: http://161.148.1.167:312)'), text_field(:article, :proxy_url, :size => '64', :maxlength => 150)) %> | ||
| 18 | + </div> | ||
| 19 | + <br /> | ||
| 20 | + <div> | ||
| 21 | + <%= _('Twitter Settings:') %> | ||
| 22 | + </div> | ||
| 23 | + <br /> | ||
| 17 | <%= check_box(:article, :twitter_enabled) %> <span><%= _("Turn on TWITTER") %></span> | 24 | <%= check_box(:article, :twitter_enabled) %> <span><%= _("Turn on TWITTER") %></span> |
| 18 | - | ||
| 19 | - <span><%= labelled_form_field(_('Hashtags (TWITTER)'), text_field(:article, 'hashtags_twitter')) %></span> | ||
| 20 | - | 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> | ||
| 27 | + <br /> | ||
| 28 | + <div> | ||
| 29 | + <%= _('Facebook Settings:') %> | ||
| 30 | + </div> | ||
| 21 | <br /> | 31 | <br /> |
| 22 | - | ||
| 23 | <%= check_box(:article, :facebook_enabled) %> <span><%= _("Turn on FACEBOOK") %></span> | 32 | <%= check_box(:article, :facebook_enabled) %> <span><%= _("Turn on FACEBOOK") %></span> |
| 24 | - | 33 | + <br /><br /> |
| 34 | + <span><%= required labelled_form_field(_('Id of Facebook\'s page which will be listened for comments (example: participabr'), text_field(:article, :facebook_page_id)) %></span> | ||
| 35 | + <br /> | ||
| 36 | + <span><%= required labelled_form_field(_('Facebook\'s access token (don\'t change unless last one has expired)'), text_field(:article, :facebook_access_token)) %></span> | ||
| 37 | + <br /> | ||
| 38 | + <a href='https://smashballoon.com/custom-facebook-feed/access-token/' ><%= _('How to get a new access token?') %><a> | ||
| 39 | + <br /> | ||
| 25 | </div> | 40 | </div> |
| 26 | \ No newline at end of file | 41 | \ No newline at end of file |