Skip to content

Commit

Permalink
Refactor OembedController
Browse files Browse the repository at this point in the history
  • Loading branch information
afred committed Dec 4, 2023
1 parent 95140eb commit 4de7212
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions app/controllers/oembed_controller.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,36 @@
require_relative '../../lib/aapb'

class OembedController < CatalogController

def show

puts "\n\nparams = #{params}\n\n"

render json: {
"title": "Test",
"type": "rich",
"width": "640",
"height": "480",
"html": "<p>Blah blah blah</p>",
"title": pbcore_presenter.title,
"type": "video/mp4",
"width": "1640",
"height": "1480",
"src": "https://americanarchive.org/embed/#{pbcore_presenter.id}",
}
end


private

def pbcore_presenter
@pbcore_presenter ||= PBCorePresenter.new(solr_doc['xml'])
end

def solr_doc
@solr_doc ||= begin
_resp, doc = fetch_from_solr(id_from_url_param)
raise Blacklight::Exceptions::RecordNotFound unless doc
doc
end
end

def id_from_url_param
@id_from_url_param ||= begin
uri = URI.parse(params['url'])
path_parts = uri.path.split('/')
path_parts.detect {|path_part| path_part =~ /^cpb\-aacip/}
end
end
end

0 comments on commit 4de7212

Please sign in to comment.