##// END OF EJS Templates
Added basic Theme support....
Jean-Philippe Lang -
r807:824a67ab5a34
parent child
Show More
@@ -0,0 +1,72
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 module Redmine
19 module Themes
20
21 # Return an array of installed themes
22 def self.themes
23 @@installed_themes ||= scan_themes
24 end
25
26 # Rescan themes directory
27 def self.rescan
28 @@installed_themes = scan_themes
29 end
30
31 # Return theme for given id, or nil if it's not found
32 def self.theme(id)
33 themes.find {|t| t.id == id}
34 end
35
36 # Class used to represent a theme
37 class Theme
38 attr_reader :name, :dir, :stylesheets
39
40 def initialize(path)
41 @dir = File.basename(path)
42 @name = @dir.humanize
43 @stylesheets = Dir.glob("#{path}/stylesheets/*.css").collect {|f| File.basename(f).gsub(/\.css$/, '')}
44 end
45
46 # Directory name used as the theme id
47 def id; dir end
48
49 def <=>(theme)
50 name <=> theme.name
51 end
52 end
53
54 private
55
56 def self.scan_themes
57 dirs = Dir.glob('public/themes/*').select do |f|
58 # A theme should at least override application.css
59 File.directory?(f) && File.exist?("#{f}/stylesheets/application.css")
60 end
61 dirs.collect {|dir| Theme.new(dir)}.sort
62 end
63 end
64 end
65
66 module ApplicationHelper
67 def stylesheet_path(source)
68 @current_theme ||= Redmine::Themes.theme(Setting.ui_theme)
69 super((@current_theme && @current_theme.stylesheets.include?(source)) ?
70 "/themes/#{@current_theme.dir}/stylesheets/#{source}" : source)
71 end
72 end
@@ -0,0 +1,1
1 Put your Redmine themes here.
@@ -13,6 +13,9
13 <%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p>
13 <%= text_area_tag 'settings[welcome_text]', Setting.welcome_text, :cols => 60, :rows => 5, :class => 'wiki-edit' %></p>
14 <%= wikitoolbar_for 'settings[welcome_text]' %>
14 <%= wikitoolbar_for 'settings[welcome_text]' %>
15
15
16 <p><label><%= l(:label_theme) %></label>
17 <%= select_tag 'settings[ui_theme]', options_for_select( ([[l(:label_default), '']] + Redmine::Themes.themes.collect {|t| [t.name, t.id]}), Setting.ui_theme) %></p>
18
16 <p><label><%= l(:setting_default_language) %></label>
19 <p><label><%= l(:setting_default_language) %></label>
17 <%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
20 <%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %></p>
18
21
@@ -92,4 +92,6 issue_list_default_columns:
92 # multiple values accepted, comma separated
92 # multiple values accepted, comma separated
93 repositories_encodings:
93 repositories_encodings:
94 default: ''
94 default: ''
95 ui_theme:
96 default: ''
95 No newline at end of file
97
@@ -431,6 +431,8 label_changeset_plural: Changesets
431 label_default_columns: Default columns
431 label_default_columns: Default columns
432 label_no_change_option: (No change)
432 label_no_change_option: (No change)
433 label_bulk_edit_selected_issues: Bulk edit selected issues
433 label_bulk_edit_selected_issues: Bulk edit selected issues
434 label_theme: Theme
435 label_default: Default
434
436
435 button_login: Login
437 button_login: Login
436 button_submit: Submit
438 button_submit: Submit
@@ -431,6 +431,8 label_changeset_plural: Révisions
431 label_default_columns: Colonnes par défaut
431 label_default_columns: Colonnes par défaut
432 label_no_change_option: (Pas de changement)
432 label_no_change_option: (Pas de changement)
433 label_bulk_edit_selected_issues: Modifier les demandes sélectionnées
433 label_bulk_edit_selected_issues: Modifier les demandes sélectionnées
434 label_theme: Thème
435 label_default: Défaut
434
436
435 button_login: Connexion
437 button_login: Connexion
436 button_submit: Soumettre
438 button_submit: Soumettre
@@ -1,6 +1,7
1 require 'redmine/access_control'
1 require 'redmine/access_control'
2 require 'redmine/menu_manager'
2 require 'redmine/menu_manager'
3 require 'redmine/mime_type'
3 require 'redmine/mime_type'
4 require 'redmine/themes'
4 require 'redmine/plugin'
5 require 'redmine/plugin'
5
6
6 begin
7 begin
General Comments 0
You need to be logged in to leave comments. Login now