diff --git a/Gemfile b/Gemfile
index d82979153..11114aaa9 100644
--- a/Gemfile
+++ b/Gemfile
@@ -102,7 +102,7 @@ gem 'zk'
gem 'mods', '~> 2.1'
gem 'riiif', '~> 1.1'
-gem 'iiif_manifest', '~> 0.2.0'
+gem 'iiif_manifest', '~> 0.3.0'
group :aws, :test do
gem 'carrierwave-aws'
diff --git a/Gemfile.lock b/Gemfile.lock
index 7befd50e7..5615eec29 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -404,7 +404,7 @@ GEM
activesupport (>= 3.2.18)
faraday (>= 0.9)
json
- iiif_manifest (0.2.0)
+ iiif_manifest (0.3.0)
activesupport (>= 4)
iiif-presentation (~> 0.2.0)
inflecto (0.0.2)
@@ -898,7 +898,7 @@ DEPENDENCIES
hyrax!
i18n-debug
i18n-tasks
- iiif_manifest (~> 0.2.0)
+ iiif_manifest (~> 0.3.0)
is_it_working
jbuilder (~> 2.5)
jquery-rails
diff --git a/app/presenters/hyku/manifest_enabled_work_show_presenter.rb b/app/presenters/hyku/manifest_enabled_work_show_presenter.rb
index ea5e69329..b4ce5eacb 100644
--- a/app/presenters/hyku/manifest_enabled_work_show_presenter.rb
+++ b/app/presenters/hyku/manifest_enabled_work_show_presenter.rb
@@ -8,13 +8,31 @@ def manifest_url
manifest_helper.polymorphic_url([:manifest, self])
end
- # Hash to populate IIIF manifest with extras. Currently only sequence rendering is implemented.
+ # IIIF rendering linking property for inclusion in the manifest
#
- # @return [Hash] hash including sequence_rendering
- def manifest_extras
- {
- sequence_rendering: sequence_rendering
- }
+ # @return [Array] array of rendering hashes
+ def sequence_rendering
+ renderings = []
+ if solr_document.rendering_ids.present?
+ solr_document.rendering_ids.each do |file_set_id|
+ renderings << build_rendering(file_set_id)
+ end
+ end
+ renderings.flatten
+ end
+
+ # IIIF metadata for inclusion in the manifest
+ #
+ # @return [Array] array of metadata hashes
+ def manifest_metadata
+ metadata = []
+ metadata_fields.each do |field|
+ metadata << {
+ 'label' => field.to_s.humanize.capitalize,
+ 'value' => get_metadata_value(field)
+ }
+ end
+ metadata
end
private
@@ -23,19 +41,6 @@ def manifest_helper
@manifest_helper ||= ManifestHelper.new(request.base_url)
end
- # IIIF rendering linking property for inclusion in the manifest
- #
- # @return [Array] array of rendering hashes
- def sequence_rendering
- renderings = []
- if solr_document.rendering_ids.present?
- solr_document.rendering_ids.each do |file_set_id|
- renderings << build_rendering(file_set_id)
- end
- end
- renderings.flatten
- end
-
# Build a rendering hash
#
# @return [Hash] rendering
@@ -58,5 +63,26 @@ def query_for_rendering(file_set_id)
fl: [ActiveFedora.id_field, 'label_ssi', 'mime_type_ssi'],
rows: 1)
end
+
+ # Retrieve the required fields from the Form class. Derive the Form class name from the Model name.
+ # The class should exist, but it may not if different namespaces are being used.
+ # If it does not exist, rescue and return an empty Array.
+ #
+ # @return [Array] required fields
+ def metadata_fields
+ ns = "Hyrax"
+ model = solr_document['has_model_ssim'].first
+
+ "#{ns}::#{model}Form".constantize.required_fields
+ rescue
+ []
+ end
+
+ # Get the metadata value(s).
+ #
+ # @return [Array] field value(s)
+ def get_metadata_value(field)
+ Array.wrap(send(field))
+ end
end
end
diff --git a/solr/config/schema.xml b/solr/config/schema.xml
index 2e9deac63..48cd2a321 100644
--- a/solr/config/schema.xml
+++ b/solr/config/schema.xml
@@ -59,32 +59,31 @@
-
+
-
+
-
+
-
+
-
-
+
-
+
-
+
-
+
@@ -112,7 +111,7 @@
-
+
@@ -120,7 +119,7 @@
-
+
@@ -129,7 +128,7 @@
-
+
@@ -144,7 +143,7 @@
-
+
@@ -154,7 +153,7 @@
-
+
@@ -175,16 +174,15 @@
-
+ -->
-
+
-
+
@@ -201,7 +199,7 @@
-
+
@@ -213,7 +211,7 @@
-
+
@@ -222,7 +220,7 @@
-
+
@@ -230,7 +228,7 @@
-
+
@@ -238,7 +236,7 @@
-
+
@@ -248,7 +246,7 @@
-
+
@@ -256,7 +254,7 @@
-
+
@@ -264,7 +262,7 @@
-
+
@@ -272,7 +270,7 @@
-
+
@@ -280,7 +278,7 @@
-
+
@@ -288,7 +286,7 @@
-
+
@@ -296,7 +294,7 @@
-
+
@@ -304,12 +302,12 @@
-
+
-
+
@@ -326,20 +324,13 @@
-
-
id
-
-
-
-
-
-
diff --git a/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb b/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb
index 0f3f0840c..e815f1d9f 100644
--- a/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb
+++ b/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb
@@ -8,7 +8,9 @@
describe "#manifest_url" do
subject { presenter.manifest_url }
+
let(:document) { { "has_model_ssim" => ['GenericWork'], 'id' => '99' } }
+
it { is_expected.to eq 'http://test.host/concern/generic_works/99/manifest' }
end
@@ -25,9 +27,9 @@
end
end
- describe "manifest_extras" do
+ describe "#sequence rendering" do
subject do
- presenter.manifest_extras
+ presenter.sequence_rendering
end
before do
@@ -37,7 +39,22 @@
it "returns a hash containing the rendering information" do
work.rendering_ids = [work.file_sets.first.id]
- expect(subject).to include(:sequence_rendering)
+ expect(subject).to be_an Array
+ end
+ end
+
+ describe "#manifest metadata" do
+ subject do
+ presenter.manifest_metadata
+ end
+
+ before do
+ work.title = ['Test title', 'Another test title']
+ end
+
+ it "returns an array of metadata values" do
+ expect(subject[0]['label']).to eq('Title')
+ expect(subject[0]['value']).to include('Test title', 'Another test title')
end
end
end