Commit 1e02838ed50861b9ed63821ebc6f400361f4166f
1 parent
fe689782
Exists in
master
and in
27 other branches
social-share: hotspot to show social buttons in content view
Plugins can provide social share buttons in content view page. (ActionItem3238)
Showing
3 changed files
with
32 additions
and
0 deletions
Show diff stats
app/views/content_viewer/view_page.html.erb
| ... | ... | @@ -42,6 +42,7 @@ |
| 42 | 42 | |
| 43 | 43 | <%= render :partial => 'shared/disabled_enterprise' %> |
| 44 | 44 | |
| 45 | +<%= @plugins.dispatch(:social_buttons_contents).collect { |content| instance_exec(&content) }.join("") %> | |
| 45 | 46 | <% if NOOSFERO_CONF['addthis_enabled'] %> |
| 46 | 47 | <%= render :partial => 'addthis' %> |
| 47 | 48 | <% end %> | ... | ... |
lib/noosfero/plugin.rb
| ... | ... | @@ -394,6 +394,12 @@ class Noosfero::Plugin |
| 394 | 394 | nil |
| 395 | 395 | end |
| 396 | 396 | |
| 397 | + # -> Adds social networks share buttons to content | |
| 398 | + # returns = proc that creates html code | |
| 399 | + def social_buttons_contents | |
| 400 | + nil | |
| 401 | + end | |
| 402 | + | |
| 397 | 403 | # -> Adds fields to the signup form |
| 398 | 404 | # returns = proc that creates html code |
| 399 | 405 | def signup_extra_contents | ... | ... |
test/functional/content_viewer_controller_test.rb
| ... | ... | @@ -1391,4 +1391,29 @@ class ContentViewerControllerTest < ActionController::TestCase |
| 1391 | 1391 | assert_tag :tag => 'meta', :attributes => { :property => 'og:image', :content => /\/images\/x.png/ } |
| 1392 | 1392 | end |
| 1393 | 1393 | |
| 1394 | + should 'add social content on content view page from plugins' do | |
| 1395 | + class Plugin1 < Noosfero::Plugin | |
| 1396 | + def social_buttons_contents | |
| 1397 | + proc {"<strong>Plugin1 text</strong>"} | |
| 1398 | + end | |
| 1399 | + end | |
| 1400 | + class Plugin2 < Noosfero::Plugin | |
| 1401 | + def social_buttons_contents | |
| 1402 | + proc {"<div class='social-buttons'></div>"} | |
| 1403 | + end | |
| 1404 | + end | |
| 1405 | + Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | |
| 1406 | + | |
| 1407 | + Environment.default.enable_plugin(Plugin1.name) | |
| 1408 | + Environment.default.enable_plugin(Plugin2.name) | |
| 1409 | + | |
| 1410 | + page = profile.articles.build(:name => 'test') | |
| 1411 | + page.save! | |
| 1412 | + | |
| 1413 | + get :view_page, :profile => profile.identifier, :page => ['test'] | |
| 1414 | + | |
| 1415 | + assert_tag :tag => 'strong', :content => 'Plugin1 text' | |
| 1416 | + assert_tag :tag => 'div', :attributes => {:class => 'social-buttons'} | |
| 1417 | + end | |
| 1418 | + | |
| 1394 | 1419 | end | ... | ... |