1 # frozen_string_literal: true
3 class ExportController < ApplicationController
4 before_action :authorize_web
5 before_action :set_locale
6 before_action :update_totp, :only => [:finish]
7 authorize_resource :class => false
9 content_security_policy(:only => :embed) do |policy|
10 policy.frame_ancestors("*")
15 # When the user clicks 'Export' we redirect to a URL which generates the export download
17 bbox = BoundingBox.from_lon_lat_params(params)
18 style = params[:format]
19 format = params[:mapnik_format]
23 # redirect to API map get
24 redirect_to api_map_path(:bbox => bbox)
27 # redirect to a special 'export' cgi script
28 scale = params[:mapnik_scale]
29 token = ROTP::TOTP.new(Settings.totp_key, :interval => 3600).now if Settings.totp_key
31 redirect_to "https://render.openstreetmap.org/cgi-bin/export?bbox=#{bbox}&scale=#{scale}&format=#{format}&token=#{token}", :allow_other_host => true
32 when "cyclemap", "transportmap"
36 width = params[:width]
37 height = params[:height]
39 redirect_to "https://tile.thunderforest.com/static/#{style[..-4]}/#{lon},#{lat},#{zoom}/#{width}x#{height}.#{format}?apikey=#{Settings.thunderforest_key}", :allow_other_host => true