Project

General

Profile

Patch #1864 » 1864-add-js-to-themes.diff

Eric Davis, 2008-10-25 06:46

View differences:

lib/redmine/themes.rb
# Class used to represent a theme
class Theme
attr_reader :name, :dir, :stylesheets
attr_reader :name, :dir, :stylesheets, :images, :javascripts
def initialize(path)
@dir = File.basename(path)
@name = @dir.humanize
@stylesheets = Dir.glob("#{path}/stylesheets/*.css").collect {|f| File.basename(f).gsub(/\.css$/, '')}
@javascripts = Dir.glob("#{path}/javascripts/*.js").collect {|f| File.basename(f).gsub(/\.js$/, '')}
@images = Dir.glob("#{path}/images/*.*").collect {|f| File.basename(f)}
end
# Directory name used as the theme id
......
def path_to_stylesheet(source)
stylesheet_path source
end
end
def image_path(source)
@current_theme ||= Redmine::Themes.theme(Setting.ui_theme)
super((@current_theme && @current_theme.images.include?(source)) ?
"/themes/#{@current_theme.dir}/images/#{source}" : source)
end
def path_to_image(source)
image_path source
end
def javascript_path(source)
@current_theme ||= Redmine::Themes.theme(Setting.ui_theme)
super((@current_theme && @current_theme.javascripts.include?(source)) ?
"/themes/#{@current_theme.dir}/javascripts/#{source}" : source)
end
def path_to_javascript(source)
javascript_path source
end
# or if we wanted to 'catch all' and allow the theme to have it's own version of anything in public
# we could have just have compute_public_path look in the theme first
# def compute_public_path(source, dir, ext = nil, include_host = true)
# end
end
(2-2/2)