-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7830796
commit e9c58bb
Showing
4 changed files
with
84 additions
and
47 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<%# Renders the primary download that is shown first %> | ||
<% document ||= @document %> | ||
<% if document.direct_download.present? %> | ||
<%= link_to(download_text(document.file_format), document.direct_download[:download], class: 'btn btn-default', 'contentUrl' => document.direct_download[:download], data: { download: 'trigger', download_type: 'direct', download_id: document.id }) %> | ||
<% elsif document.hgl_download.present? %> | ||
<%= link_to(download_text(document.download_types.first[0]), | ||
download_hgl_path(id: document), data: {ajax_modal: 'trigger', download: 'trigger', download_type: 'harvard-hgl', download_id: document.id }, | ||
class: 'btn btn-default') %> | ||
<% elsif document.iiif_download.present? %> | ||
<%= link_to "Download JPG", iiif_jpg_url, class: 'btn btn-default', download: 'trigger' %> | ||
<% else %> | ||
<%= link_to(download_text(document.download_types.first[0]), '', data: { download_path: "#{download_path(document.id, type: document.download_types.first[0])}", download: 'trigger', download_type: document.download_types.first[0], download_id: document.id }, class: 'btn btn-default') %> | ||
<% 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,39 @@ | ||
<%# Renders the secondary downloads displayed in the split dropdown %> | ||
<% document ||= @document %> | ||
|
||
<button type='button' class='btn btn-default dropdown-toggle download-dropdown-toggle' data-toggle='dropdown' aria-expanded='false'> | ||
<span class='caret'></span> | ||
<span class='sr-only'>Toggle Download Dropdown</span> | ||
</button> | ||
<ul class='dropdown-menu' role='menu'> | ||
<% if document.hgl_download.present? %> | ||
<li role="presentation" class="dropdown-header">Original</li> | ||
<li> | ||
<%= link_to(download_text(document.download_types.first[0]), | ||
download_hgl_path(id: document), data: {ajax_modal: 'trigger', download: 'trigger', download_type: 'harvard-hgl', download_id: document.id }) %> | ||
</li> | ||
<% else %> | ||
<% if document.direct_download.present? %> | ||
<li role="presentation" class="dropdown-header">Original</li> | ||
<li> | ||
<%= link_to(download_text(@document.file_format), document.direct_download[:download], 'contentUrl' => document.direct_download[:download], data: { download: 'trigger', download_type: 'direct', download_id: document.id }) %> | ||
</li> | ||
<% end %> | ||
<% if document.download_types.present? || document.iiif_download.present? %> | ||
<li role="presentation" class="dropdown-header">Generated</li> | ||
<% end %> | ||
<% if document.iiif_download.present? %> | ||
<li> | ||
<%= link_to "Download JPG", iiif_jpg_url, download: 'trigger' %> | ||
</li> | ||
<% end %> | ||
<% if document.download_types.present? %> | ||
<% document.download_types.each do |type| %> | ||
<%= content_tag(:li) do %> | ||
<% link_to(download_text(type[0]), '', data: { download_path: "#{download_path(document.id, type: type[0])}", download: 'trigger', download_type: type[0], download_id: document.id }) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</ul> |
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,29 @@ | ||
require 'spec_helper' | ||
|
||
describe 'catalog/_downloads.html.erb', type: :view do | ||
context 'document is downloadable' do | ||
it 'renders the button group with primary and secondary partials' do | ||
expect(view).to receive(:document_downloadable?).and_return(true) | ||
stub_template 'catalog/_downloads_primary.html.erb' => 'stubbed_primary_downloads' | ||
stub_template 'catalog/_downloads_secondary.html.erb' => 'stubbed_secondary_downloads' | ||
render | ||
expect(rendered).to have_css '.btn-group' | ||
expect(rendered).to have_content 'stubbed_primary_downloads' | ||
expect(rendered).to have_content 'stubbed_secondary_downloads' | ||
end | ||
end | ||
context 'document is not downloadable' do | ||
let(:document) { double('document', restricted?: true, same_institution?: true) } | ||
before(:each) do | ||
expect(view).to receive(:document_downloadable?).and_return(false) | ||
end | ||
|
||
context 'when restricted & same institution' do | ||
it 'renders login link' do | ||
assign :document, document | ||
render | ||
expect(rendered).to have_css '.panel-body a' | ||
end | ||
end | ||
end | ||
end |