forked from redmine/redmine
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
temporarily dont ignore plugins
- Loading branch information
Showing
7 changed files
with
299 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
= top_bar | ||
|
||
Description goes here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
module MenuGeneratorHelper | ||
def left_menu_tabs | ||
tabs = [ { :name => 'menu', :label => 'Menu', :partial => 'left_menu/menu.rhtml' }, | ||
{ :name => 'actions', :label => 'Actions', :partial => 'left_menu/actions.rhtml' } ] | ||
return tabs | ||
end | ||
def render_header_image (project) | ||
out = "" | ||
if project | ||
if project.try(:topbarbackgroundcolor) | ||
out += 'background-color:'+project.topbarbackgroundcolor+';' | ||
end | ||
if FileTest.exist?("#{Rails.root}/public/headerimages/"+project.id.to_s+'.jpg') | ||
out += 'background-image:url(/headerimages/'+project.id.to_s+'.jpg);' | ||
end | ||
out = ' style="' + out + '"' | ||
end | ||
return out | ||
end | ||
|
||
|
||
def render_header_textcolor (project) | ||
out = "" | ||
if project then | ||
if project.try(:topbartextcolor) then | ||
out += 'color:'+project.topbartextcolor | ||
end | ||
end | ||
return out | ||
end | ||
|
||
def render_header_menu (project) | ||
out = "" | ||
### HEADER MENU ### | ||
# Highlight current top menu item | ||
identifier = 'start' | ||
if (project) then | ||
identifier = get_parent_project_identifiers(project).last | ||
end | ||
|
||
# Display START | ||
htmlOptions = { | ||
:class => 'start' | ||
} | ||
if (identifier == 'start') | ||
htmlOptions[:class] += ' current' | ||
end | ||
#out += link_to "Start", {:controller => 'start', :action => 'index'}, htmlOptions | ||
|
||
# todo | ||
# Display Subprojects | ||
# Project.find(:all, :conditions => 'parent_id IS NULL', :order => :sorting).each { |prj| | ||
# out += generate_link_to_project(prj, (identifier == prj.identifier), 0) | ||
# } | ||
return out | ||
end | ||
|
||
def render_left_menu (project) | ||
out = '' | ||
if project and project.id | ||
@projectidentifier = project.identifier | ||
rootline = get_parent_project_identifiers(project) | ||
firstLevelProject = Project.find(rootline.last) | ||
out += outputProjectsRecursively(firstLevelProject, rootline, 1) | ||
else # No project selected | ||
out += link_to "Register project", "/" | ||
end | ||
return out; | ||
end | ||
private | ||
|
||
def get_parent_project_identifiers (project) | ||
parentProjects = Array.new | ||
parentProjects << project.identifier | ||
while (project.parent != nil) do | ||
project = project.parent | ||
parentProjects << project.identifier | ||
end | ||
return parentProjects | ||
end | ||
|
||
def generate_link_to_project (project, active, level) | ||
# if (! project.visible_by(User.current)) then | ||
# return "" | ||
# end | ||
htmlOptions = { | ||
:class => 'level-'+level.to_s | ||
} | ||
if (active) then | ||
htmlOptions[:class] += ' current' | ||
end | ||
|
||
htmlOptions[:class] += ' sorting-'+project.sorting.to_s | ||
|
||
return link_to project.name, {:controller => 'projects', :action => 'show', :id => project.identifier }, htmlOptions | ||
end | ||
|
||
def outputProjectsRecursively (project, rootline, level, inSelectTag = false) | ||
out = '' | ||
|
||
projects = Project.find(:all, :order => "sorting, name", :conditions => [Project.visible_condition(User.current) + " AND parent_id = ?", project.id]) | ||
|
||
if (inSelectTag || ( level == 2 && projects.length > 20 ) ) then | ||
if (level == 2) then | ||
out += '<select onchange="window.location.href=\'/projects/\'+this.value"><option value="extensions">- Select Subproject-</option>' | ||
end | ||
projects.each do |prj| | ||
select = '' | ||
if (prj.identifier == @projectidentifier) then | ||
select = 'selected="selected"' | ||
end | ||
out += '<option '+select+' value="'+prj.identifier+'">'+prj.name+'</option>' | ||
out += outputProjectsRecursively(prj, rootline, level+1, true) | ||
end | ||
|
||
if (level == 2) then | ||
out += '</select>' | ||
end | ||
else | ||
projects.each { |prj| | ||
if (rootline.include? prj.identifier) then # Selected menu item | ||
out += generate_link_to_project(prj, true, level) | ||
out += outputProjectsRecursively(prj, rootline, level + 1) | ||
else # Not selected menu item | ||
out += generate_link_to_project(prj, false, level) | ||
end | ||
} | ||
end | ||
return out | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<!DOCTYPE html> | ||
<html lang="<%= current_language %>"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/> | ||
<title><%= html_title %></title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | ||
<meta name="description" content="<%= Redmine::Info.app_name %>" /> | ||
<meta name="keywords" content="issue,bug,tracker" /> | ||
<%= csrf_meta_tag %> | ||
<%= favicon %> | ||
<%= stylesheet_link_tag 'jquery/jquery-ui-1.11.0', 'application', 'responsive', :media => 'all' %> | ||
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %> | ||
<%= javascript_heads %> | ||
<%= heads_for_theme %> | ||
<%= call_hook :view_layouts_base_html_head %> | ||
<!-- page specific tags --> | ||
<%= yield :header_tags -%> | ||
<style type="text/css"> | ||
<% if @project && @project.try(:topbartextcolor) %> | ||
#header #right-area, #header #right-area h1, #header #right-area a { | ||
color:<%=@project.topbartextcolor%>; | ||
} | ||
<% end %> | ||
</style> | ||
</head> | ||
<body class="<%= body_css_classes %>"> | ||
<div id="wrapper"> | ||
|
||
<div class="flyout-menu js-flyout-menu"> | ||
|
||
|
||
<% if User.current.logged? || !Setting.login_required? %> | ||
<div class="flyout-menu__search"> | ||
<%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %> | ||
<%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %> | ||
<%= label_tag 'flyout-search', '⚲'.html_safe, :class => 'search-magnifier search-magnifier--flyout' %> | ||
<%= text_field_tag 'q', @question, :id => 'flyout-search', :class => 'small js-search-input', :placeholder => l(:label_search) %> | ||
<% end %> | ||
</div> | ||
<% end %> | ||
<% if User.current.logged? %> | ||
<div class="flyout-menu__avatar <% if !Setting.gravatar_enabled? %>flyout-menu__avatar--no-avatar<% end %>"> | ||
<% if Setting.gravatar_enabled? %> | ||
<%= link_to(avatar(User.current, :size => "80"), user_path(User.current)) %> | ||
<% end %> | ||
<%= link_to_user(User.current, :format => :username) %> | ||
</div> | ||
<% end %> | ||
<% if display_main_menu?(@project) %> | ||
<h3><%= l(:label_project) %></h3> | ||
<span class="js-project-menu"></span> | ||
<% end %> | ||
|
||
<h3><%= l(:label_general) %></h3> | ||
<span class="js-general-menu"></span> | ||
|
||
<span class="js-sidebar flyout-menu__sidebar"></span> | ||
|
||
<h3><%= l(:label_profile) %></h3> | ||
<span class="js-profile-menu"></span> | ||
|
||
</div> | ||
|
||
<div id="wrapper2"> | ||
<div id="wrapper3"> | ||
<div id="top-menu"> | ||
<div id="account"> | ||
<%= render_menu :account_menu -%> | ||
</div> | ||
<%= content_tag('div', "#{l(:label_logged_as)} #{link_to_user(User.current, :format => :username)}".html_safe, :id => 'loggedas') if User.current.logged? %> | ||
<%= render_menu :top_menu if User.current.logged? || !Setting.login_required? -%> | ||
</div> | ||
|
||
<div id="header"> | ||
|
||
<div id="header-left"> | ||
<div id="header-menu"> | ||
<%= render_header_menu(@project) %> | ||
</div> | ||
</div> | ||
|
||
<a href="#" class="mobile-toggle-button js-flyout-menu-toggle-button"></a> | ||
|
||
<div id="right-area" <%= render_header_image @project %>> | ||
<% if User.current.logged? || !Setting.login_required? %> | ||
<div id="quick-search"> | ||
<%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %> | ||
<%= hidden_field_tag(controller.default_search_scope, 1, :id => nil) if controller.default_search_scope %> | ||
<label for='q'> | ||
<%= link_to l(:label_search), {:controller => 'search', :action => 'index', :id => @project}, :accesskey => accesskey(:search) %>: | ||
</label> | ||
<%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search) %> | ||
<% end %> | ||
<%= render_project_jump_box %> | ||
</div> | ||
<% end %> | ||
|
||
<h1><%= page_header_title %></h1> | ||
|
||
<% if display_main_menu?(@project) %> | ||
<div id="main-menu"> | ||
<%= render_main_menu(@project) %> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div id="main" class="<%= sidebar_content? ? '' : 'nosidebar' %>"> | ||
|
||
<div id="leftmenu"> | ||
<%= render_left_menu (@project) %> | ||
</div> | ||
|
||
<div id="sidebar"> | ||
<%= yield :sidebar %> | ||
<%= view_layouts_base_sidebar_hook_response %> | ||
</div> | ||
|
||
<div id="content"> | ||
<%= render_flash_messages %> | ||
<%= yield %> | ||
<%= call_hook :view_layouts_base_content %> | ||
<div style="clear:both;"></div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div> | ||
<div id="ajax-modal" style="display:none;"></div> | ||
|
||
<div id="footer"> | ||
|
||
<div class="bgl"><div class="bgr"> | ||
Powered by <%= link_to Redmine::Info.app_name, Redmine::Info.url %> © 2006-2012 Jean-Philippe Lang<br /><br /> | ||
Hosting sponsor:<br /><br /> | ||
<script type="text/javascript">var buttonStyle = "footer-grey-31";</script> | ||
<script src="//typo3.org/fileadmin/t3org/images/FM-content/team-pages/server-team/sponsor-banners/sponsors.js"></script> | ||
</div></div> | ||
</div> | ||
</div> | ||
</div> | ||
<%= call_hook :view_layouts_base_body_bottom %> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# English strings go here for Rails i18n | ||
en: | ||
# my_label: "My label" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Plugin's routes | ||
# See: http://guides.rubyonrails.org/routing.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Redmine::Plugin.register :top_bar do | ||
name 'Top Bar plugin' | ||
author 'Matthias Hennemeyer' | ||
description 'This is a plugin for Redmine' | ||
version '0.0.1' | ||
url 'http://example.com/path/to/plugin' | ||
author_url 'http://example.com/about' | ||
end | ||
|
||
ActionView::Base.send(:include, MenuGeneratorHelper) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Load the Redmine helper | ||
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper') |