Skip to content

Commit

Permalink
Merge pull request #1774 from sul-dlss/previewable
Browse files Browse the repository at this point in the history
Stop using previewable? We can use image? instead
  • Loading branch information
jcoyne authored Nov 17, 2023
2 parents bfcd303 + f1abc3e commit 79e433e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
10 changes: 0 additions & 10 deletions app/models/embed/purl/resource_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def mimetype
@file.attributes['mimetype'].try(:value)
end

def previewable?
preview_types.include?(mimetype)
end

def image?
mimetype =~ %r{image/jp2}i
end
Expand Down Expand Up @@ -88,12 +84,6 @@ def location_restricted?
def world_downloadable?
@rights.world_downloadable_file?(@file.attributes['id'])
end

private

def preview_types
['image/jp2']
end
end
end
end
6 changes: 3 additions & 3 deletions app/views/embed/body/_resource_file.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= viewer.purl_object.hierarchical? ? raw('&nbsp;&nbsp;') : file.index %>
</div>
<div class='sul-embed-media-object sul-embed-pull-left'>
<% if file.previewable? %>
<% if file.image? %>
<img class='sul-embed-square-image' src="<%= viewer.stacks_square_url(viewer.purl_object.druid, file.title)%>" alt=''>
<% else %>
<i class="sul-i-2x <%= viewer.file_type_icon(file.mimetype) %>"></i>
Expand Down Expand Up @@ -41,7 +41,7 @@
<% end %>
</div>

<% if file.previewable? %>
<% if file.image? %>
<span class='sul-embed-preview-toggle' data-sul-embed-file-preview-toggle='true'>
<i class='sul-i-arrow-right-8'></i>
<span class='sul-embed-preview-text'>
Expand All @@ -55,7 +55,7 @@
<% end %>

</div>
<% if file.previewable? %>
<% if file.image? %>
<div style='display: none;' class='sul-embed-preview' data-sul-embed-file-preview-window='true' aria-hidden='true'>
<img src="<%= viewer.stacks_thumb_url(viewer.purl_object.druid, file.title) %>" alt=''>
</div>
Expand Down
12 changes: 0 additions & 12 deletions spec/models/embed/purl/resource_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,6 @@
end
end

describe 'previewable?' do
it 'returns true if the mimetype of the file is previewable' do
stub_purl_xml_response_with_fixture(image_purl_xml)
expect(Embed::Purl.new('12345').contents.first.files.first).to be_previewable
end

it 'returns false if the mimetype of the file is not previewable' do
stub_purl_xml_response_with_fixture(file_purl_xml)
expect(Embed::Purl.new('12345').contents.first.files.first).not_to be_previewable
end
end

describe 'image?' do
it 'returns true if the mimetype of the file is an image' do
stub_purl_xml_response_with_fixture(image_purl_xml)
Expand Down

0 comments on commit 79e433e

Please sign in to comment.