Remove all use of the :text option to render
It doesn't actually do what it says, as it sets the content type to text/html not text/plain so is just confusing and as a result has been deprecated in newer rails versions.
This commit is contained in:
parent
9b89d4eefe
commit
ff97501ed0
17 changed files with 101 additions and 103 deletions
|
@ -100,7 +100,7 @@ class ApiController < ApplicationController
|
||||||
|
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=\"tracks.gpx\""
|
response.headers["Content-Disposition"] = "attachment; filename=\"tracks.gpx\""
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is probably the most common call of all. It is used for getting the
|
# This is probably the most common call of all. It is used for getting the
|
||||||
|
@ -198,7 +198,7 @@ class ApiController < ApplicationController
|
||||||
|
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""
|
response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get a list of the tiles that have changed within a specified time
|
# Get a list of the tiles that have changed within a specified time
|
||||||
|
@ -241,9 +241,9 @@ class ApiController < ApplicationController
|
||||||
|
|
||||||
doc.root << changes
|
doc.root << changes
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
else
|
else
|
||||||
render :text => "Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours", :status => :bad_request
|
render :plain => "Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours", :status => :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ class ApiController < ApplicationController
|
||||||
policy << blacklist
|
policy << blacklist
|
||||||
doc.root << policy
|
doc.root << policy
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# External apps that use the api are able to query which permissions
|
# External apps that use the api are able to query which permissions
|
||||||
|
|
|
@ -41,7 +41,7 @@ class ApplicationController < ActionController::Base
|
||||||
if request.get?
|
if request.get?
|
||||||
redirect_to :controller => "user", :action => "login", :referer => request.fullpath
|
redirect_to :controller => "user", :action => "login", :referer => request.fullpath
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -127,7 +127,7 @@ class ApplicationController < ActionController::Base
|
||||||
flash[:error] = t("application.require_moderator.not_a_moderator")
|
flash[:error] = t("application.require_moderator.not_a_moderator")
|
||||||
redirect_to :action => "index"
|
redirect_to :action => "index"
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base
|
||||||
unless @user
|
unless @user
|
||||||
# no auth, the user does not exist or the password was wrong
|
# no auth, the user does not exist or the password was wrong
|
||||||
response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
|
response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
|
||||||
render :text => errormessage, :status => :unauthorized
|
render :plain => errormessage, :status => :unauthorized
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -197,7 +197,7 @@ class ApplicationController < ActionController::Base
|
||||||
def authorize_moderator(errormessage = "Access restricted to moderators")
|
def authorize_moderator(errormessage = "Access restricted to moderators")
|
||||||
# check user is a moderator
|
# check user is a moderator
|
||||||
unless @user.moderator?
|
unless @user.moderator?
|
||||||
render :text => errormessage, :status => :forbidden
|
render :plain => errormessage, :status => :forbidden
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -288,9 +288,9 @@ class ApplicationController < ActionController::Base
|
||||||
result.root << (XML::Node.new("status") << "#{Rack::Utils.status_code(status)} #{Rack::Utils::HTTP_STATUS_CODES[status]}")
|
result.root << (XML::Node.new("status") << "#{Rack::Utils.status_code(status)} #{Rack::Utils::HTTP_STATUS_CODES[status]}")
|
||||||
result.root << (XML::Node.new("message") << message)
|
result.root << (XML::Node.new("message") << message)
|
||||||
|
|
||||||
render :text => result.to_s, :content_type => "text/xml"
|
render :xml => result.to_s
|
||||||
else
|
else
|
||||||
render :text => message, :status => status, :content_type => "text/plain"
|
render :plain => message, :status => status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class ApplicationController < ActionController::Base
|
||||||
def api_call_handle_error
|
def api_call_handle_error
|
||||||
yield
|
yield
|
||||||
rescue ActiveRecord::RecordNotFound => ex
|
rescue ActiveRecord::RecordNotFound => ex
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
rescue LibXML::XML::Error, ArgumentError => ex
|
rescue LibXML::XML::Error, ArgumentError => ex
|
||||||
report_error ex.message, :bad_request
|
report_error ex.message, :bad_request
|
||||||
rescue ActiveRecord::RecordInvalid => ex
|
rescue ActiveRecord::RecordInvalid => ex
|
||||||
|
@ -391,7 +391,7 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :template => "user/no_such_user", :status => :not_found }
|
format.html { render :template => "user/no_such_user", :status => :not_found }
|
||||||
format.all { render :text => "", :status => :not_found }
|
format.all { head :not_found }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class ChangesetController < ApplicationController
|
||||||
# Subscribe user to changeset comments
|
# Subscribe user to changeset comments
|
||||||
cs.subscribers << @user
|
cs.subscribers << @user
|
||||||
|
|
||||||
render :text => cs.id.to_s, :content_type => "text/plain"
|
render :plain => cs.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -43,7 +43,7 @@ class ChangesetController < ApplicationController
|
||||||
def read
|
def read
|
||||||
changeset = Changeset.find(params[:id])
|
changeset = Changeset.find(params[:id])
|
||||||
|
|
||||||
render :text => changeset.to_xml(params[:include_discussion].presence).to_s, :content_type => "text/xml"
|
render :xml => changeset.to_xml(params[:include_discussion].presence).to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -61,7 +61,7 @@ class ChangesetController < ApplicationController
|
||||||
changeset.set_closed_time_now
|
changeset.set_closed_time_now
|
||||||
|
|
||||||
changeset.save!
|
changeset.save!
|
||||||
render :text => ""
|
render :nothing => true
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -104,7 +104,7 @@ class ChangesetController < ApplicationController
|
||||||
# save the larger bounding box and return the changeset, which
|
# save the larger bounding box and return the changeset, which
|
||||||
# will include the bigger bounding box.
|
# will include the bigger bounding box.
|
||||||
cs.save!
|
cs.save!
|
||||||
render :text => cs.to_xml.to_s, :content_type => "text/xml"
|
render :xml => cs.to_xml.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -132,7 +132,7 @@ class ChangesetController < ApplicationController
|
||||||
diff_reader = DiffReader.new(request.raw_post, changeset)
|
diff_reader = DiffReader.new(request.raw_post, changeset)
|
||||||
Changeset.transaction do
|
Changeset.transaction do
|
||||||
result = diff_reader.commit
|
result = diff_reader.commit
|
||||||
render :text => result.to_s, :content_type => "text/xml"
|
render :xml => result.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ class ChangesetController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => result.to_s, :content_type => "text/xml"
|
render :xml => result.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -224,7 +224,7 @@ class ChangesetController < ApplicationController
|
||||||
results.root << cs.to_xml_node
|
results.root << cs.to_xml_node
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => results.to_s, :content_type => "text/xml"
|
render :xml => results.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -244,7 +244,7 @@ class ChangesetController < ApplicationController
|
||||||
|
|
||||||
check_changeset_consistency(changeset, @user)
|
check_changeset_consistency(changeset, @user)
|
||||||
changeset.update_from(new_changeset, @user)
|
changeset.update_from(new_changeset, @user)
|
||||||
render :text => changeset.to_xml, :mime_type => "text/xml"
|
render :xml => changeset.to_xml
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -335,7 +335,7 @@ class ChangesetController < ApplicationController
|
||||||
changeset.subscribers << @user unless changeset.subscribers.exists?(@user.id)
|
changeset.subscribers << @user unless changeset.subscribers.exists?(@user.id)
|
||||||
|
|
||||||
# Return a copy of the updated changeset
|
# Return a copy of the updated changeset
|
||||||
render :text => changeset.to_xml.to_s, :content_type => "text/xml"
|
render :xml => changeset.to_xml.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -356,7 +356,7 @@ class ChangesetController < ApplicationController
|
||||||
changeset.subscribers << @user
|
changeset.subscribers << @user
|
||||||
|
|
||||||
# Return a copy of the updated changeset
|
# Return a copy of the updated changeset
|
||||||
render :text => changeset.to_xml.to_s, :content_type => "text/xml"
|
render :xml => changeset.to_xml.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -377,7 +377,7 @@ class ChangesetController < ApplicationController
|
||||||
changeset.subscribers.delete(@user)
|
changeset.subscribers.delete(@user)
|
||||||
|
|
||||||
# Return a copy of the updated changeset
|
# Return a copy of the updated changeset
|
||||||
render :text => changeset.to_xml.to_s, :content_type => "text/xml"
|
render :xml => changeset.to_xml.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -396,7 +396,7 @@ class ChangesetController < ApplicationController
|
||||||
comment.update(:visible => false)
|
comment.update(:visible => false)
|
||||||
|
|
||||||
# Return a copy of the updated changeset
|
# Return a copy of the updated changeset
|
||||||
render :text => comment.changeset.to_xml.to_s, :content_type => "text/xml"
|
render :xml => comment.changeset.to_xml.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -415,7 +415,7 @@ class ChangesetController < ApplicationController
|
||||||
comment.update(:visible => true)
|
comment.update(:visible => true)
|
||||||
|
|
||||||
# Return a copy of the updated changeset
|
# Return a copy of the updated changeset
|
||||||
render :text => comment.changeset.to_xml.to_s, :content_type => "text/xml"
|
render :xml => comment.changeset.to_xml.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -440,7 +440,7 @@ class ChangesetController < ApplicationController
|
||||||
format.rss
|
format.rss
|
||||||
end
|
end
|
||||||
rescue OSM::APIBadUserInput
|
rescue OSM::APIBadUserInput
|
||||||
render :text => "", :status => :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -158,7 +158,7 @@ class DiaryEntryController < ApplicationController
|
||||||
@description = I18n.t("diary_entry.feed.user.description", :user => user.display_name)
|
@description = I18n.t("diary_entry.feed.user.description", :user => user.display_name)
|
||||||
@link = "http://#{SERVER_URL}/user/#{user.display_name}/diary"
|
@link = "http://#{SERVER_URL}/user/#{user.display_name}/diary"
|
||||||
else
|
else
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
|
@ -35,7 +35,7 @@ class GeocoderController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
if @sources.empty?
|
if @sources.empty?
|
||||||
render :text => "", :status => :bad_request
|
head :bad_request
|
||||||
else
|
else
|
||||||
render :layout => map_layout
|
render :layout => map_layout
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ class NodeController < ApplicationController
|
||||||
|
|
||||||
# Assume that Node.from_xml has thrown an exception if there is an error parsing the xml
|
# Assume that Node.from_xml has thrown an exception if there is an error parsing the xml
|
||||||
node.create_with_history @user
|
node.create_with_history @user
|
||||||
render :text => node.id.to_s, :content_type => "text/plain"
|
render :plain => node.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dump the details on a node given in params[:id]
|
# Dump the details on a node given in params[:id]
|
||||||
|
@ -29,9 +29,9 @@ class NodeController < ApplicationController
|
||||||
response.last_modified = node.timestamp
|
response.last_modified = node.timestamp
|
||||||
|
|
||||||
if node.visible
|
if node.visible
|
||||||
render :text => node.to_xml.to_s, :content_type => "text/xml"
|
render :xml => node.to_xml.to_s
|
||||||
else
|
else
|
||||||
render :text => "", :status => :gone
|
head :gone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ class NodeController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
node.update_from(new_node, @user)
|
node.update_from(new_node, @user)
|
||||||
render :text => node.version.to_s, :content_type => "text/plain"
|
render :plain => node.version.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete a node. Doesn't actually delete it, but retains its history
|
# Delete a node. Doesn't actually delete it, but retains its history
|
||||||
|
@ -59,7 +59,7 @@ class NodeController < ApplicationController
|
||||||
raise OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
|
raise OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
|
||||||
end
|
end
|
||||||
node.delete_with_history!(new_node, @user)
|
node.delete_with_history!(new_node, @user)
|
||||||
render :text => node.version.to_s, :content_type => "text/plain"
|
render :plain => node.version.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# Dump the details on many nodes whose ids are given in the "nodes" parameter.
|
# Dump the details on many nodes whose ids are given in the "nodes" parameter.
|
||||||
|
@ -79,6 +79,6 @@ class NodeController < ApplicationController
|
||||||
doc.root << node.to_xml_node
|
doc.root << node.to_xml_node
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,12 +33,12 @@ class OldController < ApplicationController
|
||||||
doc.root << element.to_xml_node
|
doc.root << element.to_xml_node
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def version
|
def version
|
||||||
if @old_element.redacted? && !show_redactions?
|
if @old_element.redacted? && !show_redactions?
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
|
|
||||||
else
|
else
|
||||||
response.last_modified = @old_element.timestamp
|
response.last_modified = @old_element.timestamp
|
||||||
|
@ -46,7 +46,7 @@ class OldController < ApplicationController
|
||||||
doc = OSM::API.new.get_xml_doc
|
doc = OSM::API.new.get_xml_doc
|
||||||
doc.root << @old_element.to_xml_node
|
doc.root << @old_element.to_xml_node
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class OldController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# just return an empty 200 OK for success
|
# just return an empty 200 OK for success
|
||||||
render :text => ""
|
render :nothing => true
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -16,16 +16,16 @@ class RelationController < ApplicationController
|
||||||
|
|
||||||
# Assume that Relation.from_xml has thrown an exception if there is an error parsing the xml
|
# Assume that Relation.from_xml has thrown an exception if there is an error parsing the xml
|
||||||
relation.create_with_history @user
|
relation.create_with_history @user
|
||||||
render :text => relation.id.to_s, :content_type => "text/plain"
|
render :plain => relation.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def read
|
def read
|
||||||
relation = Relation.find(params[:id])
|
relation = Relation.find(params[:id])
|
||||||
response.last_modified = relation.timestamp
|
response.last_modified = relation.timestamp
|
||||||
if relation.visible
|
if relation.visible
|
||||||
render :text => relation.to_xml.to_s, :content_type => "text/xml"
|
render :xml => relation.to_xml.to_s
|
||||||
else
|
else
|
||||||
render :text => "", :status => :gone
|
head :gone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class RelationController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
relation.update_from new_relation, @user
|
relation.update_from new_relation, @user
|
||||||
render :text => relation.version.to_s, :content_type => "text/plain"
|
render :plain => relation.version.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
|
@ -48,9 +48,9 @@ class RelationController < ApplicationController
|
||||||
new_relation = Relation.from_xml(request.raw_post)
|
new_relation = Relation.from_xml(request.raw_post)
|
||||||
if new_relation && new_relation.id == relation.id
|
if new_relation && new_relation.id == relation.id
|
||||||
relation.delete_with_history!(new_relation, @user)
|
relation.delete_with_history!(new_relation, @user)
|
||||||
render :text => relation.version.to_s, :content_type => "text/plain"
|
render :plain => relation.version.to_s
|
||||||
else
|
else
|
||||||
render :text => "", :status => :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -119,10 +119,10 @@ class RelationController < ApplicationController
|
||||||
|
|
||||||
# finally add self and output
|
# finally add self and output
|
||||||
doc.root << relation.to_xml_node(visible_members, changeset_cache, user_display_name_cache)
|
doc.root << relation.to_xml_node(visible_members, changeset_cache, user_display_name_cache)
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
|
|
||||||
else
|
else
|
||||||
render :text => "", :status => :gone
|
head :gone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -143,7 +143,7 @@ class RelationController < ApplicationController
|
||||||
doc.root << relation.to_xml_node
|
doc.root << relation.to_xml_node
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def relations_for_way
|
def relations_for_way
|
||||||
|
@ -167,6 +167,6 @@ class RelationController < ApplicationController
|
||||||
doc.root << relation.to_xml_node if relation.visible
|
doc.root << relation.to_xml_node if relation.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,13 +33,13 @@ class SearchController < ApplicationController
|
||||||
|
|
||||||
if do_nodes
|
if do_nodes
|
||||||
response.headers["Error"] = "Searching of nodes is currently unavailable"
|
response.headers["Error"] = "Searching of nodes is currently unavailable"
|
||||||
render :text => "", :status => :service_unavailable
|
head :service_unavailable
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
unless value
|
unless value
|
||||||
response.headers["Error"] = "Searching for a key without value is currently unavailable"
|
response.headers["Error"] = "Searching for a key without value is currently unavailable"
|
||||||
render :text => "", :status => :service_unavailable
|
head :service_unavailable
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,6 +94,6 @@ class SearchController < ApplicationController
|
||||||
doc.root << rel.to_xml_node(nil, changeset_cache, user_display_name_cache)
|
doc.root << rel.to_xml_node(nil, changeset_cache, user_display_name_cache)
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -115,7 +115,7 @@ class SiteController < ApplicationController
|
||||||
def offline; end
|
def offline; end
|
||||||
|
|
||||||
def preview
|
def preview
|
||||||
render :text => RichText.new(params[:format], params[:text]).to_html
|
render :html => RichText.new(params[:format], params[:text]).to_html
|
||||||
end
|
end
|
||||||
|
|
||||||
def id
|
def id
|
||||||
|
|
|
@ -92,7 +92,7 @@ class SwfController < ApplicationController
|
||||||
m = pack_rect(bounds_left, bounds_right, bounds_bottom, bounds_top) + 0.chr + 12.chr + pack_u16(1) + m
|
m = pack_rect(bounds_left, bounds_right, bounds_bottom, bounds_top) + 0.chr + 12.chr + pack_u16(1) + m
|
||||||
m = "FWS" + 6.chr + pack_u32(m.length + 8) + m
|
m = "FWS" + 6.chr + pack_u32(m.length + 8) + m
|
||||||
|
|
||||||
render :text => m, :content_type => "application/x-shockwave-flash"
|
render :body => m, :content_type => "application/x-shockwave-flash"
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -145,7 +145,7 @@ class TraceController < ApplicationController
|
||||||
|
|
||||||
if trace.visible? && (trace.public? || (@user && @user == trace.user))
|
if trace.visible? && (trace.public? || (@user && @user == trace.user))
|
||||||
if Acl.no_trace_download(request.remote_ip)
|
if Acl.no_trace_download(request.remote_ip)
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
elsif request.format == Mime::XML
|
elsif request.format == Mime::XML
|
||||||
send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
|
send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
|
||||||
elsif request.format == Mime::GPX
|
elsif request.format == Mime::GPX
|
||||||
|
@ -154,19 +154,19 @@ class TraceController < ApplicationController
|
||||||
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
|
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@trace = Trace.find(params[:id])
|
@trace = Trace.find(params[:id])
|
||||||
|
|
||||||
if !@trace.visible?
|
if !@trace.visible?
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
elsif @user.nil? || @trace.user != @user
|
elsif @user.nil? || @trace.user != @user
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
else
|
else
|
||||||
@title = t "trace.edit.title", :name => @trace.name
|
@title = t "trace.edit.title", :name => @trace.name
|
||||||
|
|
||||||
|
@ -180,16 +180,16 @@ class TraceController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def delete
|
def delete
|
||||||
trace = Trace.find(params[:id])
|
trace = Trace.find(params[:id])
|
||||||
|
|
||||||
if !trace.visible?
|
if !trace.visible?
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
elsif @user.nil? || trace.user != @user
|
elsif @user.nil? || trace.user != @user
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
else
|
else
|
||||||
trace.visible = false
|
trace.visible = false
|
||||||
trace.save
|
trace.save
|
||||||
|
@ -197,7 +197,7 @@ class TraceController < ApplicationController
|
||||||
redirect_to :action => :list, :display_name => @user.display_name
|
redirect_to :action => :list, :display_name => @user.display_name
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def georss
|
def georss
|
||||||
|
@ -221,13 +221,13 @@ class TraceController < ApplicationController
|
||||||
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
||||||
send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => "image/gif", :disposition => "inline")
|
send_file(trace.large_picture_name, :filename => "#{trace.id}.gif", :type => "image/gif", :disposition => "inline")
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def icon
|
def icon
|
||||||
|
@ -238,22 +238,22 @@ class TraceController < ApplicationController
|
||||||
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
expires_in 7.days, :private => !trace.public?, :public => trace.public?
|
||||||
send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => "image/gif", :disposition => "inline")
|
send_file(trace.icon_picture_name, :filename => "#{trace.id}_icon.gif", :type => "image/gif", :disposition => "inline")
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render :text => "", :status => :not_found
|
head :not_found
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_read
|
def api_read
|
||||||
trace = Trace.visible.find(params[:id])
|
trace = Trace.visible.find(params[:id])
|
||||||
|
|
||||||
if trace.public? || trace.user == @user
|
if trace.public? || trace.user == @user
|
||||||
render :text => trace.to_xml.to_s, :content_type => "text/xml"
|
render :xml => trace.to_xml.to_s
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -272,9 +272,9 @@ class TraceController < ApplicationController
|
||||||
trace.visibility = new_trace.visibility
|
trace.visibility = new_trace.visibility
|
||||||
trace.save!
|
trace.save!
|
||||||
|
|
||||||
render :text => "", :status => :ok
|
head :ok
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -285,9 +285,9 @@ class TraceController < ApplicationController
|
||||||
trace.visible = false
|
trace.visible = false
|
||||||
trace.save!
|
trace.save!
|
||||||
|
|
||||||
render :text => "", :status => :ok
|
head :ok
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -303,7 +303,7 @@ class TraceController < ApplicationController
|
||||||
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
|
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :text => "", :status => :forbidden
|
head :forbidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -324,14 +324,14 @@ class TraceController < ApplicationController
|
||||||
do_create(params[:file], tags, description, visibility)
|
do_create(params[:file], tags, description, visibility)
|
||||||
|
|
||||||
if @trace.id
|
if @trace.id
|
||||||
render :text => @trace.id.to_s, :content_type => "text/plain"
|
render :plain => @trace.id.to_s
|
||||||
elsif @trace.valid?
|
elsif @trace.valid?
|
||||||
render :text => "", :status => :internal_server_error
|
head :internal_server_error
|
||||||
else
|
else
|
||||||
render :text => "", :status => :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :text => "", :status => :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,7 @@ class UserController < ApplicationController
|
||||||
redirect_to :action => "lost_password"
|
redirect_to :action => "lost_password"
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
render :text => "", :status => :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ class UserController < ApplicationController
|
||||||
if @this_user.visible?
|
if @this_user.visible?
|
||||||
render :action => :api_read, :content_type => "text/xml"
|
render :action => :api_read, :content_type => "text/xml"
|
||||||
else
|
else
|
||||||
render :text => "", :status => :gone
|
head :gone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ class UserController < ApplicationController
|
||||||
@user.traces.reload.each do |trace|
|
@user.traces.reload.each do |trace|
|
||||||
doc.root << trace.to_xml_node
|
doc.root << trace.to_xml_node
|
||||||
end
|
end
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def view
|
def view
|
||||||
|
@ -752,9 +752,7 @@ class UserController < ApplicationController
|
||||||
##
|
##
|
||||||
# require that the user in the URL is the logged in user
|
# require that the user in the URL is the logged in user
|
||||||
def require_self
|
def require_self
|
||||||
if params[:display_name] != @user.display_name
|
head :forbidden if params[:display_name] != @user.display_name
|
||||||
render :text => "", :status => :forbidden
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -20,7 +20,7 @@ class UserPreferenceController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
doc.root << el1
|
doc.root << el1
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -28,7 +28,7 @@ class UserPreferenceController < ApplicationController
|
||||||
def read_one
|
def read_one
|
||||||
pref = UserPreference.find([@user.id, params[:preference_key]])
|
pref = UserPreference.find([@user.id, params[:preference_key]])
|
||||||
|
|
||||||
render :text => pref.v.to_s, :content_type => "text/plain"
|
render :plain => pref.v.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# update the entire set of preferences
|
# update the entire set of preferences
|
||||||
|
@ -57,7 +57,7 @@ class UserPreferenceController < ApplicationController
|
||||||
|
|
||||||
new_preferences.each_value(&:save!)
|
new_preferences.each_value(&:save!)
|
||||||
|
|
||||||
render :text => "", :content_type => "text/plain"
|
render :nothing => true, :content_type => "text/plain"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -74,7 +74,7 @@ class UserPreferenceController < ApplicationController
|
||||||
pref.v = request.raw_post.chomp
|
pref.v = request.raw_post.chomp
|
||||||
pref.save!
|
pref.save!
|
||||||
|
|
||||||
render :text => "", :content_type => "text/plain"
|
render :nothing => true, :content_type => "text/plain"
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -82,6 +82,6 @@ class UserPreferenceController < ApplicationController
|
||||||
def delete_one
|
def delete_one
|
||||||
UserPreference.find([@user.id, params[:preference_key]]).delete
|
UserPreference.find([@user.id, params[:preference_key]]).delete
|
||||||
|
|
||||||
render :text => "", :content_type => "text/plain"
|
render :nothing => true, :content_type => "text/plain"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,7 @@ class WayController < ApplicationController
|
||||||
|
|
||||||
# Assume that Way.from_xml has thrown an exception if there is an error parsing the xml
|
# Assume that Way.from_xml has thrown an exception if there is an error parsing the xml
|
||||||
way.create_with_history @user
|
way.create_with_history @user
|
||||||
render :text => way.id.to_s, :content_type => "text/plain"
|
render :plain => way.id.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
def read
|
def read
|
||||||
|
@ -25,9 +25,9 @@ class WayController < ApplicationController
|
||||||
response.last_modified = way.timestamp
|
response.last_modified = way.timestamp
|
||||||
|
|
||||||
if way.visible
|
if way.visible
|
||||||
render :text => way.to_xml.to_s, :content_type => "text/xml"
|
render :xml => way.to_xml.to_s
|
||||||
else
|
else
|
||||||
render :text => "", :status => :gone
|
head :gone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class WayController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
way.update_from(new_way, @user)
|
way.update_from(new_way, @user)
|
||||||
render :text => way.version.to_s, :content_type => "text/plain"
|
render :plain => way.version.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
# This is the API call to delete a way
|
# This is the API call to delete a way
|
||||||
|
@ -50,9 +50,9 @@ class WayController < ApplicationController
|
||||||
|
|
||||||
if new_way && new_way.id == way.id
|
if new_way && new_way.id == way.id
|
||||||
way.delete_with_history!(new_way, @user)
|
way.delete_with_history!(new_way, @user)
|
||||||
render :text => way.version.to_s, :content_type => "text/plain"
|
render :plain => way.version.to_s
|
||||||
else
|
else
|
||||||
render :text => "", :status => :bad_request
|
head :bad_request
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ class WayController < ApplicationController
|
||||||
end
|
end
|
||||||
doc.root << way.to_xml_node(visible_nodes, changeset_cache, user_display_name_cache)
|
doc.root << way.to_xml_node(visible_nodes, changeset_cache, user_display_name_cache)
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
else
|
else
|
||||||
render :text => "", :status => :gone
|
head :gone
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class WayController < ApplicationController
|
||||||
doc.root << way.to_xml_node
|
doc.root << way.to_xml_node
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
@ -112,6 +112,6 @@ class WayController < ApplicationController
|
||||||
doc.root << way.to_xml_node if way.visible
|
doc.root << way.to_xml_node if way.visible
|
||||||
end
|
end
|
||||||
|
|
||||||
render :text => doc.to_s, :content_type => "text/xml"
|
render :xml => doc.to_s
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1122,7 +1122,7 @@ class UserControllerTest < ActionController::TestCase
|
||||||
basic_authorization(user.email, "test")
|
basic_authorization(user.email, "test")
|
||||||
get :api_gpx_files
|
get :api_gpx_files
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/xml", response.content_type
|
assert_equal "application/xml", response.content_type
|
||||||
|
|
||||||
# check the data that is returned
|
# check the data that is returned
|
||||||
assert_select "gpx_file[id='#{trace1.id}']", 1 do
|
assert_select "gpx_file[id='#{trace1.id}']", 1 do
|
||||||
|
|
|
@ -53,7 +53,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
||||||
# try the read again
|
# try the read again
|
||||||
get :read
|
get :read
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal "text/xml", @response.content_type
|
assert_equal "application/xml", @response.content_type
|
||||||
assert_select "osm" do
|
assert_select "osm" do
|
||||||
assert_select "preferences", :count => 1 do
|
assert_select "preferences", :count => 1 do
|
||||||
assert_select "preference", :count => 2
|
assert_select "preference", :count => 2
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue