From a52ef51c293330fe8f62aeab148c7dd6d370c83b Mon Sep 17 00:00:00 2001 From: AurelioAHeckert Date: Wed, 30 Jul 2008 00:18:34 +0000 Subject: [PATCH] ActionItem531: more template options --- app/controllers/my_profile/memberships_controller.rb | 2 +- app/helpers/application_helper.rb | 4 ++-- app/models/profile.rb | 5 +++-- app/views/blocks/profile_info.rhtml | 2 +- app/views/memberships/destroy_community.rhtml | 6 +++--- app/views/memberships/index.rhtml | 2 +- app/views/shared/user_menu.rhtml | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------- test/unit/profile_test.rb | 6 +++--- 8 files changed, 80 insertions(+), 75 deletions(-) diff --git a/app/controllers/my_profile/memberships_controller.rb b/app/controllers/my_profile/memberships_controller.rb index 125d98f..517e9f5 100644 --- a/app/controllers/my_profile/memberships_controller.rb +++ b/app/controllers/my_profile/memberships_controller.rb @@ -37,7 +37,7 @@ class MembershipsController < MyProfileController @community = Community.find(params[:id]) if request.post? if @community.destroy - flash[:notice] = _('%s was destroyed!') % @community.display_name + flash[:notice] = _('%s was destroyed!') % @community.short_name redirect_to :action => 'index' end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 53cfd64..3445726 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -400,10 +400,10 @@ module ApplicationHelper # #profile_image) and its name below it. def profile_image_link( profile, size=:portrait, tag='li' ) if profile.class == Person - name = profile.display_name + name = profile.short_name city = content_tag 'span', content_tag( 'span', profile.city, :class => 'locality' ), :class => 'adr' else - name = profile.display_name + name = profile.short_name city = '' end content_tag tag, diff --git a/app/models/profile.rb b/app/models/profile.rb index 6c16530..bbda4e8 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -382,9 +382,10 @@ class Profile < ActiveRecord::Base TinyMceArticle.new(attrs) end - def display_name + include ActionView::Helpers::TextHelper + def short_name if self[:nickname].blank? - self.name + truncate self.identifier, 15, '...' else self[:nickname] end diff --git a/app/views/blocks/profile_info.rhtml b/app/views/blocks/profile_info.rhtml index 501013f..639dc84 100644 --- a/app/views/blocks/profile_info.rhtml +++ b/app/views/blocks/profile_info.rhtml @@ -1,6 +1,6 @@
-

<%= block.owner.display_name %>

+

<%= block.owner.short_name %>

diff --git a/app/views/memberships/destroy_community.rhtml b/app/views/memberships/destroy_community.rhtml index 689a5a5..b206576 100644 --- a/app/views/memberships/destroy_community.rhtml +++ b/app/views/memberships/destroy_community.rhtml @@ -1,9 +1,9 @@ -

<%= _('Destroy %s') % @community.display_name %>

+

<%= _('Destroy %s') % @community.short_name %>

-

<%= _('Are you sure you want to destroy %s?') % @community.display_name %>

+

<%= _('Are you sure you want to destroy %s?') % @community.short_name %>

<% form_tag do %> <%= hidden_field_tag(:confirmation, 1) %> - <%= submit_button(:ok, _("Yes, I want to destroy.") % @community.display_name) %> + <%= submit_button(:ok, _("Yes, I want to destroy.") % @community.short_name) %> <%= button(:cancel, _("No, I don't want."), :action => 'index') %> <% end %> diff --git a/app/views/memberships/index.rhtml b/app/views/memberships/index.rhtml index 97cb751..603ea29 100644 --- a/app/views/memberships/index.rhtml +++ b/app/views/memberships/index.rhtml @@ -9,7 +9,7 @@ <%= profile_image_link(membership, :portrait, 'div') %>
- <%= membership.display_name %>
+ <%= membership.short_name %>
<%= _('Role: %s') % rolename_for(profile, membership) %>
<%= _('Type: %s') % getterm(membership.class.name) %>
<%= _('Description: %s') % membership.description + '
' if membership.community? %> diff --git a/app/views/shared/user_menu.rhtml b/app/views/shared/user_menu.rhtml index 3f092bd..8728329 100644 --- a/app/views/shared/user_menu.rhtml +++ b/app/views/shared/user_menu.rhtml @@ -2,68 +2,72 @@ ' help="'+ _('This menu gives you access to your personal functionalities.') +'"' if logged_in? %>> -<% if logged_in? %> - -
- " alt="<%= current_user.name %> Icon-Photo" title="" height="20" border="0"/> - <%= _("%s's Menu") % current_user.person.display_name %> -
- -
-
    - -
  • <%= __('My Home Page') %>
  • - - - - <% if MailConf.enabled? && current_user.enable_email %> -
  • - <%= link_to '' + _('Webmail'), MailConf.webmail_url %> -
  • - <% end %> - -
  • <%= link_to_myprofile( ''+ _('Control panel'), - {}, nil, :id => 'link_edit_profile', - :help => _('Control panel: change your picture, edit your personal information, create content or change the way your home page looks.') - ) %>
  • - - <%= - '
  • '+ link_to( ''+ _('Admin'), - { :controller => 'admin_panel' }, :id => 'link_admin_panel', - :help => _('Access the site administration panel.') - ) + - '
  • ' if user.is_admin? - %> - -
  • <%= link_to( ''+ _('Logout'), - { :controller => 'account', :action => 'logout'}, - :id => 'link_logout', - :help => _('This link takes you out of the system. You should logout if other people are willing to use the same computer after you.') - ) %>
  • - -
-
- -<% else %> - -<%# lightbox_link_to ''+ _('Login'), - { :controller => 'account', :action => 'login_popup' }, - :id => 'link_login', - :help => _('Click here to enter your username and password and be recognized by the system.') %> - - -<%= thickbox_inline_popup_link(''+ _('Login'), 'inlineLoginBox', :help => _('Click here to enter your username and password and be recognized by the system.')) %> - -<% end %> + <% if logged_in? %> + +
+ " alt="<%= current_user.name %> Icon-Photo" title="" height="20" border="0"/> + <%= _("%s's Menu") % current_user.person.short_name %> +
+ +
+
    + +
  • <%= __('My Home Page') %>
  • + + + + <% if MailConf.enabled? && current_user.enable_email %> +
  • + <%= link_to '' + _('Webmail'), MailConf.webmail_url %> +
  • + <% end %> + +
  • <%= link_to_myprofile( ''+ _('Control panel'), + {}, nil, :id => 'link_edit_profile', + :help => _('Control panel: change your picture, edit your personal information, create content or change the way your home page looks.') + ) %>
  • + + <%= + '
  • '+ link_to( ''+ _('Admin'), + { :controller => 'admin_panel' }, :id => 'link_admin_panel', + :help => _('Access the site administration panel.') + ) + + '
  • ' if user.is_admin? + %> + +
  • <%= link_to( ''+ _('Logout'), + { :controller => 'account', :action => 'logout'}, + :id => 'link_logout', + :help => _('This link takes you out of the system. You should logout if other people are willing to use the same computer after you.') + ) %>
  • + +
+
+ + <% else %> + + <% if theme_option( :menu_login ) == 'full_form' %> + + <%= render :file => 'account/login_block' %> + + <% else # theme_option( :menu_login ) != 'full_form' %> + + <%= thickbox_inline_popup_link(''+ _('Login'), 'inlineLoginBox', :help => _('Click here to enter your username and password and be recognized by the system.')) %> + + + <% end # theme_option( :menu_login ) != 'full_form' %> + + <% end %>
- +<%= javascript_tag 'setAutoOpenMenu( $("user_menu") )' if theme_option( :menu_login ) != 'full_form' %> + diff --git a/test/unit/profile_test.rb b/test/unit/profile_test.rb index fe1fecf..f55a804 100644 --- a/test/unit/profile_test.rb +++ b/test/unit/profile_test.rb @@ -736,9 +736,9 @@ class ProfileTest < Test::Unit::TestCase assert_equal 'code', p.nickname end - should 'display_name return name if nickname is blank' do - p = Profile.new(:name => 'test profile') - assert_equal 'test profile', p.display_name + should 'short_name return truncated identifier if nickname is blank' do + p = Profile.new(:identifier => 'a123456789abcdefghij') + assert_equal 'a123456789ab...', p.short_name end private -- libgit2 0.21.2