+
+ def rss
+ request.format = :rss
+ get_bugs
+ end
+
+ def gpx_bugs
+ request.format = :xml
+ get_bugs
+ end
+
+ def read
+ @bug = MapBug.find(params['id'])
+ render :text => "", :status => :gone unless @bug.visible
+ respond_to do |format|
+ format.rss
+ format.xml
+ format.json { render :json => @bug.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
+ end
+ end
+
+ def delete
+ bug = MapBug.find(params['id'])
+ bug.status = "hidden"
+ bug.save
+ render :text => "ok\n", :content_type => "text/html"
+ end
+
+ def search
+ raise OSM::APIBadUserInput.new("No query string was given") unless params['q']
+ limit = getLimit
+ conditions = closedCondition
+
+ #TODO: There should be a better way to do this. CloseConditions are ignored at the moment
+
+ bugs2 = MapBug.find(:all, :limit => limit, :order => "last_changed DESC", :joins => :map_bug_comment,
+ :conditions => ['map_bug_comment.comment ~ ?', params['q']])
+ @bugs = bugs2.uniq
+ respond_to do |format|
+ format.html {render :template => 'map_bugs/get_bugs.js', :content_type => "text/javascript"}
+ format.rss {render :template => 'map_bugs/get_bugs.rss'}
+ format.js
+ format.xml {render :template => 'map_bugs/get_bugs.xml'}
+ format.json { render :json => @bugs.to_json(:methods => [:lat, :lon], :only => [:id, :status, :date_created], :include => { :map_bug_comment => { :only => [:commenter_name, :date_created, :comment]}}) }
+ format.gpx {render :template => 'map_bugs/get_bugs.gpx'}
+ end
+ end
+
+