【发布时间】:2014-12-11 07:23:58
【问题描述】:
redmine 使用位于 /usr/share/redmine/public/favicon.ico 的网站图标
我发现很多代码sn-ps使用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 的信息。
解决方法:
我在主题文件夹中添加了一个小javascript: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 时才有效)
【问题讨论】:
-
请不要只问问题就自己回答。虽然这对于定义明确的问题有时是可以接受的,但它并不能免除您提出一个好问题并提供一个好的答案的责任。大多数时候,这些东西最好放在你自己的博客上……
-
我的解决方法不是答案。你的答案似乎真的是我在任何地方都找不到的记录
-
@HolgerJust:我想知道您指的是什么:社区受益于本网站上越来越多的有用问答文章,因此应该鼓励每个人都这样做:回答您自己的问题如果你找到了解决方案