Commit 90eebff2ed28191e0e443b896040b2f2d5bc932e
Exists in
master
and in
29 other branches
Merge branch 'stable'
Conflicts: debian/changelog lib/noosfero.rb lib/noosfero/plugin.rb
Showing
6 changed files
with
37 additions
and
1 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -224,6 +224,8 @@ class AccountController < ApplicationController |
224 | 224 | session[:notice] = nil # consume the notice |
225 | 225 | end |
226 | 226 | |
227 | + @plugins.enabled_plugins.each { |plugin| user_data.merge!(plugin.user_data_extras) } | |
228 | + | |
227 | 229 | render :text => user_data.to_json, :layout => false, :content_type => "application/javascript" |
228 | 230 | end |
229 | 231 | ... | ... |
debian/changelog
1 | +noosfero (0.31.5) unstable; urgency=low | |
2 | + | |
3 | + * Bugfix version release | |
4 | + | |
5 | + -- Daniela Soares Feitosa <daniela@colivre.coop.br> Mon, 15 Aug 2011 18:20:13 -0300 | |
6 | + | |
1 | 7 | noosfero (0.31.4) unstable; urgency=low |
2 | 8 | |
3 | 9 | * Bugfix Version release |
4 | 10 | |
5 | 11 | -- Rodrigo Souto <rodrigo@colivre.coop.br> Fri, 15 Jul 2011 16:40:05 -0300 |
6 | 12 | |
13 | + | |
7 | 14 | noosfero (0.31.3) unstable; urgency=low |
8 | 15 | |
9 | 16 | * Bugfix Version release. | ... | ... |
lib/noosfero.rb
lib/noosfero/plugin.rb
... | ... | @@ -128,6 +128,12 @@ class Noosfero::Plugin |
128 | 128 | [] |
129 | 129 | end |
130 | 130 | |
131 | + # -> Adds stuff in user data hash | |
132 | + # returns = { :some_data => some_value, :another_data => another_value } | |
133 | + def user_data_extras | |
134 | + {} | |
135 | + end | |
136 | + | |
131 | 137 | # -> Parse and possibly make changes of content (article, block, etc) during HTML rendering |
132 | 138 | # returns = content as string after parser and changes |
133 | 139 | def parse_content(raw_content) | ... | ... |
public/javascripts/application.js
... | ... | @@ -475,6 +475,8 @@ jQuery(function($) { |
475 | 475 | if (data.notice) { |
476 | 476 | display_notice(data.notice); |
477 | 477 | } |
478 | + // Bind this event to do more actions with the user data (for example, inside plugins) | |
479 | + $(window).trigger("userDataLoaded", data); | |
478 | 480 | }); |
479 | 481 | |
480 | 482 | function loggedInDataCallBack(data) { | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -670,6 +670,25 @@ class AccountControllerTest < Test::Unit::TestCase |
670 | 670 | assert_equal 'unavailable', assigns(:status_class) |
671 | 671 | end |
672 | 672 | |
673 | + should 'merge user data with extra stuff from plugins' do | |
674 | + plugin1 = mock() | |
675 | + plugin1.stubs(:user_data_extras).returns({ :foo => 'bar' }) | |
676 | + | |
677 | + plugin2 = mock() | |
678 | + plugin2.stubs(:user_data_extras).returns({ :test => 5 }) | |
679 | + | |
680 | + enabled_plugins = [plugin1, plugin2] | |
681 | + | |
682 | + plugins = mock() | |
683 | + plugins.stubs(:enabled_plugins).returns(enabled_plugins) | |
684 | + Noosfero::Plugin::Manager.stubs(:new).returns(plugins) | |
685 | + | |
686 | + login_as 'ze' | |
687 | + | |
688 | + xhr :get, :user_data | |
689 | + assert_equal User.find_by_login('ze').data_hash.merge({ 'foo' => 'bar', 'test' => 5 }), ActiveSupport::JSON.decode(@response.body) | |
690 | + end | |
691 | + | |
673 | 692 | protected |
674 | 693 | def new_user(options = {}, extra_options ={}) |
675 | 694 | data = {:profile_data => person_data} | ... | ... |