##// END OF EJS Templates
Adds #favicon_path and #favicon_url helpers....
Jean-Philippe Lang -
r12386:1eda38be4ce0
parent child
Show More
@@ -1270,8 +1270,21 module ApplicationHelper
1270 end
1270 end
1271
1271
1272 def favicon
1272 def favicon
1273 fav_path = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico'
1273 "<link rel='shortcut icon' href='#{favicon_path}' />".html_safe
1274 "<link rel='shortcut icon' href='#{image_path(fav_path)}' />".html_safe
1274 end
1275
1276 # Returns the path to the favicon
1277 def favicon_path
1278 icon = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico'
1279 image_path(icon)
1280 end
1281
1282 # Returns the full URL to the favicon
1283 def favicon_url
1284 # TODO: use #image_url introduced in Rails4
1285 path = favicon_path
1286 base = url_for(:controller => 'welcome', :action => 'index', :only_path => false)
1287 base.sub(%r{/+$},'') + '/' + path.sub(%r{^/+},'')
1275 end
1288 end
1276
1289
1277 def robot_exclusion_tag
1290 def robot_exclusion_tag
@@ -1264,4 +1264,26 RAW
1264 assert_equal '<h2>Foo &#187; Bar</h2>', title('Foo', 'Bar')
1264 assert_equal '<h2>Foo &#187; Bar</h2>', title('Foo', 'Bar')
1265 assert_equal 'Bar - Foo - Redmine', html_title
1265 assert_equal 'Bar - Foo - Redmine', html_title
1266 end
1266 end
1267
1268 def test_favicon_path
1269 assert_match %r{^/favicon\.ico}, favicon_path
1270 end
1271
1272 def test_favicon_path_with_suburi
1273 Redmine::Utils.relative_url_root = '/foo'
1274 assert_match %r{^/foo/favicon\.ico}, favicon_path
1275 ensure
1276 Redmine::Utils.relative_url_root = ''
1277 end
1278
1279 def test_favicon_url
1280 assert_match %r{^http://test\.host/favicon\.ico}, favicon_url
1281 end
1282
1283 def test_favicon_url_with_suburi
1284 Redmine::Utils.relative_url_root = '/foo'
1285 assert_match %r{^http://test\.host/foo/favicon\.ico}, favicon_url
1286 ensure
1287 Redmine::Utils.relative_url_root = ''
1288 end
1267 end
1289 end
General Comments 0
You need to be logged in to leave comments. Login now