Feature #21483 ยป theme_patch.diff
| app/helpers/application_helper.rb | ||
|---|---|---|
|
plugin = options.delete(:plugin)
|
||
|
sources = sources.map do |source|
|
||
|
if plugin
|
||
|
"/plugin_assets/#{plugin}/stylesheets/#{source}"
|
||
|
if current_theme && current_theme.overrides?(plugin, source)
|
||
|
current_theme.override(plugin, source)
|
||
|
else
|
||
|
"/plugin_assets/#{plugin}/stylesheets/#{source}"
|
||
|
end
|
||
|
elsif current_theme && current_theme.stylesheets.include?(source)
|
||
|
current_theme.stylesheet_path(source)
|
||
|
else
|
||
| ... | ... | |
|
# image_tag('image.png', :plugin => 'foo) # => picks image.png from plugin's assets
|
||
|
#
|
||
|
def image_tag(source, options={})
|
||
|
if plugin = options.delete(:plugin)
|
||
|
source = "/plugin_assets/#{plugin}/images/#{source}"
|
||
|
plugin = options.delete(:plugin)
|
||
|
ns = source
|
||
|
if plugin
|
||
|
if current_theme && current_theme.overrides?(plugin, source)
|
||
|
ns = current_theme.override(plugin, source)
|
||
|
else
|
||
|
ns = "/plugin_assets/#{plugin}/images/#{source}"
|
||
|
end
|
||
|
elsif current_theme && current_theme.images.include?(source)
|
||
|
source = current_theme.image_path(source)
|
||
|
ns = current_theme.image_path(source)
|
||
|
end
|
||
|
super source, options
|
||
|
super ns, options
|
||
|
end
|
||
|
# Overrides Rails' javascript_include_tag with plugins support
|
||
| ... | ... | |
|
#
|
||
|
def javascript_include_tag(*sources)
|
||
|
options = sources.last.is_a?(Hash) ? sources.pop : {}
|
||
|
if plugin = options.delete(:plugin)
|
||
|
plugin = options.delete(:plugin)
|
||
|
if plugin
|
||
|
sources = sources.map do |source|
|
||
|
if plugin
|
||
|
"/plugin_assets/#{plugin}/javascripts/#{source}"
|
||
|
if current_theme && current_theme.overrides?(plugin, source)
|
||
|
current_theme.override(plugin, source)
|
||
|
else
|
||
|
"/plugin_assets/#{plugin}/javascripts/#{source}"
|
||
|
end
|
||
|
else
|
||
|
source
|
||
|
end
|
||
| lib/redmine/themes.rb | ||
|---|---|---|
|
name <=> theme.name
|
||
|
end
|
||
|
def overrides?(plugin, source)
|
||
|
@plugin_overrides ||= get_overrides
|
||
|
@plugin_overrides[plugin] && @plugin_overrides[plugin].include?(source)
|
||
|
end
|
||
|
def override(plugin, source)
|
||
|
"/themes/#{dir}/plugins/#{plugin}/#{source}"
|
||
|
end
|
||
|
def stylesheets
|
||
|
@stylesheets ||= assets("stylesheets", "css")
|
||
|
end
|
||
| ... | ... | |
|
private
|
||
|
def get_overrides
|
||
|
overrides = Hash.new
|
||
|
folders = Dir.glob("#{path}/plugins/*")
|
||
|
folders.each do |plugin|
|
||
|
plugin_name = plugin.split("/")[-1]
|
||
|
folder = "#{path}/plugins/#{plugin_name}/*"
|
||
|
new_items = Dir[folder]
|
||
|
items = []
|
||
|
while items.count < new_items.count
|
||
|
items = new_items
|
||
|
folder += "/*"
|
||
|
new_items += Dir[folder]
|
||
|
new_items.uniq!
|
||
|
end
|
||
|
ignore_path = "#{path}/plugins/#{plugin_name}/"
|
||
|
overrides[plugin_name] = items.map { |i| i.gsub(ignore_path, "") }
|
||
|
end
|
||
|
overrides
|
||
|
end
|
||
|
def assets(dir, ext=nil)
|
||
|
if ext
|
||
|
Dir.glob("#{path}/#{dir}/*.#{ext}").collect {|f| File.basename(f).gsub(/\.#{ext}$/, '')}
|
||