blacklight-oembed 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +15 -7
- data/.solr_wrapper.yml +6 -0
- data/app/components/blacklight/oembed/document_oembed_component.html.erb +3 -0
- data/app/components/blacklight/oembed/document_oembed_component.rb +60 -0
- data/app/controllers/blacklight/oembed/embed_controller.rb +1 -1
- data/app/helpers/blacklight/oembed/oembed_helper.rb +15 -12
- data/app/views/catalog/_oembed_default.html.erb +1 -5
- data/blacklight-oembed.gemspec +1 -1
- data/lib/blacklight/oembed/engine.rb +3 -3
- data/lib/blacklight/oembed/version.rb +1 -1
- data/lib/blacklight/oembed.rb +5 -1
- data/lib/generators/blacklight_oembed/install_generator.rb +13 -4
- data/spec/controllers/embed_controller_spec.rb +1 -2
- data/spec/features/embed_spec.rb +17 -0
- metadata +10 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eca599615d77fa57e306fdcf6348de145160f3d1f1539e52dd032f7cf491c06
|
4
|
+
data.tar.gz: de8590f7211be9ae2509e19247f94074cedb0c42ec28906b991ed1f122f0fd43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7804204d05c70d791e8eb1002fa3c6403d10e1ae09c6ca636e3f637e9e40aa258ae55f31acff8034bf0153b12cafebddf9e95389f3de54849916c5907d537a0
|
7
|
+
data.tar.gz: 55127a170107f36f033db58458a45810a6b222b38daeda9b909a052548fb75740977137d1a15634d554627e90ab3fb23ecae37230fae6727beb0d9f634e92b52
|
data/.github/workflows/ruby.yml
CHANGED
@@ -9,20 +9,28 @@ on:
|
|
9
9
|
jobs:
|
10
10
|
test:
|
11
11
|
runs-on: ubuntu-latest
|
12
|
+
name: test (ruby ${{ matrix.ruby }} / rails ${{ matrix.rails_version }} / blacklight ${{ matrix.blacklight_version }} ${{ matrix.additional_name }})
|
12
13
|
strategy:
|
13
14
|
matrix:
|
14
|
-
ruby: [
|
15
|
-
rails_version: ['
|
15
|
+
ruby: ['3.3']
|
16
|
+
rails_version: ['7.1.4', '7.2.1']
|
16
17
|
blacklight_version: ['~> 7.0']
|
18
|
+
additional_name: ['']
|
19
|
+
legacy_config: ['']
|
17
20
|
include:
|
18
|
-
- ruby: '3.
|
19
|
-
rails_version: '7.
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
- ruby: '3.3'
|
22
|
+
rails_version: '7.2.1'
|
23
|
+
blacklight_version: '~> 8.0'
|
24
|
+
additional_name: ''
|
25
|
+
- ruby: '3.3'
|
26
|
+
rails_version: '7.2.1'
|
27
|
+
blacklight_version: '~> 8.0'
|
28
|
+
additional_name: 'with legacy partial config'
|
29
|
+
legacy_config: 'true'
|
23
30
|
env:
|
24
31
|
RAILS_VERSION: ${{ matrix.rails_version }}
|
25
32
|
BLACKLIGHT_VERSION: ${{ matrix.blacklight_version }}
|
33
|
+
CI_TEST_LEGACY_CONFIGURATION: ${{ matrix.legacy_config }}
|
26
34
|
steps:
|
27
35
|
- uses: actions/checkout@v2
|
28
36
|
- name: Set up Ruby ${{ matrix.ruby }}
|
data/.solr_wrapper.yml
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
module Blacklight
|
2
|
+
module Oembed
|
3
|
+
class DocumentOembedComponent < Blacklight::Component
|
4
|
+
attr_reader :document, :presenter, :classes
|
5
|
+
|
6
|
+
def initialize(document:, presenter:, classes: ['oembed-widget'], **kwargs)
|
7
|
+
super
|
8
|
+
|
9
|
+
@document = document
|
10
|
+
@presenter = presenter
|
11
|
+
@classes = classes
|
12
|
+
end
|
13
|
+
|
14
|
+
def embed
|
15
|
+
return if embed_url.blank?
|
16
|
+
|
17
|
+
@embed ||= if Blacklight::Oembed::Engine.config.render_helper != :render_oembed_tag_async && Blacklight::Oembed::Engine.config.render_helper != :render_oembed_tag_embed
|
18
|
+
legacy_helper_method_embed_markup
|
19
|
+
elsif view_config.render_oembed_using_async_javascript || Blacklight::Oembed::Engine.config.render_helper == :render_oembed_tag_async
|
20
|
+
async_embed_markup
|
21
|
+
else
|
22
|
+
inline_embed_markup
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def render?
|
27
|
+
embed.present?
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def view_config
|
33
|
+
presenter.view_config
|
34
|
+
end
|
35
|
+
|
36
|
+
def embed_url
|
37
|
+
document.first(view_config.oembed_field)
|
38
|
+
end
|
39
|
+
|
40
|
+
def async_embed_url(**kwargs)
|
41
|
+
helpers.blacklight_oembed_engine.embed_url(**kwargs)
|
42
|
+
end
|
43
|
+
|
44
|
+
def async_embed_markup
|
45
|
+
content_tag :div, '', data: { async_embed_url: async_embed_url(url: embed_url) }
|
46
|
+
end
|
47
|
+
|
48
|
+
def inline_embed_markup
|
49
|
+
OEmbed::Providers.get(embed_url).html.html_safe
|
50
|
+
rescue OEmbed::NotFound
|
51
|
+
link_to t(:'blacklight_oembed.catalog.view'), embed_url
|
52
|
+
end
|
53
|
+
|
54
|
+
def legacy_helper_method_embed_markup
|
55
|
+
Blacklight::Oembed.deprecator.warn('Subclass Blacklight::Oembed::DocumentOembedComponent instead of using the blacklight-oembed render_helper config')
|
56
|
+
helpers.call(Blacklight::Oembed::Engine.config.render_helper, url)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -7,7 +7,7 @@ module Blacklight::Oembed
|
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
-
|
10
|
+
def get_embed_content(url, add_params = {})
|
11
11
|
begin
|
12
12
|
OEmbed::Providers.get(url, add_params.transform_values { |v| CGI.escape(v) }).html.html_safe
|
13
13
|
rescue OEmbed::NotFound
|
@@ -1,28 +1,31 @@
|
|
1
1
|
module Blacklight::Oembed
|
2
2
|
module OembedHelper
|
3
|
-
|
4
|
-
def render_oembed_solr_document_tag
|
3
|
+
# @deprecated
|
4
|
+
def render_oembed_solr_document_tag(document)
|
5
5
|
url = document.first(blacklight_config.show.oembed_field)
|
6
6
|
return if url.blank?
|
7
7
|
|
8
8
|
render_oembed_tag url
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
# @deprecated
|
12
|
+
def render_oembed_tag(url)
|
12
13
|
send Blacklight::Oembed::Engine.config.render_helper, url
|
13
14
|
end
|
15
|
+
Blacklight::Oembed.deprecator.deprecate_methods Blacklight::Oembed::OembedHelper,
|
16
|
+
:render_oembed_solr_document_tag, :render_oembed_tag,
|
17
|
+
'Use Blacklight::Oembed::DocumentOembedComponent instead'
|
14
18
|
|
15
19
|
private
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
20
|
+
|
21
|
+
def render_oembed_tag_embed(url)
|
22
|
+
OEmbed::Providers.get(url).html.html_safe
|
23
|
+
rescue OEmbed::NotFound
|
24
|
+
link_to t(:'blacklight_oembed.catalog.view'), url
|
22
25
|
end
|
23
26
|
|
24
|
-
def render_oembed_tag_async
|
25
|
-
content_tag :div,
|
27
|
+
def render_oembed_tag_async(url)
|
28
|
+
content_tag :div, '', data: { embed_url: blacklight_oembed_engine.embed_url(url: url) }
|
26
29
|
end
|
27
30
|
end
|
28
|
-
end
|
31
|
+
end
|
data/blacklight-oembed.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
20
|
spec.add_dependency "rails"
|
21
|
-
spec.add_dependency 'blacklight', '>= 7.
|
21
|
+
spec.add_dependency 'blacklight', '>= 7.25', '< 9'
|
22
22
|
spec.add_dependency "ruby-oembed"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", ">= 1.5"
|
@@ -3,13 +3,13 @@ require 'blacklight'
|
|
3
3
|
module Blacklight
|
4
4
|
module Oembed
|
5
5
|
class Engine < Rails::Engine
|
6
|
+
# @deprecated
|
7
|
+
config.render_helper = :render_oembed_tag_async
|
6
8
|
|
7
|
-
Blacklight::Oembed::Engine.config.render_helper = :render_oembed_tag_async
|
8
9
|
##
|
9
10
|
# Allows an adopter to pass additional parameters through to an OEmbed
|
10
11
|
# service. Examples of this could include `:canvas_index`, or `:max_width`
|
11
|
-
|
12
|
-
|
12
|
+
config.additional_params = []
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/blacklight/oembed.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
require
|
1
|
+
require 'blacklight/oembed/version'
|
2
2
|
require 'oembed'
|
3
3
|
module Blacklight
|
4
4
|
module Oembed
|
5
|
+
def self.deprecator
|
6
|
+
@deprecator ||= ActiveSupport::Deprecation.new('2.0.0', 'blacklight-oembed')
|
7
|
+
end
|
8
|
+
|
5
9
|
require 'blacklight/oembed/engine'
|
6
10
|
end
|
7
11
|
end
|
@@ -19,12 +19,21 @@ module BlacklightOembed
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def configuration
|
22
|
-
inject_into_file 'app/controllers/catalog_controller.rb', after:
|
23
|
-
|
22
|
+
inject_into_file 'app/controllers/catalog_controller.rb', after: 'configure_blacklight do |config|' do
|
23
|
+
if ENV['CI_TEST_LEGACY_CONFIGURATION'].present? || Gem::Version.new(Blacklight::VERSION) < Gem::Version.new('8.0')
|
24
|
+
<<-EOF
|
25
|
+
|
26
|
+
config.show.oembed_field = :oembed_url_ssm
|
27
|
+
config.show.partials.insert(1, :oembed)
|
28
|
+
EOF
|
29
|
+
else
|
30
|
+
<<-EOF
|
24
31
|
|
25
32
|
config.show.oembed_field = :oembed_url_ssm
|
26
|
-
config.show.
|
27
|
-
|
33
|
+
config.show.render_oembed_using_async_javascript = true
|
34
|
+
config.show.embed_component = Blacklight::Oembed::DocumentOembedComponent
|
35
|
+
EOF
|
36
|
+
end
|
28
37
|
end
|
29
38
|
end
|
30
39
|
end
|
@@ -7,8 +7,7 @@ describe Blacklight::Oembed::EmbedController do
|
|
7
7
|
render_views
|
8
8
|
|
9
9
|
before do
|
10
|
-
Blacklight::Oembed::Engine.config.
|
11
|
-
Blacklight::Oembed::Engine.config.additional_params = [:canvas_index, :suggested_search]
|
10
|
+
Blacklight::Oembed::Engine.config.additional_params = %i[canvas_index suggested_search]
|
12
11
|
end
|
13
12
|
|
14
13
|
let :oembed_obj do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe 'Embed', type: :feature do
|
4
|
+
before do
|
5
|
+
CatalogController.blacklight_config.show.oembed_field = :id
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'embeds the widget on the show page' do
|
9
|
+
visit '/catalog/2007020969'
|
10
|
+
|
11
|
+
expect(page).to have_css '.oembed-widget'
|
12
|
+
|
13
|
+
embed_div = find('.oembed-widget div')
|
14
|
+
|
15
|
+
expect(embed_div['data-async-embed-url']).to include '/oembed/embed?url=2007020969'
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-oembed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '7.
|
33
|
+
version: '7.25'
|
34
34
|
- - "<"
|
35
35
|
- !ruby/object:Gem::Version
|
36
36
|
version: '9'
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: '7.
|
43
|
+
version: '7.25'
|
44
44
|
- - "<"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '9'
|
@@ -207,11 +207,14 @@ extra_rdoc_files: []
|
|
207
207
|
files:
|
208
208
|
- ".github/workflows/ruby.yml"
|
209
209
|
- ".gitignore"
|
210
|
+
- ".solr_wrapper.yml"
|
210
211
|
- Gemfile
|
211
212
|
- LICENSE
|
212
213
|
- README.md
|
213
214
|
- Rakefile
|
214
215
|
- app/assets/javascripts/blacklight_oembed/jquery.oembed.js
|
216
|
+
- app/components/blacklight/oembed/document_oembed_component.html.erb
|
217
|
+
- app/components/blacklight/oembed/document_oembed_component.rb
|
215
218
|
- app/controllers/blacklight/oembed/embed_controller.rb
|
216
219
|
- app/helpers/blacklight/oembed/oembed_helper.rb
|
217
220
|
- app/views/catalog/_oembed_default.html.erb
|
@@ -245,6 +248,7 @@ files:
|
|
245
248
|
- solr/conf/xslt/luke.xsl
|
246
249
|
- solr/sample_solr_documents.yml
|
247
250
|
- spec/controllers/embed_controller_spec.rb
|
251
|
+
- spec/features/embed_spec.rb
|
248
252
|
- spec/helpers/oembed_helper_spec.rb
|
249
253
|
- spec/spec_helper.rb
|
250
254
|
- spec/test_app_templates/Gemfile.extra
|
@@ -268,12 +272,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
272
|
- !ruby/object:Gem::Version
|
269
273
|
version: '0'
|
270
274
|
requirements: []
|
271
|
-
rubygems_version: 3.
|
275
|
+
rubygems_version: 3.5.9
|
272
276
|
signing_key:
|
273
277
|
specification_version: 4
|
274
278
|
summary: Oembed display for Blacklight
|
275
279
|
test_files:
|
276
280
|
- spec/controllers/embed_controller_spec.rb
|
281
|
+
- spec/features/embed_spec.rb
|
277
282
|
- spec/helpers/oembed_helper_spec.rb
|
278
283
|
- spec/spec_helper.rb
|
279
284
|
- spec/test_app_templates/Gemfile.extra
|