Index: app/helpers/queries_helper.rb =================================================================== --- app/helpers/queries_helper.rb (revision 2552) +++ app/helpers/queries_helper.rb (working copy) @@ -30,7 +30,7 @@ def column_content(column, issue) if column.is_a?(QueryCustomFieldColumn) cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id} - show_value(cv) + show_value_plain(cv) else value = issue.send(column.name) if value.is_a?(Date) Index: app/helpers/timelog_helper.rb =================================================================== --- app/helpers/timelog_helper.rb (revision 2552) +++ app/helpers/timelog_helper.rb (working copy) @@ -93,7 +93,7 @@ entry.hours.to_s.gsub('.', decimal_separator), entry.comments ] - fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) } + fields += custom_fields.collect {|f| show_value_plain(entry.custom_value_for(f)) } csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } end Index: app/helpers/custom_fields_helper.rb =================================================================== --- app/helpers/custom_fields_helper.rb (revision 2552) +++ app/helpers/custom_fields_helper.rb (working copy) @@ -61,12 +61,34 @@ def custom_field_tag_with_label(name, custom_value) custom_field_label_tag(name, custom_value) + custom_field_tag(name, custom_value) end + + # Return a clean URL for a given custom field value + def url_format(custom_value) + url = custom_value.custom_field.url.strip + return false unless url.length > 0 - # Return a string used to display a custom value + formatted_value = format_value(custom_value.value, custom_value.custom_field.field_format) + while (url.sub!(/__VALUE__/, h(formatted_value.strip))) + end + return url + end + + # Return a formatted string used to display a custom value (including link if URL defined on custom_field) def show_value(custom_value) return "" unless custom_value - format_value(custom_value.value, custom_value.custom_field.field_format) + formatted_value = format_value(custom_value.value, custom_value.custom_field.field_format) + if (value = url_format(custom_value)) + return link_to formatted_value, value, :target=>'_blank' + else + return h(format_value(custom_value.value, custom_value.custom_field.field_format)) + end end + + # Return an escaped string used to display a custom value + def show_value_plain(custom_value) + return "" unless custom_value + return h(format_value(custom_value.value, custom_value.custom_field.field_format)) + end # Return a string used to display a custom value def format_value(value, field_format) Index: app/views/custom_fields/_form.rhtml =================================================================== --- app/views/custom_fields/_form.rhtml (revision 2552) +++ app/views/custom_fields/_form.rhtml (working copy) @@ -8,6 +8,7 @@ p_regexp = $("custom_field_regexp"); p_values = $("custom_field_possible_values"); p_searchable = $("custom_field_searchable"); + p_url = $("custom_field_url"); p_default = $("custom_field_default_value"); p_default.setAttribute('type','text'); @@ -65,6 +66,8 @@ :rows => 15 %>
<%= l(:text_custom_field_possible_values_info) %>

<%= @custom_field.field_format == 'bool' ? f.check_box(:default_value) : f.text_field(:default_value) %>

+

<%= f.text_field :url, :size => 60 %> +
<%= l(:text_custom_field_url_info) %>

Index: app/views/mailer/_issue_text_plain.rhtml =================================================================== --- app/views/mailer/_issue_text_plain.rhtml (revision 2552) +++ app/views/mailer/_issue_text_plain.rhtml (working copy) @@ -7,7 +7,7 @@ <%=l(:field_assigned_to)%>: <%= issue.assigned_to %> <%=l(:field_category)%>: <%= issue.category %> <%=l(:field_fixed_version)%>: <%= issue.fixed_version %> -<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value(c) %> +<% issue.custom_values.each do |c| %><%= c.custom_field.name %>: <%= show_value_plain(c) %> <% end %> <%= issue.description %> Index: app/views/projects/show.rhtml =================================================================== --- app/views/projects/show.rhtml (revision 2552) +++ app/views/projects/show.rhtml (working copy) @@ -10,7 +10,7 @@ <% end %> <% @project.custom_values.each do |custom_value| %> <% if !custom_value.value.empty? %> -
  • <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
  • +
  • <%= custom_value.custom_field.name%>: <%= show_value(custom_value) %>
  • <% end %> <% end %> Index: app/views/account/show.rhtml =================================================================== --- app/views/account/show.rhtml (revision 2552) +++ app/views/account/show.rhtml (working copy) @@ -11,7 +11,7 @@ <% end %> <% for custom_value in @custom_values %> <% if !custom_value.value.empty? %> -
  • <%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %>
  • +
  • <%= custom_value.custom_field.name%>: <%= show_value(custom_value) %>
  • <% end %> <% end %>
  • <%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %>
  • Index: app/views/issues/show.rhtml =================================================================== --- app/views/issues/show.rhtml (revision 2552) +++ app/views/issues/show.rhtml (working copy) @@ -46,7 +46,7 @@ <% n = 0 -%> <% @issue.custom_values.each do |value| -%> - <%=h value.custom_field.name %>:<%= simple_format(h(show_value(value))) %> + <%=h value.custom_field.name %>:<%= simple_format(show_value(value)) %> <% n = n + 1 if (n > 1) n = 0 %> Index: config/locales/en.yml =================================================================== --- config/locales/en.yml (revision 2552) +++ config/locales/en.yml (working copy) @@ -755,6 +755,7 @@ text_repository_usernames_mapping: "Select or update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." text_diff_truncated: '... This diff was truncated because it exceeds the maximum size that can be displayed.' text_custom_field_possible_values_info: 'One line for each value' + text_custom_field_url_info: '(__VALUE__ is a placeholder for each of the field values, eg. http://www.google.com/search?q=__VALUE__)' default_role_manager: Manager default_role_developper: Developer Index: db/migrate/20090304184821_add_custom_fields_url.rb =================================================================== --- db/migrate/20090304184821_add_custom_fields_url.rb (revision 0) +++ db/migrate/20090304184821_add_custom_fields_url.rb (revision 0) @@ -0,0 +1,9 @@ +class AddCustomFieldsUrl < ActiveRecord::Migration + def self.up + add_column :custom_fields, :url, :string, :limit=>255, :default=>"", :null=>false + end + + def self.down + remove_column :custom_fields, :url + end +end