@note = Note.create(:lat => lat, :lon => lon)
raise OSM::APIBadUserInput.new("The note is outside this world") unless @note.in_world?
- #TODO: move this into a helper function
- begin
- url = "http://nominatim.openstreetmap.org/reverse?lat=" + lat.to_s + "&lon=" + lon.to_s + "&zoom=16"
- response = REXML::Document.new(Net::HTTP.get(URI.parse(url)))
-
- if result = response.get_text("reversegeocode/result")
- @note.nearby_place = result.to_s
- else
- @note.nearby_place = "unknown"
- end
- rescue Exception => err
- @note.nearby_place = "unknown"
- end
-
# Save the note
@note.save!
json.comment_url comment_note_url(note, :format => params[:format])
json.close_url close_note_url(note, :format => params[:format])
json.date_created note.created_at
- json.nearby note.nearby_place
json.status note.status
json.closed_at note.closed_at if note.status == "closed"
xml.item do
+ location_string = Rails.cache.fetch("location_description_#{note.lat}_#{note.lon}_#{locale}") do
+ describe_location note.lat, note.lon, 14, locale
+ end
if note.status == "closed"
- xml.title t('note.rss.closed', :place => note.nearby_place)
+ xml.title t('note.rss.closed', :place => location_string)
elsif note.comments.length > 1
- xml.title t('note.rss.comment', :place => note.nearby_place)
+ xml.title t('note.rss.comment', :place => location_string)
else
- xml.title t('note.rss.new', :place => note.nearby_place)
+ xml.title t('note.rss.new', :place => location_string)
end
xml.link browse_note_url(note)
xml.guid note_url(note)
xml.description render(:partial => "description", :object => note, :formats => [ :html ])
- xml.author note.author_name
+ xml.author note.comments.first.author_name
xml.pubDate note.updated_at.to_s(:rfc822)
xml.geo :lat, note.lat
xml.geo :long, note.lon
xml.comment_url comment_note_url(note, :format => params[:format])
xml.close_url close_note_url(note, :format => params[:format])
xml.date_created note.created_at
- xml.nearby note.nearby_place
xml.status note.status
if note.status == "closed"
xml.link url_for(:controller => "site", :action => "index", :only_path => false)
@comments.each do |comment|
+ location_string = Rails.cache.fetch("location_description_#{comment.note.lat}_#{comment.note.lon}_#{locale}") do
+ describe_location comment.note.lat, comment.note.lon, 14, locale
+ end
xml.item do
if comment.event == "closed"
- xml.title t('note.rss.closed', :place => comment.note.nearby_place)
+ xml.title t('note.rss.closed', :place => location_string)
elsif comment.event == "commented"
- xml.title t('note.rss.comment', :place => comment.note.nearby_place)
+ xml.title t('note.rss.comment', :place => location_string)
elsif comment.event == "opened"
- xml.title t('note.rss.new', :place => comment.note.nearby_place)
+ xml.title t('note.rss.new', :place => location_string)
else
xml.title "unknown event"
end
--- /dev/null
+class DropNearbyPlaceFromNotes < ActiveRecord::Migration
+ def up
+ remove_column :notes, :nearby_place
+ end
+
+ def down
+ add_column :notes, :nearby_place, :string
+ end
+end