Commit a52ef51c293330fe8f62aeab148c7dd6d370c83b
1 parent
e1450df2
Exists in
master
and in
23 other branches
ActionItem531: more template options
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2336 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
8 changed files
with
80 additions
and
75 deletions
Show diff stats
app/controllers/my_profile/memberships_controller.rb
| @@ -37,7 +37,7 @@ class MembershipsController < MyProfileController | @@ -37,7 +37,7 @@ class MembershipsController < MyProfileController | ||
| 37 | @community = Community.find(params[:id]) | 37 | @community = Community.find(params[:id]) |
| 38 | if request.post? | 38 | if request.post? |
| 39 | if @community.destroy | 39 | if @community.destroy |
| 40 | - flash[:notice] = _('%s was destroyed!') % @community.display_name | 40 | + flash[:notice] = _('%s was destroyed!') % @community.short_name |
| 41 | redirect_to :action => 'index' | 41 | redirect_to :action => 'index' |
| 42 | end | 42 | end |
| 43 | end | 43 | end |
app/helpers/application_helper.rb
| @@ -400,10 +400,10 @@ module ApplicationHelper | @@ -400,10 +400,10 @@ module ApplicationHelper | ||
| 400 | # #profile_image) and its name below it. | 400 | # #profile_image) and its name below it. |
| 401 | def profile_image_link( profile, size=:portrait, tag='li' ) | 401 | def profile_image_link( profile, size=:portrait, tag='li' ) |
| 402 | if profile.class == Person | 402 | if profile.class == Person |
| 403 | - name = profile.display_name | 403 | + name = profile.short_name |
| 404 | city = content_tag 'span', content_tag( 'span', profile.city, :class => 'locality' ), :class => 'adr' | 404 | city = content_tag 'span', content_tag( 'span', profile.city, :class => 'locality' ), :class => 'adr' |
| 405 | else | 405 | else |
| 406 | - name = profile.display_name | 406 | + name = profile.short_name |
| 407 | city = '' | 407 | city = '' |
| 408 | end | 408 | end |
| 409 | content_tag tag, | 409 | content_tag tag, |
app/models/profile.rb
| @@ -382,9 +382,10 @@ class Profile < ActiveRecord::Base | @@ -382,9 +382,10 @@ class Profile < ActiveRecord::Base | ||
| 382 | TinyMceArticle.new(attrs) | 382 | TinyMceArticle.new(attrs) |
| 383 | end | 383 | end |
| 384 | 384 | ||
| 385 | - def display_name | 385 | + include ActionView::Helpers::TextHelper |
| 386 | + def short_name | ||
| 386 | if self[:nickname].blank? | 387 | if self[:nickname].blank? |
| 387 | - self.name | 388 | + truncate self.identifier, 15, '...' |
| 388 | else | 389 | else |
| 389 | self[:nickname] | 390 | self[:nickname] |
| 390 | end | 391 | end |
app/views/blocks/profile_info.rhtml
| 1 | <div class="vcard"> | 1 | <div class="vcard"> |
| 2 | 2 | ||
| 3 | -<h2 class="<%= profile.class == Person ? 'fn' : 'org' %>"><%= block.owner.display_name %></h2> | 3 | +<h2 class="<%= profile.class == Person ? 'fn' : 'org' %>"><%= block.owner.short_name %></h2> |
| 4 | 4 | ||
| 5 | <div class="profile-info-picture"> | 5 | <div class="profile-info-picture"> |
| 6 | <div class="profile-info-picture-inner1"> | 6 | <div class="profile-info-picture-inner1"> |
app/views/memberships/destroy_community.rhtml
| 1 | -<h1><%= _('Destroy %s') % @community.display_name %></h1> | 1 | +<h1><%= _('Destroy %s') % @community.short_name %></h1> |
| 2 | 2 | ||
| 3 | -<p><strong><%= _('Are you sure you want to destroy %s?') % @community.display_name %></strong></p> | 3 | +<p><strong><%= _('Are you sure you want to destroy %s?') % @community.short_name %></strong></p> |
| 4 | 4 | ||
| 5 | <% form_tag do %> | 5 | <% form_tag do %> |
| 6 | <%= hidden_field_tag(:confirmation, 1) %> | 6 | <%= hidden_field_tag(:confirmation, 1) %> |
| 7 | - <%= submit_button(:ok, _("Yes, I want to destroy.") % @community.display_name) %> | 7 | + <%= submit_button(:ok, _("Yes, I want to destroy.") % @community.short_name) %> |
| 8 | <%= button(:cancel, _("No, I don't want."), :action => 'index') %> | 8 | <%= button(:cancel, _("No, I don't want."), :action => 'index') %> |
| 9 | <% end %> | 9 | <% end %> |
app/views/memberships/index.rhtml
| @@ -9,7 +9,7 @@ | @@ -9,7 +9,7 @@ | ||
| 9 | <%= profile_image_link(membership, :portrait, 'div') %> | 9 | <%= profile_image_link(membership, :portrait, 'div') %> |
| 10 | </div> | 10 | </div> |
| 11 | <span class='profile-details'> | 11 | <span class='profile-details'> |
| 12 | - <strong><%= membership.display_name %></strong><br/> | 12 | + <strong><%= membership.short_name %></strong><br/> |
| 13 | <%= _('Role: %s') % rolename_for(profile, membership) %> <br/> | 13 | <%= _('Role: %s') % rolename_for(profile, membership) %> <br/> |
| 14 | <%= _('Type: %s') % getterm(membership.class.name) %> <br/> | 14 | <%= _('Type: %s') % getterm(membership.class.name) %> <br/> |
| 15 | <%= _('Description: %s') % membership.description + '<br/>' if membership.community? %> | 15 | <%= _('Description: %s') % membership.description + '<br/>' if membership.community? %> |
app/views/shared/user_menu.rhtml
| @@ -2,68 +2,72 @@ | @@ -2,68 +2,72 @@ | ||
| 2 | ' help="'+ _('This menu gives you access to your personal functionalities.') +'"' if logged_in? | 2 | ' help="'+ _('This menu gives you access to your personal functionalities.') +'"' if logged_in? |
| 3 | %>> | 3 | %>> |
| 4 | 4 | ||
| 5 | -<% if logged_in? %> | ||
| 6 | - | ||
| 7 | - <div id="user_menu_head"> | ||
| 8 | - <img src="<%= | ||
| 9 | - (current_user.person.image)? | ||
| 10 | - current_user.person.image.public_filename(:icon) : "/images/icons-bar/photo.png" | ||
| 11 | - %>" alt="<%= current_user.name %> Icon-Photo" title="" height="20" border="0"/> | ||
| 12 | - <span><%= _("%s's Menu") % current_user.person.display_name %> </span> | ||
| 13 | - </div> | ||
| 14 | - | ||
| 15 | - <div id="user_menu_ul"> | ||
| 16 | - <ul> | ||
| 17 | - | ||
| 18 | - <li><a href="<%= homepage_path(:profile => current_user.login) %>" | ||
| 19 | - help="<%= _('Go to your home page.') %>" | ||
| 20 | - ><span class="icon-menu-home"></span><%= __('My Home Page') %></a></li> | ||
| 21 | - | ||
| 22 | - <!-- li><a href="#"><span class="icon-menu-blog"></span> Meu Blog</a></li --> | ||
| 23 | - | ||
| 24 | - <% if MailConf.enabled? && current_user.enable_email %> | ||
| 25 | - <li> | ||
| 26 | - <%= link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url %> | ||
| 27 | - </li> | ||
| 28 | - <% end %> | ||
| 29 | - | ||
| 30 | - <li><%= link_to_myprofile( '<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), | ||
| 31 | - {}, nil, :id => 'link_edit_profile', | ||
| 32 | - :help => _('Control panel: change your picture, edit your personal information, create content or change the way your home page looks.') | ||
| 33 | - ) %></li> | ||
| 34 | - | ||
| 35 | - <%= | ||
| 36 | - '<li>'+ link_to( '<span class="icon-menu-"></span>'+ _('Admin'), | ||
| 37 | - { :controller => 'admin_panel' }, :id => 'link_admin_panel', | ||
| 38 | - :help => _('Access the site administration panel.') | ||
| 39 | - ) + | ||
| 40 | - '</li>' if user.is_admin? | ||
| 41 | - %> | ||
| 42 | - | ||
| 43 | - <li><%= link_to( '<span class="icon-menu-logout"></span>'+ _('Logout'), | ||
| 44 | - { :controller => 'account', :action => 'logout'}, | ||
| 45 | - :id => 'link_logout', | ||
| 46 | - :help => _('This link takes you out of the system. You should logout if other people are willing to use the same computer after you.') | ||
| 47 | - ) %></li> | ||
| 48 | - | ||
| 49 | - </ul> | ||
| 50 | - </div><!-- id="user_menu_ul" --> | ||
| 51 | - | ||
| 52 | -<% else %> | ||
| 53 | - | ||
| 54 | -<%# lightbox_link_to '<span class="icon-menu-login"></span>'+ _('Login'), | ||
| 55 | - { :controller => 'account', :action => 'login_popup' }, | ||
| 56 | - :id => 'link_login', | ||
| 57 | - :help => _('Click here to enter your username and password and be recognized by the system.') %> | ||
| 58 | - | ||
| 59 | -<div id='inlineLoginBox' style='display: none;'> | ||
| 60 | - <%= render :file => 'account/login' %> | ||
| 61 | - <center><%= thickbox_close_button _('Close') %></center> | ||
| 62 | -</div> | ||
| 63 | -<%= thickbox_inline_popup_link('<span class="icon-menu-login"></span>'+ _('Login'), 'inlineLoginBox', :help => _('Click here to enter your username and password and be recognized by the system.')) %> | ||
| 64 | - | ||
| 65 | -<% end %> | 5 | + <% if logged_in? %> |
| 6 | + | ||
| 7 | + <div id="user_menu_head"> | ||
| 8 | + <img src="<%= | ||
| 9 | + (current_user.person.image)? | ||
| 10 | + current_user.person.image.public_filename(:icon) : "/images/icons-bar/photo.png" | ||
| 11 | + %>" alt="<%= current_user.name %> Icon-Photo" title="" height="20" border="0"/> | ||
| 12 | + <span><%= _("%s's Menu") % current_user.person.short_name %> </span> | ||
| 13 | + </div> | ||
| 14 | + | ||
| 15 | + <div id="user_menu_ul"> | ||
| 16 | + <ul> | ||
| 17 | + | ||
| 18 | + <li><a href="<%= homepage_path(:profile => current_user.login) %>" | ||
| 19 | + help="<%= _('Go to your home page.') %>" | ||
| 20 | + ><span class="icon-menu-home"></span><%= __('My Home Page') %></a></li> | ||
| 21 | + | ||
| 22 | + <!-- li><a href="#"><span class="icon-menu-blog"></span> Meu Blog</a></li --> | ||
| 23 | + | ||
| 24 | + <% if MailConf.enabled? && current_user.enable_email %> | ||
| 25 | + <li> | ||
| 26 | + <%= link_to '<span class="icon-menu-mail"></span>' + _('Webmail'), MailConf.webmail_url %> | ||
| 27 | + </li> | ||
| 28 | + <% end %> | ||
| 29 | + | ||
| 30 | + <li><%= link_to_myprofile( '<span class="icon-menu-ctrl-panel"></span>'+ _('Control panel'), | ||
| 31 | + {}, nil, :id => 'link_edit_profile', | ||
| 32 | + :help => _('Control panel: change your picture, edit your personal information, create content or change the way your home page looks.') | ||
| 33 | + ) %></li> | ||
| 34 | + | ||
| 35 | + <%= | ||
| 36 | + '<li>'+ link_to( '<span class="icon-menu-"></span>'+ _('Admin'), | ||
| 37 | + { :controller => 'admin_panel' }, :id => 'link_admin_panel', | ||
| 38 | + :help => _('Access the site administration panel.') | ||
| 39 | + ) + | ||
| 40 | + '</li>' if user.is_admin? | ||
| 41 | + %> | ||
| 42 | + | ||
| 43 | + <li><%= link_to( '<span class="icon-menu-logout"></span>'+ _('Logout'), | ||
| 44 | + { :controller => 'account', :action => 'logout'}, | ||
| 45 | + :id => 'link_logout', | ||
| 46 | + :help => _('This link takes you out of the system. You should logout if other people are willing to use the same computer after you.') | ||
| 47 | + ) %></li> | ||
| 48 | + | ||
| 49 | + </ul> | ||
| 50 | + </div><!-- id="user_menu_ul" --> | ||
| 51 | + | ||
| 52 | + <% else %> | ||
| 53 | + | ||
| 54 | + <% if theme_option( :menu_login ) == 'full_form' %> | ||
| 55 | + | ||
| 56 | + <%= render :file => 'account/login_block' %> | ||
| 57 | + | ||
| 58 | + <% else # theme_option( :menu_login ) != 'full_form' %> | ||
| 59 | + | ||
| 60 | + <%= thickbox_inline_popup_link('<span class="icon-menu-login"></span>'+ _('Login'), 'inlineLoginBox', :help => _('Click here to enter your username and password and be recognized by the system.')) %> | ||
| 61 | + <div id='inlineLoginBox' style='display: none;'> | ||
| 62 | + <%= render :file => 'account/login' %> | ||
| 63 | + <center><%= thickbox_close_button _('Close') %></center> | ||
| 64 | + </div> | ||
| 65 | + | ||
| 66 | + <% end # theme_option( :menu_login ) != 'full_form' %> | ||
| 67 | + | ||
| 68 | + <% end %> | ||
| 66 | 69 | ||
| 67 | </div><!-- fim id="user_menu" --> | 70 | </div><!-- fim id="user_menu" --> |
| 68 | 71 | ||
| 69 | -<script> setAutoOpenMenu( $("user_menu") ); </script> | 72 | +<%= javascript_tag 'setAutoOpenMenu( $("user_menu") )' if theme_option( :menu_login ) != 'full_form' %> |
| 73 | + |
test/unit/profile_test.rb
| @@ -736,9 +736,9 @@ class ProfileTest < Test::Unit::TestCase | @@ -736,9 +736,9 @@ class ProfileTest < Test::Unit::TestCase | ||
| 736 | assert_equal 'code', p.nickname | 736 | assert_equal 'code', p.nickname |
| 737 | end | 737 | end |
| 738 | 738 | ||
| 739 | - should 'display_name return name if nickname is blank' do | ||
| 740 | - p = Profile.new(:name => 'test profile') | ||
| 741 | - assert_equal 'test profile', p.display_name | 739 | + should 'short_name return truncated identifier if nickname is blank' do |
| 740 | + p = Profile.new(:identifier => 'a123456789abcdefghij') | ||
| 741 | + assert_equal 'a123456789ab...', p.short_name | ||
| 742 | end | 742 | end |
| 743 | 743 | ||
| 744 | private | 744 | private |