we now always have a theme, so there are no

special cases for themed and un-themed display.
the default theme lives in 'default.css' and is
automatically registered. other themes can hook
in by using the asset pipeline and registering
with Redmine::Themes.register
pull/1186/head
Martin Linkhorst 12 years ago
parent b8324d0c8e
commit c9772cefa4
  1. 7
      app/assets/stylesheets/application.css.erb
  2. 8
      app/assets/stylesheets/default.css
  3. 0
      app/assets/stylesheets/default/application.css.erb
  4. 3
      app/views/layouts/base.html.erb
  5. 2
      app/views/settings/_display.html.erb
  6. 56
      lib/redmine/themes.rb

@ -7,12 +7,5 @@
*= require jquery.ui.all
*= require chosen
*= require jstoolbar
*= require default
*
*/
<%
# theme = Redmine::Themes.theme(Setting.ui_theme)
# require_asset theme.name.to_s
%>

@ -0,0 +1,8 @@
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*
*= require application
*= require default/application
*/

@ -7,8 +7,7 @@
<meta name="keywords" content="issue,bug,tracker" />
<%= csrf_meta_tag %>
<%= favicon_link_tag current_theme.favicon_path %>
<%= stylesheet_link_tag 'application' %>
<%= stylesheet_link_tag current_theme.main_stylesheet_path unless current_theme.default? %>
<%= stylesheet_link_tag current_theme.main_stylesheet_path %>
<%= javascript_include_tag 'application' %>
<!-- aditional headers -->
<%= content_for(:header_tags) if content_for?(:header_tags) %>

@ -1,7 +1,7 @@
<%= form_tag({:action => 'edit', :tab => 'display'}) do %>
<div class="box tabular settings">
<p><%= setting_select :ui_theme, Redmine::Themes.all.map { |theme| [theme.name, theme.name] }, :blank => :label_default, :label => :label_theme %></p>
<p><%= setting_select :ui_theme, Redmine::Themes.all.map { |theme| [theme.name, theme.name] }, :label => :label_theme %></p>
<p id="setting_available_languages"><%= setting_multiselect :available_languages, all_lang_options_for_select(false) %></p>

@ -28,53 +28,63 @@ module Redmine
installed_themes
end
def self.register(*names)
self.installed_themes += names.map { |name| Theme.new(name.to_s) }
def self.register(*themes)
self.installed_themes += themes.map { |theme| Theme.from(theme) }
end
def self.theme(name)
find_theme(name) || default
end
# TODO: always require a default theme
def self.default
return default_theme
# find_theme(default_theme_name) or
# raise DefaultThemeNotFoundError, 'default theme was not found'
find_theme(name) || Theme.default
end
def self.find_theme(name)
installed_themes.detect { |theme| theme.name == name.to_s }
installed_themes.detect { |theme| theme.name.to_s == name.to_s }
end
def self.default_theme
@default_theme ||= Theme.new
extend Enumerable
def self.each(&block)
installed_themes.each(&block)
end
class Theme
attr_accessor :name
Theme = Struct.new(:name) do
cattr_accessor :default_theme
def self.from(theme)
theme.kind_of?(Theme) ? theme : new(theme)
end
def initialize(name = :default)
@name = name
def self.default
self.default_theme ||= from default_theme_name
end
def favicon_path
"#{prefix}/favicon.ico"
@favicon_path ||= begin
path = '/favicon.ico'
path = "#{name}#{path}" unless default?
path
end
end
def main_stylesheet_path
name
end
def prefix
default? ? '' : name
def default?
self == self.class.default
end
def default?
name == :default
def self.default_theme_name
:default
end
include Comparable
def <=>(other)
name.to_s <=> other.name.to_s
end
end
self.register Theme.default
end
end

Loading…
Cancel
Save