Commit 130acb98b64bf9c32543531248500ebd15ef5d17
Exists in
master
and in
28 other branches
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
Showing
6 changed files
with
37 additions
and
19 deletions
Show diff stats
app/controllers/public/account_controller.rb
@@ -262,7 +262,7 @@ class AccountController < ApplicationController | @@ -262,7 +262,7 @@ class AccountController < ApplicationController | ||
262 | def user_data | 262 | def user_data |
263 | user_data = | 263 | user_data = |
264 | if logged_in? | 264 | if logged_in? |
265 | - current_user.data_hash | 265 | + current_user.data_hash self |
266 | else | 266 | else |
267 | { } | 267 | { } |
268 | end | 268 | end |
app/helpers/application_helper.rb
@@ -356,7 +356,8 @@ module ApplicationHelper | @@ -356,7 +356,8 @@ module ApplicationHelper | ||
356 | end | 356 | end |
357 | 357 | ||
358 | def theme_path | 358 | def theme_path |
359 | - if session[:theme] | 359 | + if ( respond_to?(:session) && session[:theme] ) || |
360 | + ( @controller && @controller.session[:theme] ) | ||
360 | '/user_themes/' + current_theme | 361 | '/user_themes/' + current_theme |
361 | else | 362 | else |
362 | '/designs/themes/' + current_theme | 363 | '/designs/themes/' + current_theme |
@@ -366,7 +367,8 @@ module ApplicationHelper | @@ -366,7 +367,8 @@ module ApplicationHelper | ||
366 | def current_theme | 367 | def current_theme |
367 | @current_theme ||= | 368 | @current_theme ||= |
368 | begin | 369 | begin |
369 | - if (session[:theme]) | 370 | + if ( respond_to?(:session) && session[:theme] ) || |
371 | + ( @controller && @controller.session[:theme] ) | ||
370 | session[:theme] | 372 | session[:theme] |
371 | else | 373 | else |
372 | # utility for developers: set the theme to 'random' in development mode and | 374 | # utility for developers: set the theme to 'random' in development mode and |
@@ -375,7 +377,7 @@ module ApplicationHelper | @@ -375,7 +377,7 @@ module ApplicationHelper | ||
375 | if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random' | 377 | if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random' |
376 | @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand | 378 | @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand |
377 | @random_theme | 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 | params[:theme] | 381 | params[:theme] |
380 | else | 382 | else |
381 | if profile && !profile.theme.nil? | 383 | if profile && !profile.theme.nil? |
@@ -603,15 +605,10 @@ module ApplicationHelper | @@ -603,15 +605,10 @@ module ApplicationHelper | ||
603 | 605 | ||
604 | def str_gravatar_url_for(email, options = {}) | 606 | def str_gravatar_url_for(email, options = {}) |
605 | default = theme_option['gravatar'] || NOOSFERO_CONF['gravatar'] || nil | 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 | :only_path => false, | 609 | :only_path => false, |
610 | :d => default | 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 | end | 612 | end |
616 | 613 | ||
617 | def gravatar_profile_url(email) | 614 | def gravatar_profile_url(email) |
@@ -940,7 +937,7 @@ module ApplicationHelper | @@ -940,7 +937,7 @@ module ApplicationHelper | ||
940 | (@category ? " - #{@category.full_name}" : '') | 937 | (@category ? " - #{@category.full_name}" : '') |
941 | end | 938 | end |
942 | 939 | ||
943 | - # DEPRECATED. Do not use this· | 940 | + # DEPRECATED. Do not use this. |
944 | def import_controller_stylesheets(options = {}) | 941 | def import_controller_stylesheets(options = {}) |
945 | stylesheet_import( "controller_"+ @controller.controller_name(), options ) | 942 | stylesheet_import( "controller_"+ @controller.controller_name(), options ) |
946 | end | 943 | end |
@@ -1158,12 +1155,12 @@ module ApplicationHelper | @@ -1158,12 +1155,12 @@ module ApplicationHelper | ||
1158 | pending_tasks_count = link_to(count.to_s, @environment.top_url + '/myprofile/{login}/tasks', :id => 'pending-tasks-count', :title => _("Manage your pending tasks")) | 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 | end | 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 | render_environment_features(:usermenu) + | 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 | manage_enterprises.to_s + | 1161 | manage_enterprises.to_s + |
1165 | manage_communities.to_s + | 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 | pending_tasks_count + | 1164 | pending_tasks_count + |
1168 | link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system")) | 1165 | link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system")) |
1169 | end | 1166 | end |
app/models/user.rb
@@ -275,7 +275,10 @@ class User < ActiveRecord::Base | @@ -275,7 +275,10 @@ class User < ActiveRecord::Base | ||
275 | end | 275 | end |
276 | end | 276 | end |
277 | 277 | ||
278 | - def data_hash | 278 | + include ApplicationHelper |
279 | + | ||
280 | + def data_hash(controller=nil) | ||
281 | + @controller ||= controller | ||
279 | friends_list = {} | 282 | friends_list = {} |
280 | enterprises = person.enterprises.map { |e| { 'name' => e.short_name, 'identifier' => e.identifier } } | 283 | enterprises = person.enterprises.map { |e| { 'name' => e.short_name, 'identifier' => e.identifier } } |
281 | self.person.friends.online.map do |person| | 284 | self.person.friends.online.map do |person| |
@@ -286,8 +289,11 @@ class User < ActiveRecord::Base | @@ -286,8 +289,11 @@ class User < ActiveRecord::Base | ||
286 | 'status' => person.user.chat_status, | 289 | 'status' => person.user.chat_status, |
287 | } | 290 | } |
288 | end | 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 | 'login' => self.login, | 295 | 'login' => self.login, |
296 | + 'avatar' => avatar, | ||
291 | 'is_admin' => self.person.is_admin?, | 297 | 'is_admin' => self.person.is_admin?, |
292 | 'since_month' => self.person.created_at.month, | 298 | 'since_month' => self.person.created_at.month, |
293 | 'since_year' => self.person.created_at.year, | 299 | 'since_year' => self.person.created_at.year, |
public/designs/themes/base/style.css
@@ -89,7 +89,7 @@ body, th, td, input { | @@ -89,7 +89,7 @@ body, th, td, input { | ||
89 | color: #555753; | 89 | color: #555753; |
90 | } | 90 | } |
91 | 91 | ||
92 | -#controlpanel, #logout, #openchat, .manage-groups { | 92 | +#user .logged-in > * { |
93 | margin-left: 25px; | 93 | margin-left: 25px; |
94 | } | 94 | } |
95 | 95 | ||
@@ -105,6 +105,14 @@ body, th, td, input { | @@ -105,6 +105,14 @@ body, th, td, input { | ||
105 | top: 3px; | 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 | #user form { | 116 | #user form { |
109 | position: relative; | 117 | position: relative; |
110 | display: inline; | 118 | display: inline; |
public/javascripts/application.js
@@ -539,7 +539,11 @@ jQuery(function($) { | @@ -539,7 +539,11 @@ jQuery(function($) { | ||
539 | } | 539 | } |
540 | $(this).attr('href', new_href); | 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 | $(this).html(html).fadeIn(); | 547 | $(this).html(html).fadeIn(); |
544 | if (data.is_admin) { | 548 | if (data.is_admin) { |
545 | $('#user .admin-link').show(); | 549 | $('#user .admin-link').show(); |
public/stylesheets/application.css
@@ -868,7 +868,10 @@ code input { | @@ -868,7 +868,10 @@ code input { | ||
868 | } | 868 | } |
869 | #manage-enterprises .simplemenu-item a { | 869 | #manage-enterprises .simplemenu-item a { |
870 | background-repeat: no-repeat; | 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 | #manage-enterprises .simplemenu-item a span { | 876 | #manage-enterprises .simplemenu-item a span { |
874 | display: none; | 877 | display: none; |