hyrax-iiif_av 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/hyrax/iiif_av/controller_behavior.rb +0 -1
- data/{lib → app/models}/hyrax/iiif_av/manifest_range.rb +0 -0
- data/app/presenters/concerns/hyrax/iiif_av/displays_content.rb +26 -16
- data/app/presenters/concerns/hyrax/iiif_av/displays_iiif_av.rb +2 -5
- data/hyrax-iiif_av.gemspec +1 -1
- data/lib/generators/hyrax/iiif_av/templates/_avalon.html.erb +1 -1
- data/lib/hyrax/iiif_av.rb +20 -1
- data/lib/hyrax/iiif_av/configuration.rb +21 -0
- data/lib/hyrax/iiif_av/spec/shared_specs/displays_content.rb +26 -3
- data/lib/hyrax/iiif_av/spec/shared_specs/displays_iiif_av.rb +1 -1
- data/lib/hyrax/iiif_av/version.rb +1 -1
- metadata +6 -8
- data/app/helpers/hyrax/iiif_av/iiif_av_helper.rb +0 -40
- data/app/views/hyrax/base/_representative_media.html.erb +0 -27
- data/app/views/hyrax/base/iiif_viewers/_universal_viewer.html.erb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1048d5bad3dcabb9cfbaa7617e7ac7e325e650bf
|
4
|
+
data.tar.gz: b53798072660f48f69438f5569eb8b51451c8b7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f9759d67ab956c8aa7e2b1f09efe2ba53c17e9922c45d2317b4f2248a14d6503a6587231d113b6daf3ce85228be9bf3b4e3df6d3f60f41f33fcedd8d66398c9
|
7
|
+
data.tar.gz: 9cf31dba99e9c3c2b646c08f06889b4d55c625752f7dcce859b4b654a453e57977da2afed310b0875ac5f835d868836559431d0a3d4100380fa90a9e46f37d62
|
File without changes
|
@@ -76,18 +76,12 @@ module Hyrax
|
|
76
76
|
|
77
77
|
def video_content
|
78
78
|
# @see https://github.com/samvera-labs/iiif_manifest
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
uri = URI(f['external_file_uri'])
|
85
|
-
uri = URI.join(request.base_url, uri) if uri.relative?
|
86
|
-
video_display_content(uri, f['label'])
|
87
|
-
end
|
88
|
-
end
|
79
|
+
streams = stream_urls
|
80
|
+
if streams.present?
|
81
|
+
streams.collect { |label, url| video_display_content(url, label) }
|
82
|
+
else
|
83
|
+
[video_display_content(download_path('mp4'), 'mp4'), video_display_content(download_path('webm'), 'webm')]
|
89
84
|
end
|
90
|
-
[video_display_content(download_path('mp4'), 'mp4'), video_display_content(download_path('webm'), 'webm')]
|
91
85
|
end
|
92
86
|
|
93
87
|
def video_display_content(url, label = '')
|
@@ -100,12 +94,12 @@ module Hyrax
|
|
100
94
|
end
|
101
95
|
|
102
96
|
def audio_content
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
97
|
+
streams = stream_urls
|
98
|
+
if streams.present?
|
99
|
+
streams.collect { |label, url| audio_display_content(url, label) }
|
100
|
+
else
|
101
|
+
[audio_display_content(download_path('ogg'), 'ogg'), audio_display_content(download_path('mp3'), 'mp3')]
|
107
102
|
end
|
108
|
-
[audio_display_content(download_path('ogg'), 'ogg'), audio_display_content(download_path('mp3'), 'mp3')]
|
109
103
|
end
|
110
104
|
|
111
105
|
def audio_display_content(url, label = '')
|
@@ -118,6 +112,22 @@ module Hyrax
|
|
118
112
|
def download_path(extension)
|
119
113
|
Hyrax::Engine.routes.url_helpers.download_url(solr_document, file: extension, host: request.base_url)
|
120
114
|
end
|
115
|
+
|
116
|
+
def stream_urls
|
117
|
+
return {} unless solr_document['derivatives_metadata_ssi'].present?
|
118
|
+
files_metadata = JSON.parse(solr_document['derivatives_metadata_ssi'])
|
119
|
+
file_locations = files_metadata.select { |f| f['file_location_uri'].present? }
|
120
|
+
streams = {}
|
121
|
+
if file_locations.present?
|
122
|
+
file_locations.each do |f|
|
123
|
+
streams[f['label']] = Hyrax::IiifAv.config.iiif_av_url_builder.call(
|
124
|
+
f['file_location_uri'],
|
125
|
+
request.base_url
|
126
|
+
)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
streams
|
130
|
+
end
|
121
131
|
end
|
122
132
|
end
|
123
133
|
end
|
@@ -36,14 +36,11 @@ module Hyrax
|
|
36
36
|
(representative_presenter.image? && Hyrax.config.iiif_image_server?))
|
37
37
|
end
|
38
38
|
|
39
|
-
alias universal_viewer? iiif_viewer?
|
40
|
-
# deprecation_deprecate universal_viewer?: "use iiif_viewer? instead"
|
41
|
-
|
42
39
|
def iiif_viewer
|
43
40
|
if representative_presenter.video? || representative_presenter.audio?
|
44
41
|
:avalon
|
45
|
-
|
46
|
-
|
42
|
+
else
|
43
|
+
super
|
47
44
|
end
|
48
45
|
end
|
49
46
|
|
data/hyrax-iiif_av.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
|
22
22
|
s.add_dependency "rails", "~>5.1"
|
23
23
|
s.add_dependency "blacklight"
|
24
|
-
s.add_dependency "hyrax", "~> 2.
|
24
|
+
s.add_dependency "hyrax", "~> 2.4"
|
25
25
|
s.add_dependency "iiif_manifest", "~> 0.5"
|
26
26
|
|
27
27
|
s.add_development_dependency 'bixby'
|
@@ -20,4 +20,4 @@ limitations under the License.
|
|
20
20
|
<%= javascript_pack_tag 'application' %>
|
21
21
|
<%= stylesheet_pack_tag 'application' %>
|
22
22
|
<% end %>
|
23
|
-
<%= react_component("AvalonIiifPlayer", { manifestUrl: main_app.
|
23
|
+
<%= react_component("AvalonIiifPlayer", { manifestUrl: main_app.polymorphic_url([main_app, :manifest, presenter], { locale: nil }) }) %>
|
data/lib/hyrax/iiif_av.rb
CHANGED
@@ -3,6 +3,25 @@ require "hyrax/iiif_av/engine"
|
|
3
3
|
|
4
4
|
module Hyrax
|
5
5
|
module IiifAv
|
6
|
-
|
6
|
+
extend ActiveSupport::Autoload
|
7
|
+
|
8
|
+
eager_autoload do
|
9
|
+
autoload :Configuration
|
10
|
+
end
|
11
|
+
|
12
|
+
# @api public
|
13
|
+
#
|
14
|
+
# Exposes the Hyrax configuration
|
15
|
+
#
|
16
|
+
# @yield [Hyrax::IiifAv::Configuration] if a block is passed
|
17
|
+
# @return [Hyrax::IiifAv::Configuration]
|
18
|
+
# @see Hyrax::IiifAv::Configuration for configuration options
|
19
|
+
def self.config(&block)
|
20
|
+
@config ||= Hyrax::IiifAv::Configuration.new
|
21
|
+
|
22
|
+
yield @config if block
|
23
|
+
|
24
|
+
@config
|
25
|
+
end
|
7
26
|
end
|
8
27
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Hyrax
|
3
|
+
module IiifAv
|
4
|
+
class Configuration
|
5
|
+
# URL that resolves to an AV stream provided to a IIIF presentation manifest
|
6
|
+
#
|
7
|
+
# @return [#call] lambda/proc that generates a URL to an AV stream
|
8
|
+
def iiif_av_url_builder
|
9
|
+
@iiif_av_url_builder ||= lambda do |file_location_uri, _base_url|
|
10
|
+
# Reverse engineering Hyrax::DerivativePath
|
11
|
+
path = file_location_uri.sub(/^#{Hyrax.config.derivatives_path}/, '')
|
12
|
+
id_path, file_path = path.split('-', 2)
|
13
|
+
file_set_id = id_path.delete('/')
|
14
|
+
filename = file_path[0, file_path.size / 2]
|
15
|
+
Hyrax::Engine.routes.url_helpers.download_path(file_set_id, file: filename)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
attr_writer :iiif_av_url_builder
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -80,10 +80,11 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
context 'when the file is an audio derivative with metadata' do
|
83
|
+
let(:file_set_id) { 'abcdefg' }
|
83
84
|
let(:derivatives_metadata) do
|
84
85
|
[
|
85
|
-
{ id: '1', label: 'high',
|
86
|
-
{ id: '2', label: 'medium',
|
86
|
+
{ id: '1', label: 'high', file_location_uri: Hyrax::DerivativePath.derivative_path_for_reference(file_set_id, 'medium.mp3') },
|
87
|
+
{ id: '2', label: 'medium', file_location_uri: Hyrax::DerivativePath.derivative_path_for_reference(file_set_id, 'high.mp3') }
|
87
88
|
]
|
88
89
|
end
|
89
90
|
let(:solr_document) { SolrDocument.new(id: '12345', duration_tesim: 1000, derivatives_metadata_ssi: derivatives_metadata.to_json) }
|
@@ -96,7 +97,29 @@ RSpec.shared_examples "IiifAv::DisplaysContent" do
|
|
96
97
|
expect(content).to all(be_instance_of IIIFManifest::V3::DisplayContent)
|
97
98
|
expect(content.length).to eq 2
|
98
99
|
expect(content.map(&:label)).to match_array(['high', 'medium'])
|
99
|
-
expect(content.map(&:url)).to match_array([
|
100
|
+
expect(content.map(&:url)).to match_array([Hyrax::Engine.routes.url_helpers.download_path(file_set_id, file: 'high.mp3'),
|
101
|
+
Hyrax::Engine.routes.url_helpers.download_path(file_set_id, file: 'medium.mp3')])
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'with custom av url builder' do
|
105
|
+
let(:custom_builder) do
|
106
|
+
->(file_location_uri, _base_url) { "http://streaming.example.com/stream/#{File.basename(file_location_uri)}" }
|
107
|
+
end
|
108
|
+
|
109
|
+
around do |example|
|
110
|
+
default_builder = Hyrax::IiifAv.config.iiif_av_url_builder
|
111
|
+
Hyrax::IiifAv.config.iiif_av_url_builder = custom_builder
|
112
|
+
example.run
|
113
|
+
Hyrax::IiifAv.config.iiif_av_url_builder = default_builder
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'creates an array of content objects with metadata' do
|
117
|
+
expect(content).to all(be_instance_of IIIFManifest::V3::DisplayContent)
|
118
|
+
expect(content.length).to eq 2
|
119
|
+
expect(content.map(&:label)).to match_array(['high', 'medium'])
|
120
|
+
expect(content.map(&:url)).to match_array(['http://streaming.example.com/stream/g-high.mp3.high.mp3',
|
121
|
+
'http://streaming.example.com/stream/g-medium.mp3.medium.mp3'])
|
122
|
+
end
|
100
123
|
end
|
101
124
|
end
|
102
125
|
|
@@ -123,7 +123,7 @@ RSpec.shared_examples "IiifAv::DisplaysIiifAv" do
|
|
123
123
|
context 'with no representative_presenter' do
|
124
124
|
let(:representative_presenter) { instance_double('Hyrax::FileSetPresenter', present?: false) }
|
125
125
|
|
126
|
-
it { is_expected.to be
|
126
|
+
it { is_expected.to be :universal_viewer }
|
127
127
|
end
|
128
128
|
end
|
129
129
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyrax-iiif_av
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Colvard
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2018-
|
14
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -47,14 +47,14 @@ dependencies:
|
|
47
47
|
requirements:
|
48
48
|
- - "~>"
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: '2.
|
50
|
+
version: '2.4'
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: '2.
|
57
|
+
version: '2.4'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: iiif_manifest
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
@@ -172,12 +172,10 @@ files:
|
|
172
172
|
- README.md
|
173
173
|
- Rakefile
|
174
174
|
- app/controllers/concerns/hyrax/iiif_av/controller_behavior.rb
|
175
|
-
- app/
|
175
|
+
- app/models/hyrax/iiif_av/manifest_range.rb
|
176
176
|
- app/presenters/concerns/hyrax/iiif_av/displays_content.rb
|
177
177
|
- app/presenters/concerns/hyrax/iiif_av/displays_iiif_av.rb
|
178
178
|
- app/presenters/hyrax/iiif_av/iiif_file_set_presenter.rb
|
179
|
-
- app/views/hyrax/base/_representative_media.html.erb
|
180
|
-
- app/views/hyrax/base/iiif_viewers/_universal_viewer.html.erb
|
181
179
|
- bin/rails
|
182
180
|
- hyrax-iiif_av.gemspec
|
183
181
|
- lib/generators/hyrax/iiif_av/add_to_work_type_generator.rb
|
@@ -186,8 +184,8 @@ files:
|
|
186
184
|
- lib/generators/hyrax/iiif_av/templates/AvalonIiifPlayer.js
|
187
185
|
- lib/generators/hyrax/iiif_av/templates/_avalon.html.erb
|
188
186
|
- lib/hyrax/iiif_av.rb
|
187
|
+
- lib/hyrax/iiif_av/configuration.rb
|
189
188
|
- lib/hyrax/iiif_av/engine.rb
|
190
|
-
- lib/hyrax/iiif_av/manifest_range.rb
|
191
189
|
- lib/hyrax/iiif_av/spec/shared_specs.rb
|
192
190
|
- lib/hyrax/iiif_av/spec/shared_specs/controller_behavior.rb
|
193
191
|
- lib/hyrax/iiif_av/spec/shared_specs/displays_content.rb
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# Copyright 2011-2018, The Trustees of Indiana University and Northwestern
|
3
|
-
# University. Additional copyright may be held by others, as reflected in
|
4
|
-
# the commit history.
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
# --- END LICENSE_HEADER BLOCK ---
|
18
|
-
|
19
|
-
module Hyrax
|
20
|
-
module IiifAv
|
21
|
-
module IiifAvHelper
|
22
|
-
def iiif_viewer_display(presenter, locals = {})
|
23
|
-
render iiif_viewer_display_partial(presenter),
|
24
|
-
locals.merge(presenter: presenter)
|
25
|
-
end
|
26
|
-
|
27
|
-
def iiif_viewer_display_partial(work_presenter)
|
28
|
-
'hyrax/base/iiif_viewers/' + iiif_viewer_for_work(work_presenter).to_s
|
29
|
-
end
|
30
|
-
|
31
|
-
def iiif_viewer_for_work(work_presenter)
|
32
|
-
if work_presenter.respond_to? :iiif_viewer
|
33
|
-
work_presenter.iiif_viewer
|
34
|
-
else
|
35
|
-
:universal_viewer
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
<%#
|
2
|
-
Copyright 2011-2018, The Trustees of Indiana University and Northwestern
|
3
|
-
University. Additional copyright may be held by others, as reflected in
|
4
|
-
the commit history.
|
5
|
-
|
6
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
you may not use this file except in compliance with the License.
|
8
|
-
You may obtain a copy of the License at
|
9
|
-
|
10
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
|
12
|
-
Unless required by applicable law or agreed to in writing, software
|
13
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
See the License for the specific language governing permissions and
|
16
|
-
limitations under the License.
|
17
|
-
--- END LICENSE_HEADER BLOCK ---
|
18
|
-
%>
|
19
|
-
<% if presenter.representative_id.present? && presenter.representative_presenter.present? %>
|
20
|
-
<% if defined?(viewer) && viewer %>
|
21
|
-
<%= iiif_viewer_display presenter %>
|
22
|
-
<% else %>
|
23
|
-
<%= media_display presenter.representative_presenter %>
|
24
|
-
<% end %>
|
25
|
-
<% else %>
|
26
|
-
<%= image_tag 'default.png', class: "canonical-image" %>
|
27
|
-
<% end %>
|