From 33e7ae96adcb0282ee181560bb88c0765a8ee149 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Fri, 20 Feb 2009 18:34:57 +0000 Subject: [PATCH] Adds (a maximum of 3) links to project ancestors in the page title (#2788). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2485 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 1 - app/helpers/application_helper.rb | 20 ++++++++++++++++++++ app/views/layouts/base.rhtml | 2 +- app/views/projects/show.rhtml | 4 ---- public/stylesheets/application.css | 1 + test/functional/projects_controller_test.rb | 16 ++++++++++++++++ 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a75e4120a..f9c537cfc 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -90,7 +90,6 @@ class ProjectsController < ApplicationController @members_by_role = @project.members.find(:all, :include => [:user, :role], :order => 'position').group_by {|m| m.role} @subprojects = @project.children.visible - @ancestors = @project.ancestors.visible @news = @project.news.find(:all, :limit => 5, :include => [ :author, :project ], :order => "#{News.table_name}.created_on DESC") @trackers = @project.rolled_up_trackers diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e7aa27033..2872c14a1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -312,6 +312,26 @@ module ApplicationHelper yield Redmine::Views::OtherFormatsBuilder.new(self) concat('

', block.binding) end + + def page_header_title + if @project.nil? || @project.new_record? + h(Setting.app_title) + else + b = [] + ancestors = (@project.root? ? [] : @project.ancestors.visible) + if ancestors.any? + root = ancestors.shift + b << link_to(h(root), {:controller => 'projects', :action => 'show', :id => root, :jump => current_menu_item}, :class => 'root') + if ancestors.size > 2 + b << '…' + ancestors = ancestors[-2, 2] + end + b += ancestors.collect {|p| link_to(h(p), {:controller => 'projects', :action => 'show', :id => p, :jump => current_menu_item}, :class => 'ancestor') } + end + b << h(@project) + b.join(' » ') + end + end def html_title(*args) if args.empty? diff --git a/app/views/layouts/base.rhtml b/app/views/layouts/base.rhtml index 8cb8f5f69..4f9adf6d7 100644 --- a/app/views/layouts/base.rhtml +++ b/app/views/layouts/base.rhtml @@ -37,7 +37,7 @@ <%= render_project_jump_box %> -

<%= h(@project && !@project.new_record? ? @project.name : Setting.app_title) %>

+

<%= page_header_title %>