Patch #7664 » adding-gravatar-options.patch
app/helpers/settings_helper.rb | ||
---|---|---|
81 | 81 |
l_or_humanize(notifiable.name, :prefix => 'label_'), |
82 | 82 |
:class => notifiable.parent.present? ? "parent" : '') |
83 | 83 |
end |
84 | ||
85 |
def default_gravatar_options |
|
86 |
Redmine::GravatarManager.registered_gravatars.map do |name, url_or_file_name, options| |
|
87 |
if Symbol === url_or_file_name |
|
88 |
[name, url_or_file_name] |
|
89 |
else |
|
90 |
options = (options || {}).with_indifferent_access |
|
91 |
source = image_path(url_or_file_name, options) |
|
92 |
if source !~ %r{^[-a-z]+://} |
|
93 |
source = "#{Setting.protocol}://#{Setting.host_name}#{source}" |
|
94 |
end |
|
95 |
[name, source] |
|
96 |
end |
|
97 |
end |
|
98 |
end |
|
84 | 99 |
end |
app/views/settings/_display.rhtml | ||
---|---|---|
15 | 15 | |
16 | 16 |
<p><%= setting_check_box :gravatar_enabled %></p> |
17 | 17 | |
18 |
<p><%= setting_select :gravatar_default, [["Wavatars", 'wavatar'], ["Identicons", 'identicon'], ["Monster ids", 'monsterid'], ["Retro", "retro"]], :blank => :label_none %></p>
|
|
18 |
<p><%= setting_select :gravatar_default, default_gravatar_options, :blank => :label_none %></p>
|
|
19 | 19 |
</div> |
20 | 20 | |
21 | 21 |
<%= submit_tag l(:button_save) %> |
lib/redmine.rb | ||
---|---|---|
230 | 230 |
format.register :textile, Redmine::WikiFormatting::Textile::Formatter, Redmine::WikiFormatting::Textile::Helper |
231 | 231 |
end |
232 | 232 | |
233 |
Redmine::GravatarManager.map do |options| |
|
234 |
options.register 'Wavatars', :wavatar |
|
235 |
options.register 'Identicons', :identicon |
|
236 |
options.register 'Monster ids', :monsterid |
|
237 |
options.register 'Retro', :retro |
|
238 |
end |
|
239 | ||
233 | 240 |
ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler |
lib/redmine/gravatar_manager.rb | ||
---|---|---|
1 |
module Redmine |
|
2 |
module GravatarManager |
|
3 |
@map = [] |
|
4 | ||
5 |
def self.map |
|
6 |
yield self |
|
7 |
end |
|
8 | ||
9 |
def self.register(name, url_or_file_name, options = nil) |
|
10 |
raise ArgumentError, "gravatar name '#{name}' is already taken" if @map.assoc(name.to_s) |
|
11 |
@map << [name.to_s, url_or_file_name.to_s, options] |
|
12 |
end |
|
13 | ||
14 |
def self.registered_gravatars |
|
15 |
@map.dup |
|
16 |
end |
|
17 |
end |
|
18 |
end |
lib/redmine/plugin.rb | ||
---|---|---|
270 | 270 |
Redmine::WikiFormatting.register(name, formatter, helper) |
271 | 271 |
end |
272 | 272 | |
273 |
# Registers an option for the default gravatar |
|
274 |
# * +label+ - human-readable name |
|
275 |
# * +url_or_file_name+ - URL (or file name) for the image file. |
|
276 |
def default_gravatar(label, url_or_file_name) |
|
277 |
Redmine::GravatarManager.register(label, url_or_file_name, :plugin => self.id) |
|
278 |
end |
|
279 | ||
273 | 280 |
# Returns +true+ if the plugin can be configured. |
274 | 281 |
def configurable? |
275 | 282 |
settings && settings.is_a?(Hash) && !settings[:partial].blank? |