Skip to content

Commit

Permalink
Links only the download text, replaces figure and figcaption with a d…
Browse files Browse the repository at this point in the history
…iv, removes title attribute, removes alt text, and adds representative-media class for display. Adds <h2> to improve document outline and removes unused img-responsive class. Updates text to be customizable in translation file.
  • Loading branch information
mtribone committed Aug 23, 2016
1 parent 958904e commit 1e89cd5
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 58 deletions.
5 changes: 3 additions & 2 deletions app/assets/stylesheets/curation_concerns/_positioning.scss
Expand Up @@ -134,6 +134,7 @@ legend + .form-group {
}
}

.img-responsive, figure {
display: inline-block;
.representative-media {
display: block;
padding: 0.5em 0;
}
@@ -1,12 +1,21 @@
<% if CurationConcerns.config.display_media_download_link %>
<%= link_to main_app.download_path(file_set), target: "_new", title: "Download the document" do %>
<figure>
<%= image_tag "default.png", alt: "No preview available", class: "img-responsive" %>
<figcaption>Download the document</figcaption>
</figure>
<% end %>
<div>
<h2 class="sr-only"><%= t('curation_concerns.show.downloadable_content.heading') %></h2>
<%= image_tag "default.png",
class: "representative-media",
alt: "",
role: "presentation" %>
<%= link_to main_app.download_path(file_set),
target: "_new",
class: "btn btn-default" do %>
<%= t('curation_concerns.show.downloadable_content.default_link') %>
<% end %>
</div>
<% else %>
<figure>
<%= image_tag "default.png", alt: "No preview available", class: "img-responsive" %>
</figure>
<div>
<%= image_tag "default.png",
class: "representative-media",
alt: "",
role: "presentation" %>
</div>
<% end %>
31 changes: 18 additions & 13 deletions app/views/curation_concerns/file_sets/media_display/_image.html.erb
@@ -1,16 +1,21 @@
<% if CurationConcerns.config.display_media_download_link %>
<%= link_to main_app.download_path(file_set), target: "_new", title: "Download the full-sized image" do %>
<figure>
<%= image_tag thumbnail_url(file_set),
class: "img-responsive",
alt: "Download the full-sized image of #{file_set.to_s}" %>
<figcaption>Download the full-sized image</figcaption>
</figure>
<% end %>
<div>
<h2 class="sr-only"><%= t('curation_concerns.show.downloadable_content.heading') %></h2>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
<%= link_to main_app.download_path(file_set),
target: "_new",
class: "btn btn-default" do %>
<%= t('curation_concerns.show.downloadable_content.image_link') %>
<% end %>
</div>
<% else %>
<figure>
<%= image_tag thumbnail_url(file_set),
class: "img-responsive",
alt: "Thumbnail of #{file_set.to_s}" %>
</figure>
<div>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
</div>
<% end %>
@@ -1,16 +1,21 @@
<% if CurationConcerns.config.display_media_download_link %>
<%= link_to main_app.download_path(file_set), target: "_new", title: "Download the document" do %>
<figure>
<%= image_tag thumbnail_url(file_set),
class: "img-responsive",
alt: "Download the document #{file_set.to_s}" %>
<figcaption>Download the document</figcaption>
</figure>
<% end %>
<div>
<h2 class="sr-only"><%= t('curation_concerns.show.downloadable_content.heading') %></h2>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
<%= link_to main_app.download_path(file_set),
target: "_new",
class: "btn btn-default" do %>
<%= t('curation_concerns.show.downloadable_content.office_link') %>
<% end %>
</div>
<% else %>
<figure>
<%= image_tag thumbnail_url(file_set),
class: "img-responsive",
alt: "Thumbnail of #{file_set.to_s}" %>
</figure>
<div>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
</div>
<% end %>
31 changes: 18 additions & 13 deletions app/views/curation_concerns/file_sets/media_display/_pdf.html.erb
@@ -1,16 +1,21 @@
<% if CurationConcerns.config.display_media_download_link %>
<%= link_to main_app.download_path(file_set), target: "_new", title: "Download the full-sized PDF" do %>
<figure>
<%= image_tag thumbnail_url(file_set),
class: "img-responsive",
alt: "Download the full-sized PDF of #{file_set.to_s}" %>
<figcaption>Download the full-sized PDF</figcaption>
</figure>
<% end %>
<div>
<h2 class="sr-only"><%= t('curation_concerns.show.downloadable_content.heading') %></h2>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
<%= link_to main_app.download_path(file_set),
target: "_new",
class: "btn btn-default" do %>
<%= t('curation_concerns.show.downloadable_content.pdf_link') %>
<% end %>
</div>
<% else %>
<figure>
<%= image_tag thumbnail_url(file_set),
class: "img-responsive",
alt: "Thumbnail of #{file_set.to_s}" %>
</figure>
<div>
<%= image_tag thumbnail_url(file_set),
class: "representative-media",
alt: "",
role: "presentation" %>
</div>
<% end %>
6 changes: 6 additions & 0 deletions config/locales/curation_concerns.en.yml
Expand Up @@ -16,6 +16,12 @@ en:
show:
related_files:
heading: 'Members'
downloadable_content:
heading: 'Downloadable Content'
default_link: 'Download file'
image_link: 'Download image'
office_link: 'Download file'
pdf_link: 'Download PDF'
search:
form:
q:
Expand Down
16 changes: 8 additions & 8 deletions spec/views/curation_concerns/file_sets/show.html.erb_spec.rb
Expand Up @@ -72,28 +72,28 @@
context 'with an image' do
let(:mime_type) { 'image/tiff' }
it 'renders the download link' do
expect(rendered).to have_link('Download the full-sized image')
expect(rendered).to have_link('Download image')
end
end

context 'with a PDF' do
let(:mime_type) { 'application/pdf' }
it 'renders the download link' do
expect(rendered).to have_link('Download the full-sized PDF')
expect(rendered).to have_link('Download PDF')
end
end

context 'with a word document' do
let(:mime_type) { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
it 'renders the download link' do
expect(rendered).to have_link('Download the document')
expect(rendered).to have_link('Download file')
end
end

context 'with anything else' do
let(:mime_type) { 'application/binary' }
it 'renders the download link' do
expect(rendered).to have_link('Download the document')
expect(rendered).to have_link('Download file')
end
end
end
Expand All @@ -107,28 +107,28 @@
context 'with an image' do
let(:mime_type) { 'image/tiff' }
it 'does not render the download link' do
expect(rendered).not_to have_link('Download the full-sized image')
expect(rendered).not_to have_link('Download image')
end
end

context 'with a PDF' do
let(:mime_type) { 'application/pdf' }
it 'does not render the download link' do
expect(rendered).not_to have_link('Download the full-sized PDF')
expect(rendered).not_to have_link('Download PDF')
end
end

context 'with a word document' do
let(:mime_type) { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
it 'does not render the download link' do
expect(rendered).not_to have_link('Download the document')
expect(rendered).not_to have_link('Download file')
end
end

context 'with anything else' do
let(:mime_type) { 'application/binary' }
it 'does not render the download link' do
expect(rendered).not_to have_link('Download the document')
expect(rendered).not_to have_link('Download file')
end
end
end
Expand Down

0 comments on commit 1e89cd5

Please sign in to comment.