Patch #15689 » 15689-theme_favicon.patch
| app/helpers/application_helper.rb | ||
|---|---|---|
| 1254 | 1254 |
end |
| 1255 | 1255 | |
| 1256 | 1256 |
def favicon |
| 1257 |
"<link rel='shortcut icon' href='#{image_path('/favicon.ico')}' />".html_safe
|
|
| 1257 |
fav_path = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico' |
|
| 1258 |
"<link rel='shortcut icon' href='#{image_path(fav_path)}' />".html_safe
|
|
| 1258 | 1259 |
end |
| 1259 | 1260 | |
| 1260 | 1261 |
def robot_exclusion_tag |
| lib/redmine/themes.rb | ||
|---|---|---|
| 75 | 75 |
@javascripts ||= assets("javascripts", "js")
|
| 76 | 76 |
end |
| 77 | 77 | |
| 78 |
def favicons |
|
| 79 |
@favicons ||= assets("favicon")
|
|
| 80 |
end |
|
| 81 | ||
| 82 |
def favicon |
|
| 83 |
favicons.first |
|
| 84 |
end |
|
| 85 | ||
| 86 |
def favicon? |
|
| 87 |
favicon.present? |
|
| 88 |
end |
|
| 89 | ||
| 78 | 90 |
def stylesheet_path(source) |
| 79 | 91 |
"/themes/#{dir}/stylesheets/#{source}"
|
| 80 | 92 |
end |
| ... | ... | |
| 87 | 99 |
"/themes/#{dir}/javascripts/#{source}"
|
| 88 | 100 |
end |
| 89 | 101 | |
| 102 |
def favicon_path |
|
| 103 |
"/themes/#{dir}/favicon/#{favicon}"
|
|
| 104 |
end |
|
| 105 | ||
| 90 | 106 |
private |
| 91 | 107 | |
| 92 | 108 |
def assets(dir, ext=nil) |
| test/integration/lib/redmine/themes_test.rb | ||
|---|---|---|
| 57 | 57 |
@theme.javascripts.delete 'theme' |
| 58 | 58 |
end |
| 59 | 59 | |
| 60 |
def test_use_default_favicon_if_theme_provides_none |
|
| 61 |
get '/' |
|
| 62 | ||
| 63 |
assert_response :success |
|
| 64 |
assert_tag tag: 'link', |
|
| 65 |
attributes: {rel: 'shortcut icon', href: %r{\A/favicon.ico}}
|
|
| 66 |
end |
|
| 67 | ||
| 68 |
def test_use_theme_favicon_if_theme_provides_one |
|
| 69 |
# Simulate a theme favicon |
|
| 70 |
@theme.favicons << 'a.ico' |
|
| 71 |
get '/' |
|
| 72 | ||
| 73 |
assert_response :success |
|
| 74 |
assert_tag tag: 'link', |
|
| 75 |
attributes: {rel: 'shortcut icon', href: %r{\A/themes/#{@theme.dir}/favicon/a.ico}}
|
|
| 76 |
ensure |
|
| 77 |
@theme.favicons.delete 'a.ico' |
|
| 78 |
end |
|
| 79 | ||
| 80 |
def test_use_only_one_theme_favicon_if_theme_provides_many |
|
| 81 |
@theme.favicons.concat %w{b.ico a.png}
|
|
| 82 |
get '/' |
|
| 83 | ||
| 84 |
assert_response :success |
|
| 85 |
assert_tag tag: 'link', |
|
| 86 |
attributes: {rel: 'shortcut icon', href: %r{\A/themes/#{@theme.dir}/favicon/b.ico}}
|
|
| 87 |
ensure |
|
| 88 |
@theme.favicons.delete("b.ico")
|
|
| 89 |
@theme.favicons.delete("a.png")
|
|
| 90 |
end |
|
| 91 | ||
| 60 | 92 |
def test_with_sub_uri |
| 61 | 93 |
Redmine::Utils.relative_url_root = '/foo' |
| 62 | 94 |
@theme.javascripts << 'theme' |
| 95 |
@theme.favicons << 'a.ico' |
|
| 63 | 96 |
get '/' |
| 64 | 97 | |
| 65 | 98 |
assert_response :success |
| ... | ... | |
| 67 | 100 |
:attributes => {:href => %r{^/foo/themes/#{@theme.dir}/stylesheets/application.css}}
|
| 68 | 101 |
assert_tag :tag => 'script', |
| 69 | 102 |
:attributes => {:src => %r{^/foo/themes/#{@theme.dir}/javascripts/theme.js}}
|
| 70 | ||
| 103 |
assert_tag tag: 'link', |
|
| 104 |
attributes: {rel: 'shortcut icon', href: %r{\A/foo/themes/#{@theme.dir}/favicon/a.ico}}
|
|
| 71 | 105 |
ensure |
| 72 | 106 |
Redmine::Utils.relative_url_root = '' |
| 73 | 107 |
end |
- « Previous
- 1
- 2
- Next »