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
 
   7   content_security_policy(:only => :embed) do |policy|
 
   8     policy.frame_ancestors("*")
 
  13   # When the user clicks 'Export' we redirect to a URL which generates the export download
 
  15     bbox = BoundingBox.from_lon_lat_params(params)
 
  16     style = params[:format]
 
  17     format = params[:mapnik_format]
 
  21       # redirect to API map get
 
  22       redirect_to api_map_path(:bbox => bbox)
 
  25       # redirect to a special 'export' cgi script
 
  26       scale = params[:mapnik_scale]
 
  27       token = ROTP::TOTP.new(Settings.totp_key, :interval => 3600).now if Settings.totp_key
 
  29       redirect_to "https://render.openstreetmap.org/cgi-bin/export?bbox=#{bbox}&scale=#{scale}&format=#{format}&token=#{token}", :allow_other_host => true
 
  30     when "cyclemap", "transportmap"
 
  34       width = params[:width]
 
  35       height = params[:height]
 
  37       redirect_to "https://tile.thunderforest.com/static/#{style[..-4]}/#{lon},#{lat},#{zoom}/#{width}x#{height}.#{format}?apikey=#{Settings.thunderforest_key}", :allow_other_host => true