Project

General

Profile

Patch #15689 » 15689-theme_favicon.patch

Felix Schäfer, 2013-12-14 12:31

View differences:

app/helpers/application_helper.rb
end
def favicon
"<link rel='shortcut icon' href='#{image_path('/favicon.ico')}' />".html_safe
fav_path = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico'
"<link rel='shortcut icon' href='#{image_path(fav_path)}' />".html_safe
end
def robot_exclusion_tag
lib/redmine/themes.rb
@javascripts ||= assets("javascripts", "js")
end
def favicons
@favicons ||= assets("favicon")
end
def favicon
favicons.first
end
def favicon?
favicon.present?
end
def stylesheet_path(source)
"/themes/#{dir}/stylesheets/#{source}"
end
......
"/themes/#{dir}/javascripts/#{source}"
end
def favicon_path
"/themes/#{dir}/favicon/#{favicon}"
end
private
def assets(dir, ext=nil)
test/integration/lib/redmine/themes_test.rb
@theme.javascripts.delete 'theme'
end
def test_use_default_favicon_if_theme_provides_none
get '/'
assert_response :success
assert_tag tag: 'link',
attributes: {rel: 'shortcut icon', href: %r{\A/favicon.ico}}
end
def test_use_theme_favicon_if_theme_provides_one
# Simulate a theme favicon
@theme.favicons << 'a.ico'
get '/'
assert_response :success
assert_tag tag: 'link',
attributes: {rel: 'shortcut icon', href: %r{\A/themes/#{@theme.dir}/favicon/a.ico}}
ensure
@theme.favicons.delete 'a.ico'
end
def test_use_only_one_theme_favicon_if_theme_provides_many
@theme.favicons.concat %w{b.ico a.png}
get '/'
assert_response :success
assert_tag tag: 'link',
attributes: {rel: 'shortcut icon', href: %r{\A/themes/#{@theme.dir}/favicon/b.ico}}
ensure
@theme.favicons.delete("b.ico")
@theme.favicons.delete("a.png")
end
def test_with_sub_uri
Redmine::Utils.relative_url_root = '/foo'
@theme.javascripts << 'theme'
@theme.favicons << 'a.ico'
get '/'
assert_response :success
......
:attributes => {:href => %r{^/foo/themes/#{@theme.dir}/stylesheets/application.css}}
assert_tag :tag => 'script',
:attributes => {:src => %r{^/foo/themes/#{@theme.dir}/javascripts/theme.js}}
assert_tag tag: 'link',
attributes: {rel: 'shortcut icon', href: %r{\A/foo/themes/#{@theme.dir}/favicon/a.ico}}
ensure
Redmine::Utils.relative_url_root = ''
end
(2-2/2)