blacklight-oembed 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/blacklight_oembed/jquery.oembed.js +20 -0
- data/app/controllers/blacklight/oembed/embed_controller.rb +18 -0
- data/app/helpers/blacklight/oembed/oembed_helper.rb +10 -0
- data/config/routes.rb +3 -0
- data/lib/blacklight/oembed/engine.rb +2 -4
- data/lib/blacklight/oembed/version.rb +1 -1
- data/lib/generators/blacklight_oembed/install_generator.rb +7 -0
- data/lib/generators/blacklight_oembed/templates/blacklight_oembed.js +5 -0
- data/lib/generators/blacklight_oembed/templates/oembed_providers.rb +3 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c5f0dcab275875e50d436e29e825e8a3f97fc7b
|
4
|
+
data.tar.gz: 28c6ba94fed961104b93b5231785d4ead1b1ab68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3409a00f0b28fe9b0f50468c63808cb32a73e245436772a727803486c2245b436c27fdce182475824c88fe823c3c63dbee9a9be06e354db6c90d953c98fef48
|
7
|
+
data.tar.gz: e9cfa06132ee45d72f3cd17e2711957486dd25466d7d2698f92ce0edc5042f8f71ab9c1809c75604b39893fdfc2638b25e6b5ec679f3b1313b9a7600becc1ce8
|
@@ -0,0 +1,20 @@
|
|
1
|
+
(function(){
|
2
|
+
$.fn.oEmbed = function() {
|
3
|
+
|
4
|
+
return this.each(function(){
|
5
|
+
var $embedViewer = $(this);
|
6
|
+
var $embedURL = $embedViewer.data('embed-url');
|
7
|
+
init();
|
8
|
+
|
9
|
+
function init(){
|
10
|
+
$.getJSON($embedURL, function(data){
|
11
|
+
if (data === null){
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
$embedViewer.html(data.html);
|
15
|
+
});
|
16
|
+
}
|
17
|
+
});
|
18
|
+
};
|
19
|
+
|
20
|
+
})(jQuery);
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Blacklight::Oembed
|
2
|
+
class EmbedController < ActionController::Metal
|
3
|
+
def show
|
4
|
+
self.content_type = "application/json"
|
5
|
+
self.response_body = { html: get_embed_content(params[:url]) }.to_json
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def get_embed_content url
|
11
|
+
begin
|
12
|
+
OEmbed::Providers.get(url).html.html_safe
|
13
|
+
rescue OEmbed::NotFound
|
14
|
+
link_to I18n.t(:'blacklight_oembed.catalog.view'), url
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,15 +1,25 @@
|
|
1
1
|
module Blacklight::Oembed
|
2
2
|
module OembedHelper
|
3
|
+
|
3
4
|
def render_oembed_tag document
|
4
5
|
url = document.first(blacklight_config.show.oembed_field)
|
5
6
|
|
6
7
|
return if url.blank?
|
7
8
|
|
9
|
+
send Blacklight::Oembed::Engine.config.render_helper, url
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def render_oembed_tag_embed url
|
8
14
|
begin
|
9
15
|
OEmbed::Providers.get(url).html.html_safe
|
10
16
|
rescue OEmbed::NotFound
|
11
17
|
link_to t(:'blacklight_oembed.catalog.view'), url
|
12
18
|
end
|
13
19
|
end
|
20
|
+
|
21
|
+
def render_oembed_tag_async url
|
22
|
+
content_tag :div, "", data: { embed_url: blacklight_oembed_engine.embed_url(url: url) }
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
data/config/routes.rb
CHANGED
@@ -3,10 +3,8 @@ require 'blacklight'
|
|
3
3
|
module Blacklight
|
4
4
|
module Oembed
|
5
5
|
class Engine < Rails::Engine
|
6
|
-
|
7
|
-
|
8
|
-
OEmbed::Providers.register_all
|
9
|
-
end
|
6
|
+
|
7
|
+
Blacklight::Oembed::Engine.config.render_helper = :render_oembed_tag_async
|
10
8
|
|
11
9
|
end
|
12
10
|
end
|
@@ -10,6 +10,13 @@ module BlacklightOembed
|
|
10
10
|
copy_file "blacklight_oembed.js", "app/assets/javascripts/blacklight_oembed.js"
|
11
11
|
end
|
12
12
|
|
13
|
+
def inject_routes
|
14
|
+
route "mount Blacklight::Oembed::Engine, at: 'oembed'"
|
15
|
+
end
|
16
|
+
|
17
|
+
def inject_oembed_configuration
|
18
|
+
copy_file "oembed_providers.rb", "config/initializers/oembed_providers.rb"
|
19
|
+
end
|
13
20
|
|
14
21
|
def configuration
|
15
22
|
inject_into_file 'app/controllers/catalog_controller.rb', after: "configure_blacklight do |config|" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-oembed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -219,6 +219,8 @@ files:
|
|
219
219
|
- LICENSE
|
220
220
|
- README.md
|
221
221
|
- Rakefile
|
222
|
+
- app/assets/javascripts/blacklight_oembed/jquery.oembed.js
|
223
|
+
- app/controllers/blacklight/oembed/embed_controller.rb
|
222
224
|
- app/helpers/blacklight/oembed/oembed_helper.rb
|
223
225
|
- app/views/catalog/_oembed_default.html.erb
|
224
226
|
- blacklight-oembed.gemspec
|
@@ -231,6 +233,7 @@ files:
|
|
231
233
|
- lib/generators/blacklight_oembed/install_generator.rb
|
232
234
|
- lib/generators/blacklight_oembed/templates/blacklight_oembed.css.scss
|
233
235
|
- lib/generators/blacklight_oembed/templates/blacklight_oembed.js
|
236
|
+
- lib/generators/blacklight_oembed/templates/oembed_providers.rb
|
234
237
|
- spec/spec_helper.rb
|
235
238
|
- spec/test_app_templates/lib/generators/test_app_generator.rb
|
236
239
|
homepage: https://github.com/sul-dlss/blacklight-oembed
|