Sha256: 447187ce2caa962fb506ac3949cae6e367681ae4334cc813799097675224d88a

Contents?: true

Size: 716 Bytes

Versions: 5

Compression:

Stored size: 716 Bytes

Contents

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

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

    private

    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

5 entries across 5 versions & 1 rubygems

Version Path
blacklight-oembed-1.4.2 app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-1.4.1 app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-1.4.0 app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-1.3.0 app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-1.2.0 app/controllers/blacklight/oembed/embed_controller.rb