From: Tom Hughes Date: Sat, 2 Feb 2013 17:48:56 +0000 (+0000) Subject: Make notes RSS feeds work X-Git-Tag: live~5072^2~40 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/ff73d1225554de6f6ec2aee7bcd9faa527c0d552?hp=16a0f14f4aa3cad2d38fe35d61afa1f6a236302b Make notes RSS feeds work --- diff --git a/app/views/notes/_description.html.erb b/app/views/notes/_description.html.erb index 435f263c6..761b69ea2 100644 --- a/app/views/notes/_description.html.erb +++ b/app/views/notes/_description.html.erb @@ -1,7 +1,7 @@
<% description.comments.each do |comment| -%>
- <% if comment.author.nil> -%> + <% if comment.author.nil? -%>
<%= t "note.description.#{comment.event}_at", :when => friendly_date(comment.created_at) %>
<% else -%>
<%= t "note.description.#{comment.event}_at_by", :when => friendly_date(comment.created_at), :user => note_author(comment.author, :only_path => false) %>
diff --git a/config/initializers/action_view.rb b/config/initializers/action_view.rb new file mode 100644 index 000000000..1789ec199 --- /dev/null +++ b/config/initializers/action_view.rb @@ -0,0 +1,32 @@ +# +# Make :formats work when rendering one partial from another +# +# Taken from https://github.com/rails/rails/pull/6626 +# +module ActionView + class AbstractRenderer #:nodoc: + def prepend_formats(formats) + formats = Array(formats) + return if formats.empty? + @lookup_context.formats = formats | @lookup_context.formats + end + end + + class PartialRenderer + def setup_with_formats(context, options, block) + prepend_formats(options[:formats]) + setup_without_formats(context, options, block) + end + + alias_method_chain :setup, :formats + end + + class TemplateRenderer + def render_with_formats(context, options) + prepend_formats(options[:formats]) + render_without_formats(context, options) + end + + alias_method_chain :render, :formats + end +end diff --git a/lib/nominatim.rb b/lib/nominatim.rb index 5b1c7ac32..1d2037d8d 100644 --- a/lib/nominatim.rb +++ b/lib/nominatim.rb @@ -1,4 +1,6 @@ module Nominatim + extend ActionView::Helpers::NumberHelper + def self.describe_location(lat, lon, zoom = nil, language = nil) zoom = zoom || 14 language = language || request.user_preferred_languages.join(',')