]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/site_controller.rb
Merge remote-tracking branch 'upstream/pull/5499'
[rails.git] / app / controllers / site_controller.rb
index 8b742a585c0e8f7519fb1019222cbcf88216e513..9adbaa1953fd9fe774bf9bb90eb130da53aed90e 100644 (file)
@@ -19,11 +19,12 @@ class SiteController < ApplicationController
   content_security_policy(:only => :id) do |policy|
     policy.connect_src("*")
     policy.img_src(*policy.img_src, "*", :blob)
+    policy.script_src(*policy.script_src, :unsafe_eval)
     policy.style_src(*policy.style_src, :unsafe_inline)
   end
 
   def index
-    session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"]) unless Settings.status == "database_readonly" || Settings.status == "database_offline"
+    session[:location] ||= OSM.ip_location(request.env["REMOTE_ADDR"]) unless %w[database_readonly database_offline].include?(Settings.status)
   end
 
   def permalink
@@ -109,6 +110,7 @@ class SiteController < ApplicationController
   end
 
   def copyright
+    @title = t ".title"
     @locale = params[:copyright_locale] || I18n.locale
   end
 
@@ -136,7 +138,12 @@ class SiteController < ApplicationController
   end
 
   def preview
-    render :html => RichText.new(params[:type], params[:text]).to_html
+    if params[:text].blank?
+      flash.now[:warning] = t("layouts.nothing_to_preview")
+      render :partial => "layouts/flash"
+    else
+      render :html => RichText.new(params[:type], params[:text]).to_html
+    end
   end
 
   def id