Commit 429f21d078cbf4f26eb0fedd42abdb93d1b58e58
1 parent
07f9167d
Exists in
master
and in
28 other branches
Hotspot for customize profile_image_link (profile block)
Showing
3 changed files
with
32 additions
and
14 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -553,6 +553,9 @@ module ApplicationHelper |
553 | 553 | # displays a link to the profile homepage with its image (as generated by |
554 | 554 | # #profile_image) and its name below it. |
555 | 555 | def profile_image_link( profile, size=:portrait, tag='li', extra_info = nil ) |
556 | + if content = @plugins.first_impl(:profile_image_link, profile) | |
557 | + return instance_eval(&content) | |
558 | + end | |
556 | 559 | name = profile.short_name |
557 | 560 | if profile.person? |
558 | 561 | url = url_for(profile.check_friendship_url) |
... | ... | @@ -569,16 +572,16 @@ module ApplicationHelper |
569 | 572 | extra_info = extra_info.nil? ? '' : content_tag( 'span', extra_info, :class => 'extra_info' ) |
570 | 573 | links = links_for_balloon(profile) |
571 | 574 | content_tag('div', content_tag(tag, |
572 | - (environment.enabled?(:show_balloon_with_profile_links_when_clicked) ? link_to( content_tag( 'span', _('Profile links')), '#', :onclick => "toggleSubmenu(this, '#{profile.short_name}', #{links.to_json}); return false", :class => "menu-submenu-trigger #{trigger_class}", :url => url) : "") + | |
573 | - link_to( | |
574 | - content_tag( 'span', profile_image( profile, size ), :class => 'profile-image' ) + | |
575 | - content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) + | |
576 | - extra_info + profile_sex_icon( profile ) + profile_cat_icons( profile ), | |
577 | - profile.url, | |
578 | - :class => 'profile_link url', | |
579 | - :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name, | |
580 | - :title => profile.name ), | |
581 | - :class => 'vcard'), :class => 'common-profile-list-block') | |
575 | + (environment.enabled?(:show_balloon_with_profile_links_when_clicked) ? link_to( content_tag( 'span', _('Profile links')), '#', :onclick => "toggleSubmenu(this, '#{profile.short_name}', #{links.to_json}); return false", :class => "menu-submenu-trigger #{trigger_class}", :url => url) : "") + | |
576 | + link_to( | |
577 | + content_tag( 'span', profile_image( profile, size ), :class => 'profile-image' ) + | |
578 | + content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) + | |
579 | + extra_info + profile_sex_icon( profile ) + profile_cat_icons( profile ), | |
580 | + profile.url, | |
581 | + :class => 'profile_link url', | |
582 | + :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name, | |
583 | + :title => profile.name ), | |
584 | + :class => 'vcard'), :class => 'common-profile-list-block') | |
582 | 585 | end |
583 | 586 | |
584 | 587 | def gravatar_url_for(email, options = {}) | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -128,6 +128,7 @@ class Noosfero::Plugin |
128 | 128 | |
129 | 129 | # Here the developer may specify the events to which the plugins can |
130 | 130 | # register and must return true or false. The default value must be false. |
131 | + # Must also explicitly defined its returning variables. | |
131 | 132 | |
132 | 133 | # -> If true, noosfero will include plugin_dir/public/style.css into |
133 | 134 | # application |
... | ... | @@ -135,10 +136,6 @@ class Noosfero::Plugin |
135 | 136 | false |
136 | 137 | end |
137 | 138 | |
138 | - # Here the developer should specify the events to which the plugins can | |
139 | - # register to. Must be explicitly defined its returning | |
140 | - # variables. | |
141 | - | |
142 | 139 | # -> Adds buttons to the control panel |
143 | 140 | # returns = { :title => title, :icon => icon, :url => url } |
144 | 141 | # title = name that will be displayed. |
... | ... | @@ -148,6 +145,13 @@ class Noosfero::Plugin |
148 | 145 | nil |
149 | 146 | end |
150 | 147 | |
148 | + # -> Customize profile block design and behavior | |
149 | + # (overwrites profile_image_link function) | |
150 | + # returns = lambda block that creates html code. | |
151 | + def profile_image_link profile | |
152 | + nil | |
153 | + end | |
154 | + | |
151 | 155 | # -> Adds tabs to the profile |
152 | 156 | # returns = { :title => title, :id => id, :content => content, :start => start } |
153 | 157 | # title = name that will be displayed. | ... | ... |
lib/noosfero/plugin/manager.rb
... | ... | @@ -27,6 +27,17 @@ class Noosfero::Plugin::Manager |
27 | 27 | map { |plugin| plugin.send(event, *args) }.compact |
28 | 28 | end |
29 | 29 | |
30 | + # return first implementation of a specific hotspot | |
31 | + def first_impl(event, *args) | |
32 | + default = Noosfero::Plugin.new.send(event, *args) | |
33 | + impl = default | |
34 | + each do |plugin| | |
35 | + impl = plugin.send(event, *args) | |
36 | + break if impl != default | |
37 | + end | |
38 | + impl | |
39 | + end | |
40 | + | |
30 | 41 | alias :dispatch_scopes :dispatch_without_flatten |
31 | 42 | |
32 | 43 | def enabled_plugins | ... | ... |