Sha256: e25ee5e7642380bc8f4ea1cebda06f8a4e6725add611bc96d64b22133159f1f2

Contents?: true

Size: 941 Bytes

Versions: 11

Compression:

Stored size: 941 Bytes

Contents

# frozen_string_literal: true

module Decidim
  module DecidimAwesome
    module IframeComponent
      class IframeController < DecidimAwesome::IframeComponent::ApplicationController
        ALLOWED_ATTRIBUTES = %w(src width height frameborder title allow allowpaymentrequest name referrerpolicy sandbox srcdoc allowfullscreen).freeze
        helper_method :iframe, :remove_margins?, :viewport_width?

        def show; end

        private

        def iframe
          @iframe ||= sanitize(current_component.settings.iframe).html_safe
        end

        def sanitize(html)
          sanitizer = Rails::Html::SafeListSanitizer.new
          sanitizer.sanitize(html, tags: %w(iframe), attributes: ALLOWED_ATTRIBUTES)
        end

        def remove_margins?
          current_component.settings.no_margins
        end

        def viewport_width?
          current_component.settings.viewport_width
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
decidim-decidim_awesome-0.7.2 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.7.0 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.7 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.6 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.5 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.4 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.3 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.2 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.1 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.6.0 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb
decidim-decidim_awesome-0.5.1 app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb