Commit 9048c13c05907f4cf59c5515c9abfcc5b974503e
1 parent
cb9fa174
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Configuration interface ok
Showing
4 changed files
with
39 additions
and
18 deletions
Show diff stats
plugins/community_hub/facebook_stream/lib_facebook_stream.rb
... | ... | @@ -7,7 +7,7 @@ require 'json' |
7 | 7 | #'CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH' |
8 | 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 | 12 | #raise hub.id.inspect |
13 | 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 | 5 | |
6 | 6 | @@twitter_thread_started = false #change to hash |
7 | 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 | 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 | 16 | settings_items :pinned_messages, :type => Array, :default => [] |
13 | 17 | settings_items :pinned_mediations, :type => Array, :default => [] |
14 | 18 | settings_items :mediators, :type => Array, :default => [] |
... | ... | @@ -34,10 +38,12 @@ class CommunityHubPlugin::Hub < Folder |
34 | 38 | end |
35 | 39 | |
36 | 40 | def self.twitter_service(hub, action) |
41 | + #raise hub.inspect | |
42 | + #if self.twitter_enabled == false | |
37 | 43 | author_id = 54 |
38 | 44 | if action==:start |
39 | 45 | thread = Thread.new { |
40 | - Twurl::Stream.run(hub, author_id,'torrent', 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 | 47 | } unless@@twitter_thread_started |
42 | 48 | @@twitter_thread_started = true |
43 | 49 | end |
... | ... | @@ -49,7 +55,7 @@ class CommunityHubPlugin::Hub < Folder |
49 | 55 | if action==:start |
50 | 56 | #facebook_comments(page, author_id, page_id, pooling_time=5, token='CAAD8cd4tMVkBAO3sh2DrzwZCDfeQq9ZAvTz7Jz24ZC26KtMfBoljqaXhD2vBV1zpP0bjrpxXUBzJvKKcFzOm6rMG9Sok7iNVUaxt5iwr7dfMqCvHpMboKpqrqgeLrfCH5ITVTAdezA6ZBSr9iOJrqyCSOYfui0zTmbXJ3FqtshwNRrRy4NPH') |
51 | 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 | 59 | } unless@@facebook_thread_started |
54 | 60 | @@facebook_thread_started = true |
55 | 61 | end | ... | ... |
plugins/community_hub/tweeter_stream/lib/twurl/stream.rb
... | ... | @@ -21,7 +21,7 @@ module Twurl |
21 | 21 | Twurl.options.command = 'request' # Not necessary anymore |
22 | 22 | Twurl.options.data = {"track"=>tags} |
23 | 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 | 25 | Twurl.options.trace = false |
26 | 26 | Twurl.options.headers = {} |
27 | 27 | Twurl.options.subcommands=[] | ... | ... |
plugins/community_hub/views/cms/community_hub_plugin/_hub.rhtml
1 | 1 | <div class='hub'> |
2 | - | |
3 | - <h1><%= _("HUB Settings") %></h1> | |
4 | - | |
2 | + <h1><%= _("HUB Settings:") %></h1> | |
5 | 3 | <%= required_fields_message %> |
6 | - | |
7 | 4 | <div> |
8 | 5 | <%= required labelled_form_field(_('Title'), text_field(:article, 'name', :size => '64', :maxlength => 150)) %> |
9 | 6 | </div> |
10 | - | |
11 | 7 | <div> |
12 | 8 | <%= required labelled_form_field(_('Description'), text_area(:article, 'body', :style => 'width: 99%;')) %> |
13 | 9 | </div> |
14 | - | |
15 | 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 | 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 | 31 | <br /> |
22 | - | |
23 | 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 | 40 | </div> |
26 | 41 | \ No newline at end of file | ... | ... |