将图标添加到Redmine主题 [英] Add a favicon to redmine theme
问题描述
redmine使用放置在/usr/share/redmine/public/favicon.ico
redmine uses the favicon placed at /usr/share/redmine/public/favicon.ico
我使用cd /usr/share/redmine/; grep -HR favicon app/
app/helpers/application_helper.rb: def favicon
app/helpers/application_helper.rb: "<link rel='shortcut icon' href='#{favicon_path}' />".html_safe
app/helpers/application_helper.rb: # Returns the path to the favicon
app/helpers/application_helper.rb: def favicon_path
app/helpers/application_helper.rb: icon = (current_theme && current_theme.favicon?) ? current_theme.favicon_path : '/favicon.ico'
app/helpers/application_helper.rb: # Returns the full URL to the favicon
app/helpers/application_helper.rb: def favicon_url
app/helpers/application_helper.rb: path = favicon_path
app/views/journals/index.builder: xml.icon favicon_url
app/views/common/feed.atom.builder: xml.icon favicon_url
app/views/layouts/base.html.erb:<%= favicon %>
但是没有运气能找到有关如何设置favicon_path
或favicon_url
的更多信息.
But no luck finding more info about how to set the favicon_path
or favicon_url
.
我在主题文件夹中添加了一个小的javascript:javascripts/theme.js
:
I added a small javascript in the theme folder: javascripts/theme.js
:
document.head = document.head || document.getElementsByTagName('head')[0];
function changeFavicon(src) {
var link = document.createElement('link'),
oldLink = document.getElementById('dynamic-favicon');
link.id = 'dynamic-favicon';
link.rel = 'shortcut icon';
link.href = src;
if (oldLink) {
document.head.removeChild(oldLink);
}
document.head.appendChild(link);
}
changeFavicon('../themes/freifunk-red-andy/images/favicon.ico');
(但是该解决方法仅在访问者使用javascript时有效)
(But that workaround only works if the visitor uses javascript)
推荐答案
Redmine会自动将其在主题的favicon
子目录中找到的第一个文件加载.因此,如果您将图标添加到favicon/favicon.ico
,它将被Redmine自动使用.
Redmine automatically loads the first file it finds inside the favicon
sub-directory of your theme. Thus, if you put your favicon into e.g. favicon/favicon.ico
, it will be automatically used by Redmine.
这篇关于将图标添加到Redmine主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!