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