From: Tom Hughes Date: Sat, 21 May 2011 16:22:31 +0000 (+0100) Subject: Mass rename of "bugs" as "notes" for increased user friendliness X-Git-Tag: live~5659^2~151 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e3b8b8933044104bb515d34c3d36851caba78ac7?hp=bb490aca81d8063a9ad8dd8f1a023c709c096792 Mass rename of "bugs" as "notes" for increased user friendliness --- diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb index f6bd89d4d..2036e4f10 100644 --- a/app/controllers/browse_controller.rb +++ b/app/controllers/browse_controller.rb @@ -80,11 +80,11 @@ class BrowseController < ApplicationController render :action => "not_found", :status => :not_found end - def bug - @type = "bug" - @bug = MapBug.find(params[:id]) - @next = MapBug.find(:first, :order => "id ASC", :conditions => [ "status != 'hidden' AND id > :id", { :id => @bug.id }] ) - @prev = MapBug.find(:first, :order => "id DESC", :conditions => [ "status != 'hidden' AND id < :id", { :id => @bug.id }] ) + def note + @type = "note" + @note = Note.find(params[:id]) + @next = Note.find(:first, :order => "id ASC", :conditions => [ "status != 'hidden' AND id > :id", { :id => @note.id }] ) + @prev = Note.find(:first, :order => "id DESC", :conditions => [ "status != 'hidden' AND id < :id", { :id => @note.id }] ) rescue ActiveRecord::RecordNotFound render :action => "not_found", :status => :not_found end diff --git a/app/controllers/map_bugs_controller.rb b/app/controllers/note_controller.rb similarity index 59% rename from app/controllers/map_bugs_controller.rb rename to app/controllers/note_controller.rb index 28d22c3f3..fb68280b3 100644 --- a/app/controllers/map_bugs_controller.rb +++ b/app/controllers/note_controller.rb @@ -1,4 +1,4 @@ -class MapBugsController < ApplicationController +class NoteController < ApplicationController layout 'site', :only => [:mine] @@ -36,17 +36,17 @@ class MapBugsController < ApplicationController limit = getLimit conditions = closedCondition - check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_BUG_REQUEST_AREA) + check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_NOTE_REQUEST_AREA) - @bugs = MapBug.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "updated_at DESC", :limit => limit, :conditions => conditions) + @notes = Note.find_by_area(@min_lat, @min_lon, @max_lat, @max_lon, :include => :comments, :order => "updated_at DESC", :limit => limit, :conditions => conditions) respond_to do |format| - format.html {render :template => 'map_bugs/list.rjs', :content_type => "text/javascript"} - format.rss {render :template => 'map_bugs/list.rss'} + format.html {render :template => 'note/list.rjs', :content_type => "text/javascript"} + format.rss {render :template => 'note/list.rss'} format.js - format.xml {render :template => 'map_bugs/list.xml'} - format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) } - format.gpx {render :template => 'map_bugs/list.gpx'} + format.xml {render :template => 'note/list.xml'} + format.json { render :json => @notes.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) } + format.gpx {render :template => 'note/list.gpx'} end end @@ -62,9 +62,9 @@ class MapBugsController < ApplicationController name = "NoName" name = params['name'] if params['name'] - #Include in a transaction to ensure that there is always a map_bug_comment for every map_bug - MapBug.transaction do - @bug = MapBug.create_bug(lat, lon) + #Include in a transaction to ensure that there is always a note_comment for every note + Note.transaction do + @note = Note.create_bug(lat, lon) #TODO: move this into a helper function begin @@ -72,17 +72,17 @@ class MapBugsController < ApplicationController response = REXML::Document.new(Net::HTTP.get(URI.parse(url))) if result = response.get_text("reversegeocode/result") - @bug.nearby_place = result.to_s + @note.nearby_place = result.to_s else - @bug.nearby_place = "unknown" + @note.nearby_place = "unknown" end rescue Exception => err - @bug.nearby_place = "unknown" + @note.nearby_place = "unknown" end - @bug.save + @note.save - add_comment(@bug, comment, name, "opened") + add_comment(@note, comment, name, "opened") end render_ok @@ -97,12 +97,12 @@ class MapBugsController < ApplicationController id = params['id'].to_i - bug = MapBug.find_by_id(id) - raise OSM::APINotFoundError unless bug - raise OSM::APIAlreadyDeletedError unless bug.visible + note = Note.find(id) + raise OSM::APINotFoundError unless note + raise OSM::APIAlreadyDeletedError unless note.visible - MapBug.transaction do - bug_comment = add_comment(bug, params['text'], name, "commented") + Note.transaction do + add_comment(note, params['text'], name, "commented") end render_ok @@ -115,13 +115,13 @@ class MapBugsController < ApplicationController name = "NoName" name = params['name'] if params['name'] - bug = MapBug.find_by_id(id) - raise OSM::APINotFoundError unless bug - raise OSM::APIAlreadyDeletedError unless bug.visible + note = Note.find_by_id(id) + raise OSM::APINotFoundError unless note + raise OSM::APIAlreadyDeletedError unless note.visible - MapBug.transaction do - bug.close_bug - add_comment(bug, :nil, name, "closed") + Note.transaction do + note.close + add_comment(note, :nil, name, "closed") end render_ok @@ -138,37 +138,37 @@ class MapBugsController < ApplicationController bbox = bbox.split(',') @min_lon, @min_lat, @max_lon, @max_lat = sanitise_boundaries(bbox) - check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_BUG_REQUEST_AREA) + check_boundaries(@min_lon, @min_lat, @max_lon, @max_lat, MAX_NOTE_REQUEST_AREA) conditions = cond_merge conditions, [OSM.sql_for_area(@min_lat, @min_lon, @max_lat, @max_lon)] end - @comments = MapBugComment.find(:all, :limit => limit, :order => "created_at DESC", :joins => :map_bug, :include => :map_bug, :conditions => conditions) - render :template => 'map_bugs/rss.rss' + @comments = NoteComment.find(:all, :limit => limit, :order => "created_at DESC", :joins => :note, :include => :note, :conditions => conditions) + render :template => 'note/rss.rss' end def read - @bug = MapBug.find(params['id']) - raise OSM::APINotFoundError unless @bug - raise OSM::APIAlreadyDeletedError unless @bug.visible + @note = Note.find(params['id']) + raise OSM::APINotFoundError unless @note + raise OSM::APIAlreadyDeletedError unless @note.visible respond_to do |format| format.rss format.xml - format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) } + format.json { render :json => @note.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) } format.gpx end end def delete - bug = MapBug.find(params['id']) - raise OSM::APINotFoundError unless @bug - raise OSM::APIAlreadyDeletedError unless @bug.visible - - MapBug.transaction do - bug.status = "hidden" - bug.save - add_comment(bug,:nil,name,"hidden") + note = note.find(params['id']) + raise OSM::APINotFoundError unless note + raise OSM::APIAlreadyDeletedError unless note.visible + + Note.transaction do + note.status = "hidden" + note.save + add_comment(note, :nil, name, "hidden") end render :text => "ok\n", :content_type => "text/html" @@ -178,20 +178,18 @@ class MapBugsController < ApplicationController raise OSM::APIBadUserInput.new("No query string was given") unless params['q'] limit = getLimit conditions = closedCondition - conditions = cond_merge conditions, ['map_bug_comment.body ~ ?', params['q']] + conditions = cond_merge conditions, ['note_comments.body ~ ?', params['q']] #TODO: There should be a better way to do this. CloseConditions are ignored at the moment - bugs2 = MapBug.find(:all, :limit => limit, :order => "updated_at DESC", :joins => :comments, :include => :comments, - :conditions => conditions) - @bugs = bugs2.uniq + @notes = Note.find(:all, :limit => limit, :order => "updated_at DESC", :joins => :comments, :include => :comments, :conditions => conditions).uniq respond_to do |format| - format.html {render :template => 'map_bugs/list.rjs', :content_type => "text/javascript"} - format.rss {render :template => 'map_bugs/list.rss'} + format.html {render :template => 'note/list.rjs', :content_type => "text/javascript"} + format.rss {render :template => 'note/list.rss'} format.js - format.xml {render :template => 'map_bugs/list.xml'} - format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) } - format.gpx {render :template => 'map_bugs/list.gpx'} + format.xml {render :template => 'note/list.xml'} + format.json { render :json => @notes.to_json(:methods => [:lat, :lon], :only => [:id, :status, :created_at], :include => { :comments => { :only => [:author_name, :created_at, :body]}}) } + format.gpx {render :template => 'note/list.gpx'} end end @@ -201,7 +199,7 @@ class MapBugsController < ApplicationController if @user2 if @user2.data_public? or @user2 == @user - conditions = ['map_bug_comment.author_id = ?', @user2.id] + conditions = ['note_comments.author_id = ?', @user2.id] else conditions = ['false'] end @@ -217,20 +215,20 @@ class MapBugsController < ApplicationController user_link = render_to_string :partial => "user", :object => @user2 end - @title = t 'bugs.user.title_user', :user => @user2.display_name - @heading = t 'bugs.user.heading_user', :user => @user2.display_name - @description = t 'bugs.user.description_user', :user => user_link + @title = t 'note.mine.title', :user => @user2.display_name + @heading = t 'note.mine.heading', :user => @user2.display_name + @description = t 'note.mine.description', :user => user_link @page = (params[:page] || 1).to_i @page_size = 10 - @bugs = MapBug.find(:all, - :include => [:comments, {:comments => :author}], - :joins => :comments, - :order => "updated_at DESC", - :conditions => conditions, - :offset => (@page - 1) * @page_size, - :limit => @page_size).uniq + @notes = Note.find(:all, + :include => [:comments, {:comments => :author}], + :joins => :comments, + :order => "updated_at DESC", + :conditions => conditions, + :offset => (@page - 1) * @page_size, + :limit => @page_size).uniq end private @@ -260,8 +258,8 @@ private if output_js == :true render :text => "osbResponse();", :content_type => "text/javascript" else - render :text => "ok " + @bug.id.to_s + "\n", :content_type => "text/html" if @bug - render :text => "ok\n", :content_type => "text/html" unless @bug + render :text => "ok " + @note.id.to_s + "\n", :content_type => "text/html" if @note + render :text => "ok\n", :content_type => "text/html" unless @note end end @@ -286,24 +284,24 @@ private return conditions end - def add_comment(bug, comment, name,event) - bug_comment = bug.comments.create(:visible => true, :event => event) - bug_comment.body = comment unless comment == :nil + def add_comment(note, text, name, event) + comment = note.comments.create(:visible => true, :event => event) + comment.body = text unless text == :nil if @user - bug_comment.author_id = @user.id - bug_comment.author_name = @user.display_name + comment.author_id = @user.id + comment.author_name = @user.display_name else - bug_comment.author_ip = request.remote_ip - bug_comment.author_name = name + " (a)" + comment.author_ip = request.remote_ip + comment.author_name = name + " (a)" end - bug_comment.save - bug.save + comment.save + note.save sent_to = Set.new - bug.comments.each do | cmt | + note.comments.each do | cmt | if cmt.author unless sent_to.include?(cmt.author) - Notifier.deliver_bug_comment_notification(bug_comment, cmt.author) unless cmt.author == @user + Notifier.deliver_note_comment_notification(note_comment, cmt.author) unless cmt.author == @user sent_to.add(cmt.author) end end diff --git a/app/models/map_bug.rb b/app/models/note.rb similarity index 80% rename from app/models/map_bug.rb rename to app/models/note.rb index 7094bfe5e..e36884ec1 100644 --- a/app/models/map_bug.rb +++ b/app/models/note.rb @@ -1,8 +1,8 @@ -class MapBug < ActiveRecord::Base +class Note < ActiveRecord::Base include GeoRecord - has_many :comments, :class_name => "MapBugComment", - :foreign_key => :bug_id, + has_many :comments, :class_name => "NoteComment", + :foreign_key => :note_id, :order => :created_at, :conditions => "visible = true AND body IS NOT NULL" @@ -14,13 +14,13 @@ class MapBug < ActiveRecord::Base validates_inclusion_of :status, :in => ["open", "closed", "hidden"] def self.create_bug(lat, lon) - bug = MapBug.new(:lat => lat, :lon => lon, :status => "open") - raise OSM::APIBadUserInput.new("The node is outside this world") unless bug.in_world? + note = Note.new(:lat => lat, :lon => lon, :status => "open") + raise OSM::APIBadUserInput.new("The note is outside this world") unless note.in_world? - return bug + return note end - def close_bug + def close self.status = "closed" self.closed_at = Time.now.getutc diff --git a/app/models/map_bug_comment.rb b/app/models/note_comment.rb similarity index 77% rename from app/models/map_bug_comment.rb rename to app/models/note_comment.rb index 9a130dd34..5e04723bd 100644 --- a/app/models/map_bug_comment.rb +++ b/app/models/note_comment.rb @@ -1,7 +1,5 @@ -class MapBugComment < ActiveRecord::Base - set_table_name 'map_bug_comment' - - belongs_to :map_bug, :foreign_key => :bug_id +class NoteComment < ActiveRecord::Base + belongs_to :note, :foreign_key => :bug_id belongs_to :author, :class_name => "User", :foreign_key => :author_id validates_inclusion_of :event, :in => [ "opened", "closed", "reopened", "commented", "hidden" ] diff --git a/app/models/notifier.rb b/app/models/notifier.rb index e8c9259cb..f025da7b1 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -95,20 +95,20 @@ class Notifier < ActionMailer::Base body :friend => friend end - def bug_comment_notification(bug_comment, recipient) + def note_comment_notification(comment, recipient) common_headers recipient - owner = (recipient == bug_comment.map_bug.author); - subject I18n.t('notifier.map_bug_plain.subject_own', :commenter => bug_comment.author_name) if owner - subject I18n.t('notifier.map_bug_plain.subject_other', :commenter => bug_comment.author_name) unless owner + owner = (recipient == comment.note.author); + subject I18n.t('notifier.note_plain.subject_own', :commenter => comment.author_name) if owner + subject I18n.t('notifier.note_plain.subject_other', :commenter => comment.author_name) unless owner - body :bugurl => url_for(:host => SERVER_URL, - :controller => "browse", - :action => "bug", - :id => bug_comment.bug_id), - :place => bug_comment.map_bug.nearby_place, - :comment => bug_comment.body, + body :nodeurl => url_for(:host => SERVER_URL, + :controller => "browse", + :action => "note", + :id => comment.note_id), + :place => comment.note.nearby_place, + :comment => comment.body, :owner => owner, - :commenter => bug_comment.author_name + :commenter => comment.author_name end private diff --git a/app/views/browse/_map.html.erb b/app/views/browse/_map.html.erb index d8980f2a2..dd4ec74df 100644 --- a/app/views/browse/_map.html.erb +++ b/app/views/browse/_map.html.erb @@ -38,7 +38,7 @@ $("area_larger_map").href = '/?minlon='+minlon+'&minlat='+minlat+'&maxlon='+maxlon+'&maxlat='+maxlat+'&box=yes'; $("area_larger_map").innerHTML = "<%= t 'browse.map.larger.area' %>"; - <% elsif map.instance_of? MapBug %> + <% elsif map.instance_of? Note %> var centre = new OpenLayers.LonLat(<%= map.lon %>, <%= map.lat %>); setMapCenter(centre, 16); diff --git a/app/views/browse/bug.html.erb b/app/views/browse/bug.html.erb deleted file mode 100644 index 698532290..000000000 --- a/app/views/browse/bug.html.erb +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - <%= render :partial => "map", :object => @bug %> - -
-

- <% if @bug.status == "closed" %> - <%= image_tag("closed_bug_marker.png", :alt => 'closed') %> - <%= t 'browse.bug.closed_title', :bug_name => @bug.id %> - <% else %> - <%= image_tag("open_bug_marker.png", :alt => 'open') %> - <%= t 'browse.bug.open_title', :bug_name => @bug.id %> - <% end %> -

-
- <%= render :partial => "navigation" %> -
- - - - - - - - - - <% if @bug.status == "closed" %> - - - - - <% end %> - - - <% if @bug.author.nil? %> - - <% else %> - - <% end %> - - - - - - - - - -
<%= t 'browse.bug.created_at' %><%= l @bug.created_at %>
<%= t 'browse.bug.edited_at' %><%= l @bug.updated_at %>
<%= t 'browse.bug.closed_at' %><%= l @bug.closed_at %>
<%= t 'browse.bug.opened_by' %> <%= @bug.author_name %> <%= link_to h(@bug.author_name), :controller => "user", :action => "view", :display_name => @bug.author_name %>
<%= t 'browse.bug.description' %><%= h(@bug.comments.first.body) %>
<%= t 'browse.node_details.coordinates' %>
<%= link_to ("#{number_with_delimiter(@bug.lat)}, #{number_with_delimiter(@bug.lon)}"), {:controller => 'site', :action => 'index', :lat => h(@bug.lat), :lon => h(@bug.lon), :zoom => "18"} %>
- -
- - <% if @bug.comments.length > 1 %> - - - - - - - <% @bug.comments[1..-1].each do |bug_comment| %> - - - - - - <% end %> -
<%= t 'browse.bug.comment_by' %> <%= t 'browse.bug.comment' %> <%= t 'browse.bug.date' %>
- <% if bug_comment.user.nil? %> - <%= bug_comment.author_name %> - <% else %> - <%= link_to h(bug_comment.user.display_name), :controller => "user", :action => "view", :display_name => bug_comment.user.display_name %> - <% end %> - <%= h(bug_comment.body) %> <%= l bug_comment.created_at %>
- <% end %> - -
-
diff --git a/app/views/browse/note.html.erb b/app/views/browse/note.html.erb new file mode 100644 index 000000000..5c42fddd6 --- /dev/null +++ b/app/views/browse/note.html.erb @@ -0,0 +1,83 @@ + + + + + + + + + <%= render :partial => "map", :object => @note %> + +
+

+ <% if @note.status == "closed" %> + <%= image_tag("closed_note_marker.png", :alt => 'closed') %> + <%= t 'browse.note.closed_title', :note_name => @note.id %> + <% else %> + <%= image_tag("open_note_marker.png", :alt => 'open') %> + <%= t 'browse.note.open_title', :note_name => @note.id %> + <% end %> +

+
+ <%= render :partial => "navigation" %> +
+ + + + + + + + + + <% if @note.status == "closed" %> + + + + + <% end %> + + + <% if @note.author.nil? %> + + <% else %> + + <% end %> + + + + + + + + + +
<%= t 'browse.note.created_at' %><%= l @note.created_at %>
<%= t 'browse.note.edited_at' %><%= l @note.updated_at %>
<%= t 'browse.note.closed_at' %><%= l @note.closed_at %>
<%= t 'browse.note.opened_by' %> <%= @note.author_name %> <%= link_to h(@note.author_name), :controller => "user", :action => "view", :display_name => @note.author_name %>
<%= t 'browse.note.description' %><%= h(@note.comments.first.body) %>
<%= t 'browse.node_details.coordinates' %>
<%= link_to ("#{number_with_delimiter(@note.lat)}, #{number_with_delimiter(@note.lon)}"), {:controller => 'site', :action => 'index', :lat => h(@note.lat), :lon => h(@note.lon), :zoom => "18"} %>
+ +
+ + <% if @note.comments.length > 1 %> + + + + + + + <% @note.comments[1..-1].each do |comment| %> + + + + + + <% end %> +
<%= t 'browse.note.comment_by' %> <%= t 'browse.note.comment' %> <%= t 'browse.note.date' %>
+ <% if comment.author.nil? %> + <%= comment.author_name %> + <% else %> + <%= link_to h(comment.author.display_name), :controller => "user", :action => "view", :display_name => comment.author.display_name %> + <% end %> + <%= h(comment.body) %> <%= l comment.created_at %>
+ <% end %> + +
+
diff --git a/app/views/map_bugs/_bug.gpx.builder b/app/views/map_bugs/_bug.gpx.builder deleted file mode 100644 index 18a84bac7..000000000 --- a/app/views/map_bugs/_bug.gpx.builder +++ /dev/null @@ -1,15 +0,0 @@ -xml.wpt("lon" => bug.lon, "lat" => bug.lat) do - xml.desc do - xml.cdata! bug.flatten_comment("
") - end - - xml.extension do - if bug.status = "open" - xml.closed "0" - else - xml.closed "1" - end - - xml.id bug.id - end -end diff --git a/app/views/map_bugs/_bug.rss.builder b/app/views/map_bugs/_bug.rss.builder deleted file mode 100644 index e9f1420c1..000000000 --- a/app/views/map_bugs/_bug.rss.builder +++ /dev/null @@ -1,18 +0,0 @@ -xml.item do - if bug.status == "closed" - xml.title t('bugs.rss.closed', :place => bug.nearby_place) - elsif bug.comments.length > 1 - xml.title t('bugs.rss.comment', :place => bug.nearby_place) - else - xml.title t('bugs.rss.new', :place => bug.nearby_place) - end - - xml.link url_for(:controller => "browse", :action => "bug", :id => bug.id, :only_path => false) - xml.guid url_for(:controller => "map_bugs", :action => "read", :id => bug.id, :only_path => false) - xml.description htmlize(bug.flatten_comment("

")) - xml.author bug.author_name - xml.pubDate bug.updated_at.to_s(:rfc822) - xml.geo :lat, bug.lat - xml.geo :long, bug.lon - xml.georss :point, "#{bug.lat} #{bug.lon}" -end diff --git a/app/views/map_bugs/_bug.xml.builder b/app/views/map_bugs/_bug.xml.builder deleted file mode 100644 index 1219f3d74..000000000 --- a/app/views/map_bugs/_bug.xml.builder +++ /dev/null @@ -1,21 +0,0 @@ -xml.bug("lon" => bug.lon, "lat" => bug.lat) do - xml.id bug.id - xml.date_created bug.created_at - xml.nearby bug.nearby_place - xml.status bug.status - - if bug.status == "closed" - xml.date_closed bug.closed_at - end - - xml.comments do - bug.comments.each do |comment| - xml.comment do - xml.date comment.created_at - xml.uid comment.author_id unless comment.author_id.nil? - xml.user comment.author_name - xml.text comment.body - end - end - end -end diff --git a/app/views/map_bugs/list.rjs b/app/views/map_bugs/list.rjs deleted file mode 100644 index 7268ded74..000000000 --- a/app/views/map_bugs/list.rjs +++ /dev/null @@ -1,6 +0,0 @@ -@bugs.each do |bug| - page.call "putAJAXMarker", - bug.id, bug.lon, bug.lat, - bug.flatten_comment("
"), - bug.status == "open" ? 0 : 1 -end diff --git a/app/views/map_bugs/list.xml.builder b/app/views/map_bugs/list.xml.builder deleted file mode 100644 index 16be0598b..000000000 --- a/app/views/map_bugs/list.xml.builder +++ /dev/null @@ -1,3 +0,0 @@ -xml.instruct! - -xml << render(:partial => "bug", :collection => @bugs) diff --git a/app/views/map_bugs/mine.html.erb b/app/views/map_bugs/mine.html.erb deleted file mode 100644 index d837c7829..000000000 --- a/app/views/map_bugs/mine.html.erb +++ /dev/null @@ -1,37 +0,0 @@ -

<%= @heading %>

-

<%= @description %>

- -<%= render :partial => 'bugs_paging_nav' %> - - - - - - - - - - -<% @bugs.each do |bug| %> - bgcolor="#EEEEEE"<% end %>> - - - <% if bug.author.nil? %> - - <% else %> - - <% end %> - - - - -<% end %> -
<%= t'bugs.user.id' %><%= t'changeset.changesets.user' %><%= t'changeset.changesets.comment' %><%= t'changeset.changesets.saved_at' %><%= t'bugs.user.last_changed' %>
- <% if bug.status == "closed" %> - <%= image_tag("closed_bug_marker.png", :alt => 'closed') %> - <% else %> - <%= image_tag("open_bug_marker.png", :alt => 'open') %> - <% end %> - <%= link_to bug.id.to_s, :controller => "browse", :action => "bug", :id => bug.id %> <%= bug.author_name %> <%= link_to h(bug.author_name), :controller => "user", :action => "view", :display_name => bug.author_name %> <%= htmlize bug.comments.first.body %> <%= l bug.created_at %><%= l bug.updated_at %>
- -<%= render :partial => 'bugs_paging_nav' %> diff --git a/app/views/map_bugs/read.xml.builder b/app/views/map_bugs/read.xml.builder deleted file mode 100644 index 82fe04c4b..000000000 --- a/app/views/map_bugs/read.xml.builder +++ /dev/null @@ -1,3 +0,0 @@ -xml.instruct! - -xml << render(:partial => "bug", :object => @bug) diff --git a/app/views/note/_note.gpx.builder b/app/views/note/_note.gpx.builder new file mode 100644 index 000000000..91c0cbd98 --- /dev/null +++ b/app/views/note/_note.gpx.builder @@ -0,0 +1,15 @@ +xml.wpt("lon" => note.lon, "lat" => note.lat) do + xml.desc do + xml.cdata! note.flatten_comment("
") + end + + xml.extension do + if note.status = "open" + xml.closed "0" + else + xml.closed "1" + end + + xml.id note.id + end +end diff --git a/app/views/note/_note.rss.builder b/app/views/note/_note.rss.builder new file mode 100644 index 000000000..856b4cc62 --- /dev/null +++ b/app/views/note/_note.rss.builder @@ -0,0 +1,18 @@ +xml.item do + if note.status == "closed" + xml.title t('note.rss.closed', :place => note.nearby_place) + elsif note.comments.length > 1 + xml.title t('note.rss.comment', :place => note.nearby_place) + else + xml.title t('note.rss.new', :place => note.nearby_place) + end + + xml.link url_for(:controller => "browse", :action => "note", :id => note.id, :only_path => false) + xml.guid url_for(:controller => "note", :action => "read", :id => note.id, :only_path => false) + xml.description htmlize(note.flatten_comment("

")) + xml.author note.author_name + xml.pubDate note.updated_at.to_s(:rfc822) + xml.geo :lat, note.lat + xml.geo :long, note.lon + xml.georss :point, "#{note.lat} #{note.lon}" +end diff --git a/app/views/note/_note.xml.builder b/app/views/note/_note.xml.builder new file mode 100644 index 000000000..2a2b2ffc1 --- /dev/null +++ b/app/views/note/_note.xml.builder @@ -0,0 +1,21 @@ +xml.note("lon" => note.lon, "lat" => note.lat) do + xml.id note.id + xml.date_created note.created_at + xml.nearby note.nearby_place + xml.status note.status + + if note.status == "closed" + xml.date_closed note.closed_at + end + + xml.comments do + note.comments.each do |comment| + xml.comment do + xml.date comment.created_at + xml.uid comment.author_id unless comment.author_id.nil? + xml.user comment.author_name + xml.text comment.body + end + end + end +end diff --git a/app/views/map_bugs/_bugs_paging_nav.html.erb b/app/views/note/_notes_paging_nav.html.erb similarity index 92% rename from app/views/map_bugs/_bugs_paging_nav.html.erb rename to app/views/note/_notes_paging_nav.html.erb index 3de179008..108cbb3d2 100644 --- a/app/views/map_bugs/_bugs_paging_nav.html.erb +++ b/app/views/note/_notes_paging_nav.html.erb @@ -8,7 +8,7 @@ | <%= t('changeset.changeset_paging_nav.showing_page', :page => @page) %> | -<% if @bugs.size < @page_size %> +<% if @notes.size < @page_size %> <%= t('changeset.changeset_paging_nav.next') %> <% else %> <%= link_to t('changeset.changeset_paging_nav.next'), params.merge({ :page => @page + 1 }) %> diff --git a/app/views/map_bugs/_user.html.erb b/app/views/note/_user.html.erb similarity index 100% rename from app/views/map_bugs/_user.html.erb rename to app/views/note/_user.html.erb diff --git a/app/views/map_bugs/list.gpx.builder b/app/views/note/list.gpx.builder similarity index 79% rename from app/views/map_bugs/list.gpx.builder rename to app/views/note/list.gpx.builder index f543c1a02..7a3046027 100644 --- a/app/views/map_bugs/list.gpx.builder +++ b/app/views/note/list.gpx.builder @@ -3,5 +3,5 @@ xml.instruct! xml.gpx("version" => "1.1", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do - xml << render(:partial => "bug", :collection => @bugs) + xml << render(:partial => "note", :collection => @notes) end diff --git a/app/views/note/list.rjs b/app/views/note/list.rjs new file mode 100644 index 000000000..1113c3f08 --- /dev/null +++ b/app/views/note/list.rjs @@ -0,0 +1,6 @@ +@notes.each do |note| + page.call "putAJAXMarker", + note.id, note.lon, note.lat, + note.flatten_comment("
"), + note.status == "open" ? 0 : 1 +end diff --git a/app/views/map_bugs/list.rss.builder b/app/views/note/list.rss.builder similarity index 69% rename from app/views/map_bugs/list.rss.builder rename to app/views/note/list.rss.builder index a1852fab1..d6ee2bbad 100644 --- a/app/views/map_bugs/list.rss.builder +++ b/app/views/note/list.rss.builder @@ -4,10 +4,10 @@ xml.rss("version" => "2.0", "xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#", "xmlns:georss" => "http://www.georss.org/georss") do xml.channel do - xml.title "OpenStreetBugs" - xml.description t('bugs.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon ) + xml.title t('note.rss.title') + xml.description t('note.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon ) xml.link url_for(:controller => "site", :action => "index", :only_path => false) - xml << render(:partial => "bug", :collection => @bugs) + xml << render(:partial => "note", :collection => @notes) end end diff --git a/app/views/note/list.xml.builder b/app/views/note/list.xml.builder new file mode 100644 index 000000000..38b239afc --- /dev/null +++ b/app/views/note/list.xml.builder @@ -0,0 +1,3 @@ +xml.instruct! + +xml << render(:partial => "note", :collection => @notes) diff --git a/app/views/note/mine.html.erb b/app/views/note/mine.html.erb new file mode 100644 index 000000000..d81824324 --- /dev/null +++ b/app/views/note/mine.html.erb @@ -0,0 +1,37 @@ +

<%= @heading %>

+

<%= @description %>

+ +<%= render :partial => 'notes_paging_nav' %> + + + + + + + + + + +<% @notes.each do |note| %> + bgcolor="#EEEEEE"<% end %>> + + + <% if note.author.nil? %> + + <% else %> + + <% end %> + + + + +<% end %> +
<%= t'note.mine.id' %><%= t'changeset.changesets.user' %><%= t'changeset.changesets.comment' %><%= t'changeset.changesets.saved_at' %><%= t'note.mine.last_changed' %>
+ <% if note.status == "closed" %> + <%= image_tag("closed_note_marker.png", :alt => 'closed') %> + <% else %> + <%= image_tag("open_note_marker.png", :alt => 'open') %> + <% end %> + <%= link_to note.id.to_s, :controller => "browse", :action => "note", :id => note.id %> <%= note.author_name %> <%= link_to h(note.author_name), :controller => "user", :action => "view", :display_name => note.author_name %> <%= htmlize note.comments.first.body %> <%= l note.created_at %><%= l note.updated_at %>
+ +<%= render :partial => 'notes_paging_nav' %> diff --git a/app/views/map_bugs/read.gpx.builder b/app/views/note/read.gpx.builder similarity index 80% rename from app/views/map_bugs/read.gpx.builder rename to app/views/note/read.gpx.builder index 0108a261b..e54d77246 100644 --- a/app/views/map_bugs/read.gpx.builder +++ b/app/views/note/read.gpx.builder @@ -3,5 +3,5 @@ xml.instruct! xml.gpx("version" => "1.1", "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation" => "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd") do - xml << render(:partial => "bug", :object => @bug) + xml << render(:partial => "note", :object => @note) end diff --git a/app/views/map_bugs/read.rss.builder b/app/views/note/read.rss.builder similarity index 64% rename from app/views/map_bugs/read.rss.builder rename to app/views/note/read.rss.builder index aba1f831d..e566ff02e 100644 --- a/app/views/map_bugs/read.rss.builder +++ b/app/views/note/read.rss.builder @@ -4,10 +4,10 @@ xml.rss("version" => "2.0", "xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#", "xmlns:georss" => "http://www.georss.org/georss") do xml.channel do - xml.title "OpenStreetBugs" - xml.description t('bugs.rss.description_item', :id => @bug.id) + xml.title t('note.rss.title') + xml.description t('note.rss.description_item', :id => @note.id) xml.link url_for(:controller => "site", :action => "index", :only_path => false) - xml << render(:partial => "bug", :object => @bug) + xml << render(:partial => "note", :object => @note) end end diff --git a/app/views/note/read.xml.builder b/app/views/note/read.xml.builder new file mode 100644 index 000000000..cfb28c20e --- /dev/null +++ b/app/views/note/read.xml.builder @@ -0,0 +1,3 @@ +xml.instruct! + +xml << render(:partial => "note", :object => @note) diff --git a/app/views/map_bugs/rss.rss.builder b/app/views/note/rss.rss.builder similarity index 53% rename from app/views/map_bugs/rss.rss.builder rename to app/views/note/rss.rss.builder index 566a3b322..d22d67311 100644 --- a/app/views/map_bugs/rss.rss.builder +++ b/app/views/note/rss.rss.builder @@ -4,24 +4,24 @@ xml.rss("version" => "2.0", "xmlns:geo" => "http://www.w3.org/2003/01/geo/wgs84_pos#", "xmlns:georss" => "http://www.georss.org/georss") do xml.channel do - xml.title "OpenStreetBugs" - xml.description t('bugs.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon ) + xml.title t('note.rss.title') + xml.description t('note.rss.description_area', :min_lat => @min_lat, :min_lon => @min_lon, :max_lat => @max_lat, :max_lon => @max_lon ) xml.link url_for(:controller => "site", :action => "index", :only_path => false) @comments.each do |comment| xml.item do if comment.event == "closed" - xml.title t('bugs.rss.closed', :place => comment.map_bug.nearby_place) + xml.title t('note.rss.closed', :place => comment.note.nearby_place) elsif comment.event == "commented" - xml.title t('bugs.rss.comment', :place => comment.map_bug.nearby_place) + xml.title t('note.rss.comment', :place => comment.note.nearby_place) elsif comment.event == "opened" - xml.title t('bugs.rss.new', :place => comment.map_bug.nearby_place) + xml.title t('note.rss.new', :place => comment.note.nearby_place) else xml.title "unknown event" end - xml.link url_for(:controller => "browse", :action => "bug", :id => comment.map_bug.id, :only_path => false) - xml.guid url_for(:controller => "browse", :action => "bug", :id => comment.map_bug.id, :only_path => false) + xml.link url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false) + xml.guid url_for(:controller => "browse", :action => "note", :id => comment.note.id, :only_path => false) description_text = "" @@ -31,15 +31,15 @@ xml.rss("version" => "2.0", description_text += "
" end - description_text += "Full bug report:
" - description_text += comment.map_bug.flatten_comment("
", comment.created_at) + description_text += "Full note:
" + description_text += comment.note.flatten_comment("
", comment.created_at) xml.description description_text xml.author comment.author_name xml.pubDate comment.created_at.to_s(:rfc822) - xml.geo :lat, comment.map_bug.lat - xml.geo :long, comment.map_bug.lon - xml.georss :point, "#{comment.map_bug.lat} #{comment.map_bug.lon}" + xml.geo :lat, comment.note.lat + xml.geo :long, comment.note.lon + xml.georss :point, "#{comment.note.lat} #{comment.note.lon}" end end end diff --git a/app/views/notifier/bug_comment_notification.html.erb b/app/views/notifier/bug_comment_notification.html.erb deleted file mode 100644 index ff8ad4265..000000000 --- a/app/views/notifier/bug_comment_notification.html.erb +++ /dev/null @@ -1,15 +0,0 @@ -<%= t 'notifier.map_bug_plain.greeting' %> - -<% if @owner %> -<%= t 'notifier.map_bug_plain.your_bug', :commenter => @commenter, :place => @place %> -<% else %> -<%= t 'notifier.map_bug_plain.commented_bug', :commenter => @commenter, :place => @place %> -<% end %> - -== -<%= @comment %> -== - -<%= t 'notifier.map_bug_plain.details', :URL => @bugurl %> - - diff --git a/app/views/notifier/note_comment_notification.html.erb b/app/views/notifier/note_comment_notification.html.erb new file mode 100644 index 000000000..fade148d8 --- /dev/null +++ b/app/views/notifier/note_comment_notification.html.erb @@ -0,0 +1,15 @@ +<%= t 'notifier.note_plain.greeting' %> + +<% if @owner %> +<%= t 'notifier.note_plain.your_note', :commenter => @commenter, :place => @place %> +<% else %> +<%= t 'notifier.note_plain.commented_note', :commenter => @commenter, :place => @place %> +<% end %> + +== +<%= @comment %> +== + +<%= t 'notifier.note_plain.details', :URL => @noteurl %> + + diff --git a/app/views/site/index.html.erb b/app/views/site/index.html.erb index f75756862..a61baca81 100644 --- a/app/views/site/index.html.erb +++ b/app/views/site/index.html.erb @@ -139,10 +139,10 @@ end map.dataLayer.events.register("visibilitychanged", map.dataLayer, toggleData); map.addLayer(map.dataLayer); - map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("OpenStreetBugs", { + map.osbLayer = new OpenLayers.Layer.OpenStreetBugs("Notes", { serverURL: "/api/0.6/", - iconOpen: new OpenLayers.Icon("<%= image_path "open_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), - iconClosed: new OpenLayers.Icon("<%= image_path "closed_bug_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), + iconOpen: new OpenLayers.Icon("<%= image_path "open_note_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), + iconClosed: new OpenLayers.Icon("<%= image_path "closed_noe_marker.png" %>", new OpenLayers.Size(22, 22), new OpenLayers.Pixel(-11, -11)), readonly: false, setCookie: false, permalinkURL: "http://www.openstreetmap.org/", diff --git a/app/views/user/view.html.erb b/app/views/user/view.html.erb index 4d3d7c0c2..5659cd133 100644 --- a/app/views/user/view.html.erb +++ b/app/views/user/view.html.erb @@ -23,9 +23,9 @@ | <%= link_to t('user.view.my edits'), :controller => 'changeset', :action => 'list', :display_name => @user.display_name %> | - <%= link_to t('user.view.my traces'), :controller => 'trace', :action=>'mine' %> + <%= link_to t('user.view.my traces'), :controller => 'trace', :action=> 'mine' %> | - <%= link_to t('user.view.my bugs'), :controller => 'map_bugs', :action=>'my_bugs' %> + <%= link_to t('user.view.my notes'), :controller => 'note', :action=> 'mine' %> | <%= link_to t('user.view.my settings'), :controller => 'user', :action => 'account', :display_name => @user.display_name %> | @@ -45,7 +45,7 @@ | <%= link_to t('user.view.traces'), :controller => 'trace', :action => 'view', :display_name => @this_user.display_name %> | - <%= link_to t('user.view.bugs'), :controller => 'map_bugs', :action=>'my_bugs' %> + <%= link_to t('user.view.notes'), :controller => 'note', :action=> 'mine' %> | <% if @user and @user.is_friends_with?(@this_user) %> <%= link_to t('user.view.remove as friend'), :controller => 'user', :action => 'remove_friend', :display_name => @this_user.display_name %> diff --git a/config/example.application.yml b/config/example.application.yml index 7d7d9ad8b..dea87c247 100644 --- a/config/example.application.yml +++ b/config/example.application.yml @@ -24,8 +24,8 @@ standard_settings: &standard_settings max_number_of_nodes: 50000 # Maximum number of nodes that can be in a way (checked on save) max_number_of_way_nodes: 2000 - # The maximum area you're allowed to request bugs from, in square degrees - max_bug_request_area: 25 + # The maximum area you're allowed to request notes from, in square degrees + max_note_request_area: 25 # Zoom level to use for postcode results from the geocoder postcode_zoom: 15 # Zoom level to use for geonames results from the geocoder diff --git a/config/locales/en.yml b/config/locales/en.yml index a8f523b47..49f8da0f7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -277,9 +277,9 @@ en: download_xml: "Download XML" view_history: "view history" edit: "edit" - bug: - open_title: "Unresolved issue: {{bug_name}}" - closed_title: "Resolved issue: {{bug_name}}" + note: + open_title: "Unresolved issue: {{note_name}}" + closed_title: "Resolved issue: {{note_name}}" created_at: "Created at:" edited_at: "Edited at:" closed_at: "Closed at:" @@ -1178,13 +1178,13 @@ en: greeting: "Hi," hopefully_you: "Someone (possibly you) has asked for the password to be reset on this email address's openstreetmap.org account." click_the_link: "If this is you, please click the link below to reset your password." - map_bug_plain: - subject_own: "[OpenStreetMap bugs] {{commenter}} has commented on one of your bugs" - subject_other: "[OpenStreetMap bugs] {{commenter}} has commented on a bug you are interested in" + note_plain: + subject_own: "[OpenStreetMap] {{commenter}} has commented on one of your notes" + subject_other: "[OpenStreetMap] {{commenter}} has commented on a note you are interested in" greeting: "Hi," - your_bug: "{{commenter}} has left a comment on one of your map bug reports near {{place}}." - commented_bug: "{{commenter}} has left a comment on a map bug report you have commented on. The bug is near {{place}}." - details: "More details about the bug report can be found at {{URL}}." + your_note: "{{commenter}} has left a comment on one of your map notes near {{place}}." + commented_note: "{{commenter}} has left a comment on a map note you have commented on. The note is near {{place}}." + details: "More details about the note can be found at {{URL}}." message: inbox: title: "Inbox" @@ -1615,7 +1615,7 @@ en: new diary entry: new diary entry my edits: my edits my traces: my traces - my bugs: my map bugs + my notes: my map notes my settings: my settings oauth settings: oauth settings blocks on me: blocks on me @@ -1624,7 +1624,7 @@ en: diary: diary edits: edits traces: traces - bugs: map bugs + notes: map notes remove as friend: remove as friend add as friend: add as friend mapper since: "Mapper since:" @@ -1872,17 +1872,18 @@ en: back: "View all blocks" revoker: "Revoker:" needs_view: "The user needs to log in before this block will be cleared." - bugs: + note: rss: - description_area: "A list of bugs, reported, commented on or closed in your area [({{min_lat}}|{{min_lon}}) -- ({{max_lat}}|{{max_lon}})]" - description_item: "An rss feed for bug {{id}}" - closed: "closed bug (near {{place}})" - new: "new bug (near {{place}})" + title: "OpenStreetMap Notes" + description_area: "A list of notes, reported, commented on or closed in your area [({{min_lat}}|{{min_lon}}) -- ({{max_lat}}|{{max_lon}})]" + description_item: "An rss feed for note {{id}}" + closed: "closed note (near {{place}})" + new: "new note (near {{place}})" comment: "new comment (near {{place}})" - user: - title_user: "Bugs submitted or commented on by {{user}}" - heading_user: "{{user}}'s bugs" - description_user: "Bugs submitted or commented on by {{user}}" + mine: + title: "Notes submitted or commented on by {{user}}" + heading: "{{user}}'s notes" + description: "Notes submitted or commented on by {{user}}" id: "Id" last_changed: "Last changed" diff --git a/config/routes.rb b/config/routes.rb index e4ace79b1..334cb7422 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -75,21 +75,21 @@ ActionController::Routing::Routes.draw do |map| map.connect "api/#{API_VERSION}/amf/write", :controller =>'amf', :action =>'amf_write' map.connect "api/#{API_VERSION}/swf/trackpoints", :controller =>'swf', :action =>'trackpoints' - # Map Bugs API - map.connect "api/#{API_VERSION}/bugs", :controller => 'map_bugs', :action => 'list' - map.connect "api/#{API_VERSION}/bugs/search", :controller => 'map_bugs', :action => 'search' - map.connect "api/#{API_VERSION}/bugs/rss", :controller =>'map_bugs', :action => 'rss' - map.connect "api/#{API_VERSION}/bug/create", :controller => 'map_bugs', :action => 'create' - map.connect "api/#{API_VERSION}/bug/:id/comment", :controller => 'map_bugs', :action => 'update', :id => /\d+/ - map.connect "api/#{API_VERSION}/bug/:id/close", :controller => 'map_bugs', :action => 'close', :id => /\d+/ - map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'read', :id => /\d+/, :conditions => { :method => :get } - map.connect "api/#{API_VERSION}/bug/:id", :controller => 'map_bugs', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete } - map.connect "api/#{API_VERSION}/bugs/getBugs", :controller => 'map_bugs', :action => 'list' - map.connect "api/#{API_VERSION}/bugs/addPOIexec", :controller => 'map_bugs', :action => 'create' - map.connect "api/#{API_VERSION}/bugs/closePOIexec", :controller => 'map_bugs', :action => 'close' - map.connect "api/#{API_VERSION}/bugs/editPOIexec", :controller => 'map_bugs', :action => 'update' - map.connect "api/#{API_VERSION}/bugs/getGPX", :controller => 'map_bugs', :action => 'list', :format => :gpx - map.connect "api/#{API_VERSION}/bugs/getRSSfeed", :controller => 'map_bugs', :action => 'rss' + # Map notes API + map.connect "api/#{API_VERSION}/notes", :controller => 'note', :action => 'list' + map.connect "api/#{API_VERSION}/notes/search", :controller => 'note', :action => 'search' + map.connect "api/#{API_VERSION}/notes/rss", :controller =>'notes', :action => 'rss' + map.connect "api/#{API_VERSION}/note/create", :controller => 'note', :action => 'create' + map.connect "api/#{API_VERSION}/note/:id/comment", :controller => 'note', :action => 'update', :id => /\d+/ + map.connect "api/#{API_VERSION}/note/:id/close", :controller => 'note', :action => 'close', :id => /\d+/ + map.connect "api/#{API_VERSION}/note/:id", :controller => 'note', :action => 'read', :id => /\d+/, :conditions => { :method => :get } + map.connect "api/#{API_VERSION}/note/:id", :controller => 'note', :action => 'delete', :id => /\d+/, :conditions => { :method => :delete } + map.connect "api/#{API_VERSION}/notes/getBugs", :controller => 'note', :action => 'list' + map.connect "api/#{API_VERSION}/notes/addPOIexec", :controller => 'note', :action => 'create' + map.connect "api/#{API_VERSION}/notes/closePOIexec", :controller => 'note', :action => 'close' + map.connect "api/#{API_VERSION}/notes/editPOIexec", :controller => 'note', :action => 'update' + map.connect "api/#{API_VERSION}/notes/getGPX", :controller => 'note', :action => 'list', :format => :gpx + map.connect "api/#{API_VERSION}/notes/getRSSfeed", :controller => 'note', :action => 'rss' # Data browsing map.connect '/browse/start', :controller => 'browse', :action => 'start' @@ -104,8 +104,8 @@ ActionController::Routing::Routes.draw do |map| map.connect '/user/:display_name/edits', :controller => 'changeset', :action => 'list' map.connect '/browse/changesets/feed', :controller => 'changeset', :action => 'list', :format => :atom map.connect '/browse/changesets', :controller => 'changeset', :action => 'list' - map.connect '/browse/bug/:id', :controller => 'browse', :action => 'bug', :id => /\d+/ - map.connect '/user/:display_name/bugs', :controller => 'map_bugs', :action => 'mine' + map.connect '/browse/note/:id', :controller => 'browse', :action => 'note', :id => /\d+/ + map.connect '/user/:display_name/notes', :controller => 'note', :action => 'mine' map.connect '/browse', :controller => 'changeset', :action => 'list' # web site diff --git a/db/migrate/20110508145337_cleanup_bug_tables.rb b/db/migrate/20110508145337_cleanup_bug_tables.rb index a5563ce0f..e7dfcb793 100644 --- a/db/migrate/20110508145337_cleanup_bug_tables.rb +++ b/db/migrate/20110508145337_cleanup_bug_tables.rb @@ -4,32 +4,20 @@ class CleanupBugTables < ActiveRecord::Migration rename_column :map_bugs, :last_changed, :updated_at rename_column :map_bugs, :date_closed, :closed_at - rename_index :map_bugs, :map_bugs_tile_idx, :map_bugs_tile_staus_idx - rename_index :map_bugs, :map_bugs_changed_idx, :map_bugs_updated_at_idx - rename_index :map_bugs, :map_bugs_created_idx, :map_bugs_created_at_idx - rename_column :map_bug_comment, :date_created, :created_at rename_column :map_bug_comment, :commenter_name, :author_name rename_column :map_bug_comment, :commenter_ip, :author_ip rename_column :map_bug_comment, :commenter_id, :author_id rename_column :map_bug_comment, :comment, :body - - rename_index :map_bug_comment, :map_bug_comment_id_idx, :map_bug_comment_bug_id_idx end def self.down - rename_index :map_bug_comment, :map_bug_comment_bug_id_idx, :map_bug_comment_id_idx - rename_column :map_bug_comment, :body, :comment rename_column :map_bug_comment, :author_id, :commenter_id rename_column :map_bug_comment, :author_ip, :commenter_ip rename_column :map_bug_comment, :author_name, :commenter_name rename_column :map_bug_comment, :created_at, :date_created - rename_index :map_bugs, :map_bugs_created_at_idx, :map_bugs_created_idx - rename_index :map_bugs, :map_bugs_updated_at_idx, :map_bugs_changed_idx - rename_index :map_bugs, :map_bugs_tile_staus_idx, :map_bugs_tile_idx - rename_column :map_bugs, :closed_at, :date_closed rename_column :map_bugs, :updated_at, :last_changed rename_column :map_bugs, :created_at, :date_created diff --git a/db/migrate/20110521142405_rename_bugs_to_notes.rb b/db/migrate/20110521142405_rename_bugs_to_notes.rb new file mode 100644 index 000000000..240d4474f --- /dev/null +++ b/db/migrate/20110521142405_rename_bugs_to_notes.rb @@ -0,0 +1,55 @@ +require 'lib/migrate' + +class RenameBugsToNotes < ActiveRecord::Migration + def self.up + rename_enumeration "map_bug_status_enum", "note_status_enum" + rename_enumeration "map_bug_event_enum", "note_event_enum" + + rename_table :map_bugs, :notes + rename_sequence :notes, "map_bugs_id_seq", "notes_id_seq" + rename_index :notes, "map_bugs_pkey", "notes_pkey" + rename_index :notes, "map_bugs_changed_idx", "notes_updated_at_idx" + rename_index :notes, "map_bugs_created_idx", "notes_created_at_idx" + rename_index :notes, "map_bugs_tile_idx", "notes_tile_status_idx" + + remove_foreign_key :map_bug_comment, [:bug_id], :map_bugs, [:id] + rename_column :map_bug_comment, :author_id, :commenter_id + remove_foreign_key :map_bug_comment, [:commenter_id], :users, [:id] + rename_column :map_bug_comment, :commenter_id, :author_id + + rename_table :map_bug_comment, :note_comments + rename_column :note_comments, :bug_id, :note_id + rename_sequence :note_comments, "map_bug_comment_id_seq", "note_comments_id_seq" + rename_index :note_comments, "map_bug_comment_pkey", "note_comments_pkey" + rename_index :note_comments, "map_bug_comment_id_idx", "note_comments_note_id_idx" + + add_foreign_key :note_comments, [:note_id], :notes, [:id] + add_foreign_key :note_comments, [:author_id], :users, [:id] + end + + def self.down + remove_foreign_key :note_comments, [:author_id], :users, [:id] + remove_foreign_key :note_comments, [:note_id], :notes, [:id] + + rename_index :note_comments, "note_comments_note_id_idx", "map_bug_comment_id_idx" + rename_index :notes, "note_comments_pkey", "map_bug_comment_pkey" + rename_column :note_comments, :note_id, :bug_id + rename_sequence :note_comments, "note_comments_id_seq", "map_bug_comment_id_seq" + rename_table :note_comments, :map_bug_comment + + rename_column :map_bug_comment, :author_id, :commenter_id + add_foreign_key :map_bug_comment, [:commenter_id], :users, [:id] + rename_column :map_bug_comment, :commenter_id, :author_id + add_foreign_key :map_bug_comment, [:bug_id], :notes, [:id] + + rename_index :notes, "notes_tile_status_idx", "map_bugs_tile_idx" + rename_index :notes, "notes_created_at_idx", "map_bugs_created_idx" + rename_index :notes, "notes_updated_at_idx", "map_bugs_changed_idx" + rename_index :notes, "notes_pkey", "map_bugs_pkey" + rename_sequence :notes, "notes_id_seq", "map_bugs_id_seq" + rename_table :notes, :map_bugs + + rename_enumeration "note_event_enum", "map_bug_event_enum" + rename_enumeration "note_status_enum", "map_bug_status_enum" + end +end diff --git a/lib/migrate.rb b/lib/migrate.rb index 81cdd4d05..8e6629f0d 100644 --- a/lib/migrate.rb +++ b/lib/migrate.rb @@ -105,11 +105,11 @@ module ActiveRecord @enumerations ||= Hash.new end - def create_enumeration (enumeration_name, values) + def create_enumeration(enumeration_name, values) enumerations[enumeration_name] = values end - def drop_enumeration (enumeration_name) + def drop_enumeration(enumeration_name) enumerations.delete(enumeration_name) end @@ -158,29 +158,34 @@ module ActiveRecord return "" end - def change_engine (table_name, engine) + def change_engine(table_name, engine) end - def add_fulltext_index (table_name, column) - execute "CREATE INDEX #{table_name}_#{column}_idx on #{table_name} (#{column})" + def add_fulltext_index(table_name, column) + execute "CREATE INDEX #{table_name}_#{column}_idx ON #{table_name} (#{column})" end def enumerations @enumerations ||= Hash.new end - def create_enumeration (enumeration_name, values) + def create_enumeration(enumeration_name, values) enumerations[enumeration_name] = values - execute "create type #{enumeration_name} as enum ('#{values.join '\',\''}')" + execute "CREATE TYPE #{enumeration_name} AS ENUM ('#{values.join '\',\''}')" end - def drop_enumeration (enumeration_name) - execute "drop type #{enumeration_name}" + def drop_enumeration(enumeration_name) + execute "DROP TYPE #{enumeration_name}" enumerations.delete(enumeration_name) end + def rename_enumeration(old_name, new_name) + execute "ALTER TYPE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}" + end + def alter_primary_key(table_name, new_columns) - execute "alter table #{table_name} drop constraint #{table_name}_pkey; alter table #{table_name} add primary key (#{new_columns.join(',')})" + execute "ALTER TABLE #{table_name} DROP CONSTRAINT #{table_name}_pkey" + execute "ALTER TABLE #{table_name} ADD PRIMARY KEY (#{new_columns.join(',')})" end def interval_constant(interval) @@ -201,6 +206,14 @@ module ActiveRecord quoted_column_names = column_names.map { |e| quote_column_name(e) }.join(", ") execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} USING #{index_method} (#{quoted_column_names})" end + + def rename_index(table_name, old_name, new_name) + execute "ALTER INDEX #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}" + end + + def rename_sequence(table_name, old_name, new_name) + execute "ALTER SEQUENCE #{quote_table_name(old_name)} RENAME TO #{quote_table_name(new_name)}" + end end end end diff --git a/public/images/closed_bug_marker.png b/public/images/closed_note_marker.png similarity index 100% rename from public/images/closed_bug_marker.png rename to public/images/closed_note_marker.png diff --git a/public/images/open_bug_marker.png b/public/images/open_note_marker.png similarity index 100% rename from public/images/open_bug_marker.png rename to public/images/open_note_marker.png diff --git a/public/javascripts/openstreetbugs.js b/public/javascripts/openstreetbugs.js index 6d2f62b35..12bd7d859 100644 --- a/public/javascripts/openstreetbugs.js +++ b/public/javascripts/openstreetbugs.js @@ -248,7 +248,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, if(!bounds) return false; bounds.transform(this.map.getProjectionObject(), this.apiProjection); - this.apiRequest("bugs" + this.apiRequest("notes" + "?bbox="+this.round(bounds.left, 5) + ","+this.round(bounds.bottom, 5) + ","+this.round(bounds.right, 5) @@ -467,7 +467,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, * @param String description */ createBug: function(lonlat, description) { - this.apiRequest("bug/create" + this.apiRequest("note/create" + "?lat="+encodeURIComponent(lonlat.lat) + "&lon="+encodeURIComponent(lonlat.lon) + "&text="+encodeURIComponent(description) @@ -482,7 +482,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, * @param String comment */ submitComment: function(id, comment) { - this.apiRequest("bug/"+encodeURIComponent(id)+"/comment" + this.apiRequest("note/"+encodeURIComponent(id)+"/comment" + "?text="+encodeURIComponent(comment) + "&name="+encodeURIComponent(this.getUserName()) + "&format=js" @@ -494,7 +494,7 @@ OpenLayers.Layer.OpenStreetBugs = new OpenLayers.Class(OpenLayers.Layer.Markers, * @param Number id */ closeBug: function(id) { - this.apiRequest("bug/"+encodeURIComponent(id)+"/close" + this.apiRequest("note/"+encodeURIComponent(id)+"/close" + "?format=js" ); },