在app/views/layerout/base.rb文件中
<div id="main-menu">
<%= render_main_menu(@project) %>
</div>
render_main_menu 方法定义在
./lib/redmine/menu_manager.rb 文件中
def render_main_menu(project)
render_menu((project && !project.new_record?) ? :project_menu : :application_menu, project)
end
render_menu定义:
def render_menu(menu, project=nil)
links = []
menu_items_for(menu, project) do |node|
links << render_menu_node(node, project)
end
links.empty? ? nil : content_tag('ul', links.join("\n").html_safe)
end
project_menu 定义在
./lib/redmine.rb 文件中
Redmine::MenuManager.map :project_menu do |menu|
menu.push :overview, { :controller => 'projects', :action => 'show' }
menu.push :activity, { :controller => 'activities', :action => 'index' }
menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
:if => Proc.new { |p| p.shared_versions.any? }
menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_
issue_new,
:html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) },
:if => Proc.new { |p| p.trackers.any? }
menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plura
l
menu.push :wiki, { :controller => 'wiki', :action => 'show', :id => nil }, :param => :project_id,
:if => Proc.new { |p| p.wiki && !p.wiki.new_record? }
menu.push :boards, { :controller => 'boards', :action => 'index', :id => nil }, :param => :project_id,
:if => Proc.new { |p| p.boards.any? }, :caption => :label_board_plural
menu.push :files, { :controller => 'files', :action => 'index' }, :caption => :label_file_plural, :param => :project_id
menu.push :repository, { :controller => 'repositories', :action => 'show', :repository_id => nil, :path => nil, :rev => nil },
:if => Proc.new { |p| p.repository && !p.repository.new_record? }
menu.push :settings, { :controller => 'projects', :action => 'settings' }, :last => true
end
render_menu_node 定义在文件
./lib/redmine/menu_manager.rb
def render_main_menu(project)
render_menu((project && !project.new_record?) ? :project_menu : :application_menu, project)
end
def render_menu(menu, project=nil)
links = []
menu_items_for(menu, project) do |node|
links << render_menu_node(node, project)
end
links.empty? ? nil : content_tag('ul', links.join("\n").html_safe)
end
def render_menu_node(node, project=nil)
if node.children.present? || !node.child_menus.nil?
return render_menu_node_with_children(node, project)
else
caption, url, selected = extract_node_details(node, project)
return content_tag('li',
render_single_menu_node(node, caption, url, selected))
end
end