Sha256: 954b289b321cea215da656fb87e5b48f19526b1323f580f0e9dca1aa2fe724ae

Contents?: true

Size: 713 Bytes

Versions: 3

Compression:

Stored size: 713 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| URI.encode(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 & 1 rubygems

Version Path
blacklight-oembed-1.0.1 app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-1.0.0 app/controllers/blacklight/oembed/embed_controller.rb
blacklight-oembed-0.3.0 app/controllers/blacklight/oembed/embed_controller.rb