Sha256: 3c4e3660216baa386dc43d545c27f1b99e6121fd66dfab44e333fda45f54e743

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 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).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

1 entries across 1 versions & 1 rubygems

Version Path
blacklight-oembed-0.2.0 app/controllers/blacklight/oembed/embed_controller.rb