From 2a1ea20528e44e636dfd1f7ddfdbcec3ee3d8da0 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Fri, 19 Oct 2007 16:15:51 +0000 Subject: [PATCH] ActionItem111: added more links to the user_options bar --- app/controllers/public/home_controller.rb | 2 +- app/helpers/application_helper.rb | 50 ++++++++++++++++++++++++++++++++++++++++++-------- app/views/layouts/application.rhtml | 3 ++- script/populate | 2 +- 4 files changed, 46 insertions(+), 11 deletions(-) diff --git a/app/controllers/public/home_controller.rb b/app/controllers/public/home_controller.rb index 791c908..592af08 100644 --- a/app/controllers/public/home_controller.rb +++ b/app/controllers/public/home_controller.rb @@ -2,6 +2,6 @@ class HomeController < PublicController design :holder => 'environment' def index -# redirect_to homepage_path(:profile => 'anhetegua') + redirect_to homepage_path(:profile => 'noosfero') if Profile.find_by_identifier('noosfero') end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8569ed9..c499851 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -115,14 +115,20 @@ module ApplicationHelper # FIXME: uncomment "My enterprises" links def user_links links = [ - ( link_to_homepage(current_user.login) ), - ( link_to(_('My account'), { :controller => 'account' }) ), + ( link_to_homepage( _('My account') )), ( link_to_myprofile _('My Enterprises'), {:controller => 'membership_editor'} ), ( link_to(_('Admin'), { :controller => 'admin_panel' }) if current_user.person.is_admin?), + ( link_to_document (about_document), _('About') if about_document ), ].join("\n") content_tag('span', links, :id => 'user_links') end + def about_document + Article.find_all_by_title('About').select do |a| + a.full_path.split(/\//).shift == 'noosfero' + end[0] + end + def header login_or_register_or_logout end @@ -190,30 +196,58 @@ module ApplicationHelper ] end + def myprofile_links + links = [ + [(link_to _('Change password'), {:controller => 'account', :action => 'change_password'}), 'edit_profile', profile] + ] + end + + def about_links + links = [ + [(link_to _('Report bug'), 'http://www.colivre.coop.br/Noosfero/BugItem')], + ] + end + + def design_links + links = [ + [(link_to _('Change template'), :controller => 'profile_editor', :action => 'design_editor_change_template')], + [(link_to _('Change block theme'), :controller => 'profile_editor', :action => 'design_editor_change_theme')], + [(link_to _('Change icon theme'), :controller => 'profile_editor', :action => 'design_editor_change_icon_theme')], + ] + end - #FIXME: find a way of accessing environment from here def user_options - profile = params[:profile] + profile = Profile.find_by_identifier(params[:profile]) case params[:controller] when 'admin_panel' admin_links when 'membership_editor' membership_links when 'profile_editor' - if profile.kind_of?(Enterprise) + if profile.kind_of?(Enterprise) && params[:action] == 'index' enterprise_links - elsif profile.kind_of?(Person) - person_links + elsif profile.kind_of?(Person) && params[:action] == 'index' + myprofile_links + elsif params[:action] == 'design_editor' + design_links else [] end when 'content_viewer' - person_links + if params[:profile] == 'noosfero' && params[:page][0] == 'about' + about_links + else + person_links + end else [] end.map{|l| link_if_permitted(l[0], l[1], l[2]) } end + def accessibility_link + link_to _('Accessibility') + end + def footer # FIXME: add some information from the environment [ diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml index d282c7b..b828a3d 100644 --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -63,7 +63,8 @@
- Ir para conteúdo + Ir para conteúdo + <%= accessibility_link %> Acessibilidade
diff --git a/script/populate b/script/populate index f0f1fb7..7a9b084 100755 --- a/script/populate +++ b/script/populate @@ -1,7 +1,7 @@ #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/environment' -anhetegua = Profile.create!(:name => 'anhetegua', :identifier => 'anhetegua') +anhetegua = Profile.create!(:name => 'noosfero', :identifier => 'noosfero') User.create!(:login => 'testprofile', :email => 'admin@localhost.localdomain', :password => 'test', :password_confirmation => 'test') User.create!(:login => 'user', :email => 'user@localhost.localdomain', :password => 'user', :password_confirmation => 'user') -- libgit2 0.21.2