response.headers["Content-Disposition"] = "attachment; filename=\"tracks.gpx\""
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
# This is probably the most common call of all. It is used for getting the
response.headers["Content-Disposition"] = "attachment; filename=\"map.osm\""
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
# Get a list of the tiles that have changed within a specified time
doc.root << changes
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
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
policy << blacklist
doc.root << policy
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
# External apps that use the api are able to query which permissions
if request.get?
redirect_to :controller => "user", :action => "login", :referer => request.fullpath
else
- render :text => "", :status => :forbidden
+ head :forbidden
end
end
end
flash[:error] = t("application.require_moderator.not_a_moderator")
redirect_to :action => "index"
else
- render :text => "", :status => :forbidden
+ head :forbidden
end
end
end
unless @user
# no auth, the user does not exist or the password was wrong
response.headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\""
- render :text => errormessage, :status => :unauthorized
+ render :plain => errormessage, :status => :unauthorized
return false
end
end
def authorize_moderator(errormessage = "Access restricted to moderators")
# check user is a moderator
unless @user.moderator?
- render :text => errormessage, :status => :forbidden
+ render :plain => errormessage, :status => :forbidden
false
end
end
result.root << (XML::Node.new("status") << "#{Rack::Utils.status_code(status)} #{Rack::Utils::HTTP_STATUS_CODES[status]}")
result.root << (XML::Node.new("message") << message)
- render :text => result.to_s, :content_type => "text/xml"
+ render :xml => result.to_s
else
- render :text => message, :status => status, :content_type => "text/plain"
+ render :plain => message, :status => status
end
end
def api_call_handle_error
yield
rescue ActiveRecord::RecordNotFound => ex
- render :text => "", :status => :not_found
+ head :not_found
rescue LibXML::XML::Error, ArgumentError => ex
report_error ex.message, :bad_request
rescue ActiveRecord::RecordInvalid => ex
respond_to do |format|
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
# Subscribe user to changeset comments
cs.subscribers << @user
- render :text => cs.id.to_s, :content_type => "text/plain"
+ render :plain => cs.id.to_s
end
##
def read
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
##
changeset.set_closed_time_now
changeset.save!
- render :text => ""
+ render :nothing => true
end
##
# save the larger bounding box and return the changeset, which
# will include the bigger bounding box.
cs.save!
- render :text => cs.to_xml.to_s, :content_type => "text/xml"
+ render :xml => cs.to_xml.to_s
end
##
diff_reader = DiffReader.new(request.raw_post, changeset)
Changeset.transaction do
result = diff_reader.commit
- render :text => result.to_s, :content_type => "text/xml"
+ render :xml => result.to_s
end
end
end
end
- render :text => result.to_s, :content_type => "text/xml"
+ render :xml => result.to_s
end
##
results.root << cs.to_xml_node
end
- render :text => results.to_s, :content_type => "text/xml"
+ render :xml => results.to_s
end
##
check_changeset_consistency(changeset, @user)
changeset.update_from(new_changeset, @user)
- render :text => changeset.to_xml, :mime_type => "text/xml"
+ render :xml => changeset.to_xml
end
##
changeset.subscribers << @user unless changeset.subscribers.exists?(@user.id)
# 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
##
changeset.subscribers << @user
# 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
##
changeset.subscribers.delete(@user)
# 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
##
comment.update(:visible => false)
# 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
##
comment.update(:visible => true)
# 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
##
format.rss
end
rescue OSM::APIBadUserInput
- render :text => "", :status => :bad_request
+ head :bad_request
end
private
@description = I18n.t("diary_entry.feed.user.description", :user => user.display_name)
@link = "http://#{SERVER_URL}/user/#{user.display_name}/diary"
else
- render :text => "", :status => :not_found
+ head :not_found
return
end
else
end
if @sources.empty?
- render :text => "", :status => :bad_request
+ head :bad_request
else
render :layout => map_layout
end
# Assume that Node.from_xml has thrown an exception if there is an error parsing the xml
node.create_with_history @user
- render :text => node.id.to_s, :content_type => "text/plain"
+ render :plain => node.id.to_s
end
# Dump the details on a node given in params[:id]
response.last_modified = node.timestamp
if node.visible
- render :text => node.to_xml.to_s, :content_type => "text/xml"
+ render :xml => node.to_xml.to_s
else
- render :text => "", :status => :gone
+ head :gone
end
end
end
node.update_from(new_node, @user)
- render :text => node.version.to_s, :content_type => "text/plain"
+ render :plain => node.version.to_s
end
# Delete a node. Doesn't actually delete it, but retains its history
raise OSM::APIBadUserInput.new("The id in the url (#{node.id}) is not the same as provided in the xml (#{new_node.id})")
end
node.delete_with_history!(new_node, @user)
- render :text => node.version.to_s, :content_type => "text/plain"
+ render :plain => node.version.to_s
end
# Dump the details on many nodes whose ids are given in the "nodes" parameter.
doc.root << node.to_xml_node
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
end
doc.root << element.to_xml_node
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
def version
if @old_element.redacted? && !show_redactions?
- render :text => "", :status => :forbidden
+ head :forbidden
else
response.last_modified = @old_element.timestamp
doc = OSM::API.new.get_xml_doc
doc.root << @old_element.to_xml_node
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
end
end
# just return an empty 200 OK for success
- render :text => ""
+ render :nothing => true
end
private
# Assume that Relation.from_xml has thrown an exception if there is an error parsing the xml
relation.create_with_history @user
- render :text => relation.id.to_s, :content_type => "text/plain"
+ render :plain => relation.id.to_s
end
def read
relation = Relation.find(params[:id])
response.last_modified = relation.timestamp
if relation.visible
- render :text => relation.to_xml.to_s, :content_type => "text/xml"
+ render :xml => relation.to_xml.to_s
else
- render :text => "", :status => :gone
+ head :gone
end
end
end
relation.update_from new_relation, @user
- render :text => relation.version.to_s, :content_type => "text/plain"
+ render :plain => relation.version.to_s
end
def delete
new_relation = Relation.from_xml(request.raw_post)
if new_relation && new_relation.id == relation.id
relation.delete_with_history!(new_relation, @user)
- render :text => relation.version.to_s, :content_type => "text/plain"
+ render :plain => relation.version.to_s
else
- render :text => "", :status => :bad_request
+ head :bad_request
end
end
# finally add self and output
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
- render :text => "", :status => :gone
+ head :gone
end
end
doc.root << relation.to_xml_node
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
def relations_for_way
doc.root << relation.to_xml_node if relation.visible
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
end
if do_nodes
response.headers["Error"] = "Searching of nodes is currently unavailable"
- render :text => "", :status => :service_unavailable
+ head :service_unavailable
return false
end
unless value
response.headers["Error"] = "Searching for a key without value is currently unavailable"
- render :text => "", :status => :service_unavailable
+ head :service_unavailable
return false
end
doc.root << rel.to_xml_node(nil, changeset_cache, user_display_name_cache)
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
end
def offline; end
def preview
- render :text => RichText.new(params[:format], params[:text]).to_html
+ render :html => RichText.new(params[:format], params[:text]).to_html
end
def id
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
- render :text => m, :content_type => "application/x-shockwave-flash"
+ render :body => m, :content_type => "application/x-shockwave-flash"
end
private
if trace.visible? && (trace.public? || (@user && @user == trace.user))
if Acl.no_trace_download(request.remote_ip)
- render :text => "", :status => :forbidden
+ head :forbidden
elsif request.format == Mime::XML
send_file(trace.xml_file, :filename => "#{trace.id}.xml", :type => request.format.to_s, :disposition => "attachment")
elsif request.format == Mime::GPX
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
end
else
- render :text => "", :status => :not_found
+ head :not_found
end
rescue ActiveRecord::RecordNotFound
- render :text => "", :status => :not_found
+ head :not_found
end
def edit
@trace = Trace.find(params[:id])
if !@trace.visible?
- render :text => "", :status => :not_found
+ head :not_found
elsif @user.nil? || @trace.user != @user
- render :text => "", :status => :forbidden
+ head :forbidden
else
@title = t "trace.edit.title", :name => @trace.name
end
end
rescue ActiveRecord::RecordNotFound
- render :text => "", :status => :not_found
+ head :not_found
end
def delete
trace = Trace.find(params[:id])
if !trace.visible?
- render :text => "", :status => :not_found
+ head :not_found
elsif @user.nil? || trace.user != @user
- render :text => "", :status => :forbidden
+ head :forbidden
else
trace.visible = false
trace.save
redirect_to :action => :list, :display_name => @user.display_name
end
rescue ActiveRecord::RecordNotFound
- render :text => "", :status => :not_found
+ head :not_found
end
def georss
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")
else
- render :text => "", :status => :forbidden
+ head :forbidden
end
else
- render :text => "", :status => :not_found
+ head :not_found
end
rescue ActiveRecord::RecordNotFound
- render :text => "", :status => :not_found
+ head :not_found
end
def icon
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")
else
- render :text => "", :status => :forbidden
+ head :forbidden
end
else
- render :text => "", :status => :not_found
+ head :not_found
end
rescue ActiveRecord::RecordNotFound
- render :text => "", :status => :not_found
+ head :not_found
end
def api_read
trace = Trace.visible.find(params[:id])
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
- render :text => "", :status => :forbidden
+ head :forbidden
end
end
trace.visibility = new_trace.visibility
trace.save!
- render :text => "", :status => :ok
+ head :ok
else
- render :text => "", :status => :forbidden
+ head :forbidden
end
end
trace.visible = false
trace.save!
- render :text => "", :status => :ok
+ head :ok
else
- render :text => "", :status => :forbidden
+ head :forbidden
end
end
send_file(trace.trace_name, :filename => "#{trace.id}#{trace.extension_name}", :type => trace.mime_type, :disposition => "attachment")
end
else
- render :text => "", :status => :forbidden
+ head :forbidden
end
end
do_create(params[:file], tags, description, visibility)
if @trace.id
- render :text => @trace.id.to_s, :content_type => "text/plain"
+ render :plain => @trace.id.to_s
elsif @trace.valid?
- render :text => "", :status => :internal_server_error
+ head :internal_server_error
else
- render :text => "", :status => :bad_request
+ head :bad_request
end
else
- render :text => "", :status => :bad_request
+ head :bad_request
end
end
redirect_to :action => "lost_password"
end
else
- render :text => "", :status => :bad_request
+ head :bad_request
end
end
if @this_user.visible?
render :action => :api_read, :content_type => "text/xml"
else
- render :text => "", :status => :gone
+ head :gone
end
end
@user.traces.reload.each do |trace|
doc.root << trace.to_xml_node
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
def view
##
# require that the user in the URL is the logged in user
def require_self
- if params[:display_name] != @user.display_name
- render :text => "", :status => :forbidden
- end
+ head :forbidden if params[:display_name] != @user.display_name
end
##
end
doc.root << el1
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
##
def read_one
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
# update the entire set of preferences
new_preferences.each_value(&:save!)
- render :text => "", :content_type => "text/plain"
+ render :nothing => true, :content_type => "text/plain"
end
##
pref.v = request.raw_post.chomp
pref.save!
- render :text => "", :content_type => "text/plain"
+ render :nothing => true, :content_type => "text/plain"
end
##
def delete_one
UserPreference.find([@user.id, params[:preference_key]]).delete
- render :text => "", :content_type => "text/plain"
+ render :nothing => true, :content_type => "text/plain"
end
end
# Assume that Way.from_xml has thrown an exception if there is an error parsing the xml
way.create_with_history @user
- render :text => way.id.to_s, :content_type => "text/plain"
+ render :plain => way.id.to_s
end
def read
response.last_modified = way.timestamp
if way.visible
- render :text => way.to_xml.to_s, :content_type => "text/xml"
+ render :xml => way.to_xml.to_s
else
- render :text => "", :status => :gone
+ head :gone
end
end
end
way.update_from(new_way, @user)
- render :text => way.version.to_s, :content_type => "text/plain"
+ render :plain => way.version.to_s
end
# This is the API call to delete a way
if new_way && new_way.id == way.id
way.delete_with_history!(new_way, @user)
- render :text => way.version.to_s, :content_type => "text/plain"
+ render :plain => way.version.to_s
else
- render :text => "", :status => :bad_request
+ head :bad_request
end
end
end
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
- render :text => "", :status => :gone
+ head :gone
end
end
doc.root << way.to_xml_node
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
##
doc.root << way.to_xml_node if way.visible
end
- render :text => doc.to_s, :content_type => "text/xml"
+ render :xml => doc.to_s
end
end
basic_authorization(user.email, "test")
get :api_gpx_files
assert_response :success
- assert_equal "text/xml", response.content_type
+ assert_equal "application/xml", response.content_type
# check the data that is returned
assert_select "gpx_file[id='#{trace1.id}']", 1 do
# try the read again
get :read
assert_response :success
- assert_equal "text/xml", @response.content_type
+ assert_equal "application/xml", @response.content_type
assert_select "osm" do
assert_select "preferences", :count => 1 do
assert_select "preference", :count => 2