Sha256: 8302e0041acec88ff6b19c8694430d597dc030392c97a9e67a6893ec5b350c77

Contents?: true

Size: 731 Bytes

Versions: 3

Compression:

Stored size: 731 Bytes

Contents

module Blacklight::Oembed
  class EmbedController < ActionController::Base

    def show
      render json: { html: get_embed_content(params[:url], additional_params) }
    end

    private

    ruby2_keywords def get_embed_content(url, add_params = {})
      begin
        OEmbed::Providers.get(url, add_params.transform_values { |v| CGI.escape(v) }).html.html_safe
      rescue OEmbed::NotFound
        response.status = 400
        ""
      end
    end

    ##
    # Allows for blacklight-oembed users to pass through additional configured
    # parameters
    def additional_params
      params
        .slice(*Blacklight::Oembed::Engine.config.additional_params)
        .to_unsafe_h
        .symbolize_keys
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/blacklight-oembed-1.1.1/app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-1.1.1 app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-1.1.0 app/controllers/blacklight/oembed/embed_controller.rb