Commit 130acb98b64bf9c32543531248500ebd15ef5d17

Authored by Rodrigo Souto
2 parents 2d3800c3 630c8265

Merge commit 'refs/merge-requests/387' of git://gitorious.org/noosfero/noosfero …

…into merge-requests/387

Conflicts:
	app/helpers/application_helper.rb
	public/designs/themes/base/style.css
app/controllers/public/account_controller.rb
... ... @@ -262,7 +262,7 @@ class AccountController < ApplicationController
262 262 def user_data
263 263 user_data =
264 264 if logged_in?
265   - current_user.data_hash
  265 + current_user.data_hash self
266 266 else
267 267 { }
268 268 end
... ...
app/helpers/application_helper.rb
... ... @@ -356,7 +356,8 @@ module ApplicationHelper
356 356 end
357 357  
358 358 def theme_path
359   - if session[:theme]
  359 + if ( respond_to?(:session) && session[:theme] ) ||
  360 + ( @controller && @controller.session[:theme] )
360 361 '/user_themes/' + current_theme
361 362 else
362 363 '/designs/themes/' + current_theme
... ... @@ -366,7 +367,8 @@ module ApplicationHelper
366 367 def current_theme
367 368 @current_theme ||=
368 369 begin
369   - if (session[:theme])
  370 + if ( respond_to?(:session) && session[:theme] ) ||
  371 + ( @controller && @controller.session[:theme] )
370 372 session[:theme]
371 373 else
372 374 # utility for developers: set the theme to 'random' in development mode and
... ... @@ -375,7 +377,7 @@ module ApplicationHelper
375 377 if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random'
376 378 @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand
377 379 @random_theme
378   - elsif ENV['RAILS_ENV'] == 'development' && params[:theme] && File.exists?(File.join(Rails.root, 'public/designs/themes', params[:theme]))
  380 + elsif ENV['RAILS_ENV'] == 'development' && respond_to?(:params) && params[:theme] && File.exists?(File.join(Rails.root, 'public/designs/themes', params[:theme]))
379 381 params[:theme]
380 382 else
381 383 if profile && !profile.theme.nil?
... ... @@ -603,15 +605,10 @@ module ApplicationHelper
603 605  
604 606 def str_gravatar_url_for(email, options = {})
605 607 default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil
606   - url = 'http://www.gravatar.com/avatar.php?gravatar_id=' +
607   - Digest::MD5.hexdigest(email.to_s)
608   - {
  608 + "http://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.to_s)}?" + {
609 609 :only_path => false,
610 610 :d => default
611   - }.merge(options).each { |k,v|
612   - url += ( '&%s=%s' % [ k,v ] )
613   - }
614   - url
  611 + }.merge(options).map{|k,v| '%s=%s' % [ k,v ] }.join('&')
615 612 end
616 613  
617 614 def gravatar_profile_url(email)
... ... @@ -940,7 +937,7 @@ module ApplicationHelper
940 937 (@category ? " - #{@category.full_name}" : '')
941 938 end
942 939  
943   - # DEPRECATED. Do not use this·
  940 + # DEPRECATED. Do not use this.
944 941 def import_controller_stylesheets(options = {})
945 942 stylesheet_import( "controller_"+ @controller.controller_name(), options )
946 943 end
... ... @@ -1158,12 +1155,12 @@ module ApplicationHelper
1158 1155 pending_tasks_count = link_to(count.to_s, @environment.top_url + '/myprofile/{login}/tasks', :id => 'pending-tasks-count', :title => _("Manage your pending tasks"))
1159 1156 end
1160 1157  
1161   - (_("<span class='welcome'>Welcome,</span> %s") % link_to('<i></i><strong>{login}</strong>', @environment.top_url + '/{login}', :id => "homepage-link", :title => _('Go to your homepage'))) +
  1158 + (_("<span class='welcome'>Welcome,</span> %s") % link_to('<i style="background-image:url({avatar})"></i><strong>{login}</strong>', @environment.top_url + '/{login}', :id => "homepage-link", :title => _('Go to your homepage'))) +
1162 1159 render_environment_features(:usermenu) +
1163   - link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', @environment.top_url + '/admin', :id => "controlpanel", :title => _("Configure the environment"), :class => 'admin-link', :style => 'display: none') +
  1160 + link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', @environment.top_url + '/admin', :title => _("Configure the environment"), :class => 'admin-link', :style => 'display: none') +
1164 1161 manage_enterprises.to_s +
1165 1162 manage_communities.to_s +
1166   - link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', @environment.top_url + '/myprofile/{login}', :id => "controlpanel", :title => _("Configure your personal account and content")) +
  1163 + link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', @environment.top_url + '/myprofile/{login}', :class => 'ctrl-panel', :title => _("Configure your personal account and content")) +
1167 1164 pending_tasks_count +
1168 1165 link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system"))
1169 1166 end
... ...
app/models/user.rb
... ... @@ -275,7 +275,10 @@ class User &lt; ActiveRecord::Base
275 275 end
276 276 end
277 277  
278   - def data_hash
  278 + include ApplicationHelper
  279 +
  280 + def data_hash(controller=nil)
  281 + @controller ||= controller
279 282 friends_list = {}
280 283 enterprises = person.enterprises.map { |e| { 'name' => e.short_name, 'identifier' => e.identifier } }
281 284 self.person.friends.online.map do |person|
... ... @@ -286,8 +289,11 @@ class User &lt; ActiveRecord::Base
286 289 'status' => person.user.chat_status,
287 290 }
288 291 end
  292 + avatar = self.person.profile_custom_icon
  293 + avatar = str_gravatar_url_for(self.email, :size=>20) if avatar.blank?
289 294 {
290 295 'login' => self.login,
  296 + 'avatar' => avatar,
291 297 'is_admin' => self.person.is_admin?,
292 298 'since_month' => self.person.created_at.month,
293 299 'since_year' => self.person.created_at.year,
... ...
public/designs/themes/base/style.css
... ... @@ -89,7 +89,7 @@ body, th, td, input {
89 89 color: #555753;
90 90 }
91 91  
92   -#controlpanel, #logout, #openchat, .manage-groups {
  92 +#user .logged-in > * {
93 93 margin-left: 25px;
94 94 }
95 95  
... ... @@ -105,6 +105,14 @@ body, th, td, input {
105 105 top: 3px;
106 106 }
107 107  
  108 +#user #homepage-link i {
  109 + width: 18px;
  110 + height: 18px;
  111 + left: -20px;
  112 + top: -2px;
  113 + background-position: 50% 50%;
  114 +}
  115 +
108 116 #user form {
109 117 position: relative;
110 118 display: inline;
... ...
public/javascripts/application.js
... ... @@ -539,7 +539,11 @@ jQuery(function($) {
539 539 }
540 540 $(this).attr('href', new_href);
541 541 });
542   - var html = $(this).html().replace(/{login}/g, data.login).replace('{month}', data.since_month).replace('{year}', data.since_year);
  542 + var html = $(this).html()
  543 + .replace(/{login}/g, data.login)
  544 + .replace('{avatar}', data.avatar)
  545 + .replace('{month}', data.since_month)
  546 + .replace('{year}', data.since_year);
543 547 $(this).html(html).fadeIn();
544 548 if (data.is_admin) {
545 549 $('#user .admin-link').show();
... ...
public/stylesheets/application.css
... ... @@ -868,7 +868,10 @@ code input {
868 868 }
869 869 #manage-enterprises .simplemenu-item a {
870 870 background-repeat: no-repeat;
871   - padding-left: 20px;
  871 + background-position: 5px 50%;
  872 + padding: 1px 0px 0px 26px;
  873 + line-height: 15px;
  874 + display: block;
872 875 }
873 876 #manage-enterprises .simplemenu-item a span {
874 877 display: none;
... ...