Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Universal Viewer embed code #3341

Merged
merged 1 commit into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/controllers/concerns/hyrax/works_controller_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ def inspect_work

def manifest
headers['Access-Control-Allow-Origin'] = '*'
render json: manifest_builder.to_h
respond_to do |wants|
wants.json { render json: manifest_builder.to_h }
wants.html { render json: manifest_builder.to_h }
end
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/views/hyrax/base/_representative_media.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% if defined?(viewer) && viewer %>
<%= PulUvRails::UniversalViewer.script_tag %>
<div class="viewer-wrapper">
<div class="uv viewer" data-uri="<%= main_app.polymorphic_path [main_app, :manifest, presenter], { locale: nil } %>"></div>
<div class="uv viewer" data-uri="<%= main_app.polymorphic_url [main_app, :manifest, presenter], { locale: nil } %>"></div>
</div>
<% else %>
<%= media_display presenter.representative_presenter %>
Expand Down
7 changes: 6 additions & 1 deletion spec/controllers/hyrax/generic_works_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,14 @@
.and_return(manifest_factory)
end

it "produces a manifest" do
it "produces a manifest for a json request" do
get :manifest, params: { id: work, format: :json }
expect(response.body).to eq "{\"test\":\"manifest\"}"
end

it "produces a manifest for a html request" do
get :manifest, params: { id: work, format: :html }
expect(response.body).to eq "{\"test\":\"manifest\"}"
end
end
end
2 changes: 1 addition & 1 deletion spec/features/work_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
end

# IIIF manifest does not include locale query param
expect(find('div.viewer:first')['data-uri']).to eq "/concern/generic_works/#{work.id}/manifest"
expect(find('div.viewer:first')['data-uri']).to eq "http://www.example.com/concern/generic_works/#{work.id}/manifest"
end

it "add work to a collection", clean_repo: true, js: true do
Expand Down