Commit 83c8889ef2260eb69fe04ae63856676c4691e2eb
Exists in
master
and in
28 other branches
Merge commit 'refs/merge-requests/313' of git://gitorious.org/noosfero/noosfero …
…into merge-requests/313
Showing
3 changed files
with
32 additions
and
14 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -558,6 +558,9 @@ module ApplicationHelper |
558 | 558 | # displays a link to the profile homepage with its image (as generated by |
559 | 559 | # #profile_image) and its name below it. |
560 | 560 | def profile_image_link( profile, size=:portrait, tag='li', extra_info = nil ) |
561 | + if content = @plugins.first_impl(:profile_image_link, profile) | |
562 | + return instance_eval(&content) | |
563 | + end | |
561 | 564 | name = profile.short_name |
562 | 565 | if profile.person? |
563 | 566 | url = url_for(profile.check_friendship_url) |
... | ... | @@ -574,16 +577,16 @@ module ApplicationHelper |
574 | 577 | extra_info = extra_info.nil? ? '' : content_tag( 'span', extra_info, :class => 'extra_info' ) |
575 | 578 | links = links_for_balloon(profile) |
576 | 579 | content_tag('div', content_tag(tag, |
577 | - (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) : "") + | |
578 | - link_to( | |
579 | - content_tag( 'span', profile_image( profile, size ), :class => 'profile-image' ) + | |
580 | - content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) + | |
581 | - extra_info + profile_sex_icon( profile ) + profile_cat_icons( profile ), | |
582 | - profile.url, | |
583 | - :class => 'profile_link url', | |
584 | - :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name, | |
585 | - :title => profile.name ), | |
586 | - :class => 'vcard'), :class => 'common-profile-list-block') | |
580 | + (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) : "") + | |
581 | + link_to( | |
582 | + content_tag( 'span', profile_image( profile, size ), :class => 'profile-image' ) + | |
583 | + content_tag( 'span', h(name), :class => ( profile.class == Person ? 'fn' : 'org' ) ) + | |
584 | + extra_info + profile_sex_icon( profile ) + profile_cat_icons( profile ), | |
585 | + profile.url, | |
586 | + :class => 'profile_link url', | |
587 | + :help => _('Click on this icon to go to the <b>%s</b>\'s home page') % profile.name, | |
588 | + :title => profile.name ), | |
589 | + :class => 'vcard'), :class => 'common-profile-list-block') | |
587 | 590 | end |
588 | 591 | |
589 | 592 | def gravatar_url_for(email, options = {}) | ... | ... |
lib/noosfero/plugin.rb
... | ... | @@ -152,6 +152,7 @@ class Noosfero::Plugin |
152 | 152 | |
153 | 153 | # Here the developer may specify the events to which the plugins can |
154 | 154 | # register and must return true or false. The default value must be false. |
155 | + # Must also explicitly defined its returning variables. | |
155 | 156 | |
156 | 157 | # -> If true, noosfero will include plugin_dir/public/style.css into |
157 | 158 | # application |
... | ... | @@ -159,10 +160,6 @@ class Noosfero::Plugin |
159 | 160 | false |
160 | 161 | end |
161 | 162 | |
162 | - # Here the developer should specify the events to which the plugins can | |
163 | - # register to. Must be explicitly defined its returning | |
164 | - # variables. | |
165 | - | |
166 | 163 | # -> Adds buttons to the control panel |
167 | 164 | # returns = { :title => title, :icon => icon, :url => url } |
168 | 165 | # title = name that will be displayed. |
... | ... | @@ -172,6 +169,13 @@ class Noosfero::Plugin |
172 | 169 | nil |
173 | 170 | end |
174 | 171 | |
172 | + # -> Customize profile block design and behavior | |
173 | + # (overwrites profile_image_link function) | |
174 | + # returns = lambda block that creates html code. | |
175 | + def profile_image_link profile | |
176 | + nil | |
177 | + end | |
178 | + | |
175 | 179 | # -> Adds tabs to the profile |
176 | 180 | # returns = { :title => title, :id => id, :content => content, :start => start } |
177 | 181 | # title = name that will be displayed. | ... | ... |
lib/noosfero/plugin/manager.rb
... | ... | @@ -31,6 +31,17 @@ class Noosfero::Plugin::Manager |
31 | 31 | map { |plugin| plugin.send(event, *args) }.compact |
32 | 32 | end |
33 | 33 | |
34 | + # return first implementation of a specific hotspot | |
35 | + def first_impl(event, *args) | |
36 | + default = Noosfero::Plugin.new.send(event, *args) | |
37 | + impl = default | |
38 | + each do |plugin| | |
39 | + impl = plugin.send(event, *args) | |
40 | + break if impl != default | |
41 | + end | |
42 | + impl | |
43 | + end | |
44 | + | |
34 | 45 | alias :dispatch_scopes :dispatch_without_flatten |
35 | 46 | |
36 | 47 | def dispatch_first(event, *args) | ... | ... |