]> git.openstreetmap.org Git - rails.git/blob - app/controllers/export_controller.rb
Fix new rubocop warnings
[rails.git] / app / controllers / export_controller.rb
1 class ExportController < ApplicationController
2   before_action :authorize_web
3   before_action :set_locale
4   before_action :update_totp, :only => [:finish]
5   authorize_resource :class => false
6
7   caches_page :embed
8
9   # When the user clicks 'Export' we redirect to a URL which generates the export download
10   def finish
11     bbox = BoundingBox.from_lon_lat_params(params)
12     format = params[:format]
13
14     case format
15     when "osm"
16       # redirect to API map get
17       redirect_to :controller => "api/map", :action => "index", :bbox => bbox
18
19     when "mapnik"
20       # redirect to a special 'export' cgi script
21       format = params[:mapnik_format]
22       scale = params[:mapnik_scale]
23
24       redirect_to "https://render.openstreetmap.org/cgi-bin/export?bbox=#{bbox}&scale=#{scale}&format=#{format}"
25     end
26   end
27
28   def embed
29     append_content_security_policy_directives(
30       :frame_ancestors => %w[*]
31     )
32   end
33 end