-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1376 from samvera-labs/1372_iiif_rendering
Implementation of #1372: support downloads (eg. a PDF of the whole paged item) via Universal Viewer
- Loading branch information
Showing
17 changed files
with
202 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
class FileSetIndexer < Hyrax::FileSetIndexer | ||
self.thumbnail_path_service = IIIFWorkThumbnailPathService | ||
def generate_solr_document | ||
super.tap do |solr_doc| | ||
solr_doc['hasFormat_ssim'] = object.rendering_ids | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module HasRendering | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
# rubocop:disable Rails/HasAndBelongsToMany | ||
# dc:hasFormat defined in Presentation API context: http://iiif.io/api/presentation/2/context.json | ||
has_and_belongs_to_many :renderings, | ||
predicate: ::RDF::Vocab::DC.hasFormat, | ||
class_name: 'ActiveFedora::Base' | ||
# rubocop:enable Rails/HasAndBelongsToMany | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
module Hyku | ||
class FileSetPresenter < Hyrax::FileSetPresenter | ||
include DisplaysImage | ||
# CurationConcern methods | ||
delegate :rendering_ids, to: :solr_document | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% if f.object.persisted? && f.object.member_ids.present? %> | ||
<%= render 'form_representative', f: f %> | ||
<%= render 'form_thumbnail', f: f %> | ||
<%# display the rendering dropdown only if the representitive responds to image? (ie. Universal Viewer is used) %> | ||
<% if curation_concern.representative.image? %> | ||
<%= render 'form_rendering', f: f %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<fieldset id="representative-media"> | ||
<legend> | ||
Rendering | ||
</legend> | ||
<p>Select file(s) to be offered as as downloads for every image in Universal Viewer, for example a PDF of the whole <%= f.object.human_readable_type %>.</p> | ||
<%= f.select :rendering_ids, | ||
f.object.select_files, | ||
{ include_blank: true }, | ||
{ class: 'form-control', multiple: true } %> | ||
</fieldset> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
# Generated via | ||
# `rails generate curation_concerns:work GenericWork` | ||
RSpec.describe Hyrax::GenericWorkForm do | ||
it "has tests" do | ||
skip "Add your tests here" | ||
let(:work) { GenericWork.new } | ||
let(:form) { described_class.new(work, nil, nil) } | ||
let(:file_set) { FactoryGirl.create(:file_set) } | ||
|
||
describe ".model_attributes" do | ||
subject { described_class.model_attributes(params) } | ||
|
||
let(:params) { ActionController::Parameters.new(attributes) } | ||
let(:attributes) do | ||
{ | ||
title: ['foo'], | ||
rendering_ids: [file_set.id] | ||
} | ||
end | ||
|
||
it 'permits parameters' do | ||
expect(subject['rendering_ids']).to eq [file_set.id] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,26 @@ | ||
# Generated via | ||
# `rails generate hyrax:work Image` | ||
# `rails generate hyrax:work Image` | ||
|
||
RSpec.describe Hyrax::ImageForm do | ||
it "has tests" do | ||
skip "Add your tests here" | ||
let(:work) { Image.new } | ||
let(:form) { described_class.new(work, nil, nil) } | ||
let(:file_set) { FactoryGirl.create(:file_set) } | ||
|
||
describe ".model_attributes" do | ||
subject { described_class.model_attributes(params) } | ||
|
||
let(:params) { ActionController::Parameters.new(attributes) } | ||
let(:attributes) do | ||
{ | ||
title: ['foo'], | ||
rendering_ids: [file_set.id], | ||
extent: ['extent'] | ||
} | ||
end | ||
|
||
it 'permits parameters' do | ||
expect(subject['rendering_ids']).to eq [file_set.id] | ||
expect(subject['extent']).to eq ['extent'] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
RSpec.describe 'hyrax/base/_form_rendering.html.erb', type: :view do | ||
let(:ability) { double } | ||
let(:work) { FactoryGirl.create(:work_with_one_file) } | ||
let(:form) do | ||
Hyrax::GenericWorkForm.new(work, ability, controller) | ||
end | ||
|
||
let(:page) do | ||
view.simple_form_for form do |f| | ||
render 'hyrax/base/form_rendering', f: f | ||
end | ||
Capybara::Node::Simple.new(rendered) | ||
end | ||
|
||
it 'has a rendering_ids field' do | ||
expect(page).to have_selector("select#generic_work_rendering_ids", count: 1) | ||
end | ||
end |