curation_concerns 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 385f4e3748f29f5498d701ecaca78b830e466317
4
- data.tar.gz: 9df2179967ddec4f5eac6e8a3e2adec52f50b61a
3
+ metadata.gz: 7ededd8a3ac47bb55d279de6c1557e9f1ca49573
4
+ data.tar.gz: 695d208d75e884acb6d9bab98b5aa2da9fe89905
5
5
  SHA512:
6
- metadata.gz: 560677b0f20e0024f49e8a30fbb19114be599f2bbba7a360808c008b0d888593a2051c7bfea46c3a606423299a7e0464f0fa3a7044b398735bb86c106c9aa86c
7
- data.tar.gz: 50a8a6920a23729f5a83fa73bb92fc41ec25e27c520cbe6414405f7e14d54c59711c7ac8fab580eb9e3b60712a5aab2523133cdd3a1439e867dbac115832dd08
6
+ metadata.gz: 32e3c790662784293d7d40b23c8149d9cfa49063c0f304d577820d01ad505f547cb27195d9976bc00ebd11ed80ad589292f444041455d404f76849a07b0b7422
7
+ data.tar.gz: 546f1002130a05f4100ce2731bf20ab75e9e726a6dffe127637d58a6aff47fa1d377a1dee270a1ffc4943065dab451dcacf1a726b05e4867a4e1f895623094a7
@@ -1,7 +1,12 @@
1
- <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the document" do %>
1
+ <% if CurationConcerns.config.display_media_download_link %>
2
+ <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the document" do %>
3
+ <figure>
4
+ <%= image_tag "default.png", alt: "No preview available", class: "img-responsive" %>
5
+ <figcaption>Download the document</figcaption>
6
+ </figure>
7
+ <% end %>
8
+ <% else %>
2
9
  <figure>
3
- <%= image_tag "default.png", alt: "No preview available", class: "img-responsive" %>
4
- <figcaption>Download the document</figcaption>
10
+ <%= image_tag "default.png", alt: "No preview available", class: "img-responsive" %>
5
11
  </figure>
6
- <% end %>
7
-
12
+ <% end %>
@@ -1,9 +1,16 @@
1
- <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the full-sized image" do %>
1
+ <% if CurationConcerns.config.display_media_download_link %>
2
+ <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the full-sized image" do %>
3
+ <figure>
4
+ <%= image_tag main_app.download_path(file_set, file: 'thumbnail'),
5
+ class: "img-responsive",
6
+ alt: "Download the full-sized image of #{file_set.to_s}" %>
7
+ <figcaption>Download the full-sized image</figcaption>
8
+ </figure>
9
+ <% end %>
10
+ <% else %>
2
11
  <figure>
3
- <%= image_tag(main_app.download_path(file_set, file: 'thumbnail'),
4
- class: "img-responsive",
5
- alt: "Download the full-sized image of #{file_set.to_s}"
6
- ) %>
7
- <figcaption>Download the full-sized image</figcaption>
12
+ <%= image_tag main_app.download_path(file_set, file: 'thumbnail'),
13
+ class: "img-responsive",
14
+ alt: "Thumbnail of #{file_set.to_s}" %>
8
15
  </figure>
9
- <% end %>
16
+ <% end %>
@@ -1,9 +1,16 @@
1
- <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the document" do %>
1
+ <% if CurationConcerns.config.display_media_download_link %>
2
+ <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the document" do %>
3
+ <figure>
4
+ <%= image_tag main_app.download_path(file_set, file: 'thumbnail'),
5
+ class: "img-responsive",
6
+ alt: "Download the document #{file_set.to_s}" %>
7
+ <figcaption>Download the document</figcaption>
8
+ </figure>
9
+ <% end %>
10
+ <% else %>
2
11
  <figure>
3
- <%= image_tag(main_app.download_path(file_set, file: 'thumbnail'),
4
- class: "img-responsive",
5
- alt: "Download the document \"#{file_set.to_s}\""
6
- ) %>
7
- <figcaption>Download the document</figcaption>
12
+ <%= image_tag main_app.download_path(file_set, file: 'thumbnail'),
13
+ class: "img-responsive",
14
+ alt: "Thumbnail of #{file_set.to_s}" %>
8
15
  </figure>
9
- <% end %>
16
+ <% end %>
@@ -1,9 +1,16 @@
1
- <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the full-sized PDF" do %>
1
+ <% if CurationConcerns.config.display_media_download_link %>
2
+ <%= link_to main_app.download_path(file_set), target: "_new", title: "Download the full-sized PDF" do %>
3
+ <figure>
4
+ <%= image_tag main_app.download_path(file_set, file: 'thumbnail'),
5
+ class: "img-responsive",
6
+ alt: "Download the full-sized PDF of #{file_set.to_s}" %>
7
+ <figcaption>Download the full-sized PDF</figcaption>
8
+ </figure>
9
+ <% end %>
10
+ <% else %>
2
11
  <figure>
3
- <%= image_tag main_app.download_path(file_set, file: 'thumbnail'),
4
- class: "img-responsive",
5
- alt: "Download the full-sized PDF of #{file_set.to_s}" %>
6
- <figcaption>Download the full-sized PDF</figcaption>
12
+ <%= image_tag main_app.download_path(file_set, file: 'thumbnail'),
13
+ class: "img-responsive",
14
+ alt: "Thumbnail of #{file_set.to_s}" %>
7
15
  </figure>
8
- <% end %>
9
-
16
+ <% end %>
@@ -96,6 +96,12 @@ module CurationConcerns
96
96
  @redis_namespace ||= 'curation_concerns'
97
97
  end
98
98
 
99
+ attr_writer :display_media_download_link
100
+ def display_media_download_link
101
+ return @display_media_download_link unless @display_media_download_link.nil?
102
+ @display_media_download_link = true
103
+ end
104
+
99
105
  attr_writer :fits_path
100
106
  def fits_path
101
107
  @fits_path ||= 'fits.sh'
@@ -1,3 +1,3 @@
1
1
  module CurationConcerns
2
- VERSION = "0.12.0".freeze
2
+ VERSION = "0.13.0".freeze
3
3
  end
@@ -49,6 +49,9 @@ CurationConcerns.configure do |config|
49
49
  # Specify the prefix for Redis keys:
50
50
  # config.redis_namespace = "curation_concerns"
51
51
 
52
+ # Specify whether the media display partial should render a download link
53
+ # config.display_media_download_link = true
54
+
52
55
  # Specify the path to the file characterization tool:
53
56
  # config.fits_path = "fits.sh"
54
57
 
@@ -22,10 +22,12 @@ describe 'curation_concerns/file_sets/show.html.erb', type: :view do
22
22
  depositor: depositor.user_key,
23
23
  audit_stat: 1,
24
24
  title: ['My Title'],
25
- description: ['Lorem ipsum lorem ipsum. http://my.link.com']
25
+ description: ['Lorem ipsum lorem ipsum. http://my.link.com'],
26
+ mime_type: mime_type
26
27
  )
27
28
  end
28
29
 
30
+ let(:mime_type) { 'application/binary' }
29
31
  let(:ability) { double }
30
32
  let(:solr_doc) { SolrDocument.new(file_set.to_solr) }
31
33
  let(:presenter) { CurationConcerns::FileSetPresenter.new(solr_doc, ability) }
@@ -47,6 +49,78 @@ describe 'curation_concerns/file_sets/show.html.erb', type: :view do
47
49
  end
48
50
  end
49
51
 
52
+ describe 'media display' do
53
+ context 'when config is true' do
54
+ before do
55
+ allow(CurationConcerns.config).to receive(:display_media_download_link) { true }
56
+ render
57
+ end
58
+
59
+ context 'with an image' do
60
+ let(:mime_type) { 'image/tiff' }
61
+ it 'renders the download link' do
62
+ expect(rendered).to have_link('Download the full-sized image')
63
+ end
64
+ end
65
+
66
+ context 'with a PDF' do
67
+ let(:mime_type) { 'application/pdf' }
68
+ it 'renders the download link' do
69
+ expect(rendered).to have_link('Download the full-sized PDF')
70
+ end
71
+ end
72
+
73
+ context 'with a word document' do
74
+ let(:mime_type) { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
75
+ it 'renders the download link' do
76
+ expect(rendered).to have_link('Download the document')
77
+ end
78
+ end
79
+
80
+ context 'with anything else' do
81
+ let(:mime_type) { 'application/binary' }
82
+ it 'renders the download link' do
83
+ expect(rendered).to have_link('Download the document')
84
+ end
85
+ end
86
+ end
87
+
88
+ context 'when config is false' do
89
+ before do
90
+ allow(CurationConcerns.config).to receive(:display_media_download_link) { false }
91
+ render
92
+ end
93
+
94
+ context 'with an image' do
95
+ let(:mime_type) { 'image/tiff' }
96
+ it 'does not render the download link' do
97
+ expect(rendered).not_to have_link('Download the full-sized image')
98
+ end
99
+ end
100
+
101
+ context 'with a PDF' do
102
+ let(:mime_type) { 'application/pdf' }
103
+ it 'does not render the download link' do
104
+ expect(rendered).not_to have_link('Download the full-sized PDF')
105
+ end
106
+ end
107
+
108
+ context 'with a word document' do
109
+ let(:mime_type) { 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
110
+ it 'does not render the download link' do
111
+ expect(rendered).not_to have_link('Download the document')
112
+ end
113
+ end
114
+
115
+ context 'with anything else' do
116
+ let(:mime_type) { 'application/binary' }
117
+ it 'does not render the download link' do
118
+ expect(rendered).not_to have_link('Download the document')
119
+ end
120
+ end
121
+ end
122
+ end
123
+
50
124
  describe 'attributes' do
51
125
  before { render }
52
126
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curation_concerns
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt
@@ -1224,7 +1224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1224
1224
  version: '0'
1225
1225
  requirements: []
1226
1226
  rubyforge_project:
1227
- rubygems_version: 2.5.1
1227
+ rubygems_version: 2.4.8
1228
1228
  signing_key:
1229
1229
  specification_version: 4
1230
1230
  summary: A Rails Engine that allows an application to CRUD CurationConcern objects