From cc708406072b50583d08cc0193184385474b08e6 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 9 Feb 2021 09:29:36 -0500 Subject: [PATCH 01/26] enable hyrax to create works without files --- config/initializers/hyrax.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/hyrax.rb b/config/initializers/hyrax.rb index d36f7c987..6df187e5c 100644 --- a/config/initializers/hyrax.rb +++ b/config/initializers/hyrax.rb @@ -116,7 +116,7 @@ # Should work creation require file upload, or can a work be created first # and a file added at a later time? # The default is true. - # config.work_requires_files = true + config.work_requires_files = false # Enable IIIF image service. This is required to use the # UniversalViewer-ified show page From 55f3c370554a677823744939d69ed18ee37edbc3 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Wed, 10 Feb 2021 12:09:25 -0500 Subject: [PATCH 02/26] allow metadata records to be shown for items with discover access --- .../concerns/spot/metadata_only_display.rb | 33 +++++++++++++++++++ app/presenters/spot/base_presenter.rb | 1 + .../catalog/_index_list_default.html.erb | 10 +++++- app/views/hyrax/base/_items_table.html.erb | 23 ++++++++----- .../base/_metadata_and_viewer_panel.html.erb | 16 +++++++-- 5 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 app/presenters/concerns/spot/metadata_only_display.rb diff --git a/app/presenters/concerns/spot/metadata_only_display.rb b/app/presenters/concerns/spot/metadata_only_display.rb new file mode 100644 index 000000000..4ec04b848 --- /dev/null +++ b/app/presenters/concerns/spot/metadata_only_display.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true +module Spot + # Mixin for WorkShowPresenters to determine if an item + module MetadataOnlyDisplay + # Conditions for whether to display only metadata or the files attached: + # - "admin" users can see files for all items + # - if the user can +:download+ a record (which includes those that can +:read+), + # we'll show the file + # - if the item is "authenticated" and the user is logged in, show the file + # - if the item is "public" and not embargoed, show the file + # + # Otherwise, we'll display just the metadata. + # + # @return [true, false] + def metadata_only? + @metadata_only ||= !(current_ability.admin? || current_ability.can?(:download, solr_document)) + end + + # Text content for the alert informing the user that they can not view a work's files. + # This should probably be moved to a helper method that uses the presenter and I18n. + # + # @return [Strinng] + def metadata_only_alert_text + if embargo_release_date.present? + "This item is under embargo until #{solr_document.embargo_release_date.strftime('%B %e, %Y')}.".html_safe + elsif visibility == 'authenticated' && !current_ability.can?(:download, solr_document) + "This item is restricted to members of the Lafayette College community." + else + "This item is unavailable to view." + end + end + end +end diff --git a/app/presenters/spot/base_presenter.rb b/app/presenters/spot/base_presenter.rb index 869a93ba6..2fd4a3052 100644 --- a/app/presenters/spot/base_presenter.rb +++ b/app/presenters/spot/base_presenter.rb @@ -15,6 +15,7 @@ module Spot class BasePresenter < ::Hyrax::WorkShowPresenter include PresentsAttributes include HumanizesDateFields + include MetadataOnlyDisplay # @return [String] def export_all_text diff --git a/app/views/catalog/_index_list_default.html.erb b/app/views/catalog/_index_list_default.html.erb index e7c9f7ba7..915a80c1f 100644 --- a/app/views/catalog/_index_list_default.html.erb +++ b/app/views/catalog/_index_list_default.html.erb @@ -18,9 +18,17 @@ <% highlight_values = extracted_text_highlight_values_for(document) %> - <% if highlight_values.length > 0 -%> + <% unless highlight_values.length.zero? -%>

<%= highlight_values.join(' ... ').html_safe %>

<% end -%> + + <% if document.embargo_release_date.present? %> +
File(s) under embargo until: <%= document.embargo_release_date %>
+ <% end %> + + <% if document.lease_expiration_date.present? %> +
File(s) available until: <%= document.lease_expiration_date %>
+ <% end %> diff --git a/app/views/hyrax/base/_items_table.html.erb b/app/views/hyrax/base/_items_table.html.erb index 22964e4e8..ed6bedea9 100644 --- a/app/views/hyrax/base/_items_table.html.erb +++ b/app/views/hyrax/base/_items_table.html.erb @@ -1,5 +1,4 @@ -<% array_of_ids = presenter.list_of_item_ids_to_display %> -<% members = presenter.member_presenters_for(array_of_ids) %> +<% members = presenter.member_presenters_for(presenter.list_of_item_ids_to_display) %>
@@ -15,15 +14,23 @@ <%= type %> - <%= link_to(member.link_name, contextual_path(member, presenter)) %> + + <% if presenter.metadata_only? -%> + <%= member.first_title %> + <% else %> + <%= link_to(member.link_name, contextual_path(member, presenter)) -%> + <% end %> + Uploaded <%= member.try(:date_uploaded) %> - <%= member.permission_badge %> + ><%= member.permission_badge %> + <% unless presenter.metadata_only? %> - <% if model_name == :file_set %> - <%= render "hyrax/file_sets/actions", file_set: member %> - <% end %> + <% if model_name == :file_set %> + <%= render "hyrax/file_sets/actions", file_set: member -%> + <% end %> - + <% end %> + <% end %> diff --git a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb index 2429a7290..7bce50355 100644 --- a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb +++ b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb @@ -5,18 +5,28 @@
<%= render 'workflow_actions_widget', presenter: presenter %> +
<%= render 'show_actions', presenter: presenter %>
+
- <%= render 'representative_media', presenter: presenter, viewer: presenter.iiif_viewer? %> -
+ <%# @todo make this a partial? %> + <% if presenter.metadata_only? %> +
+ <%= presenter.metadata_only_alert_text %> +
+ <% else %> + <%= render 'representative_media', presenter: presenter, viewer: presenter.iiif_viewer? %> +
+ <% end %> + <%#
%> <%# render 'citations', presenter: presenter %> <%# render 'social_media' %> <%#
%> - - <% highlight_values = extracted_text_highlight_values_for(document) %> - <% unless highlight_values.length.zero? -%> -
-

<%= highlight_values.join(' ... ').html_safe %>

-
- <% end -%> - - <% if document.embargo_release_date.present? %> -
File(s) under embargo until: <%= document.embargo_release_date %>
- <% end %> - - <% if document.lease_expiration_date.present? %> -
File(s) available until: <%= document.lease_expiration_date %>
- <% end %>
diff --git a/config/locales/spot.en.yml b/config/locales/spot.en.yml index 063a9f6a8..b8777d385 100644 --- a/config/locales/spot.en.yml +++ b/config/locales/spot.en.yml @@ -106,6 +106,10 @@ en: page_title: Terms of Use // %{name} work: + embargo: + catalog_result_html: File(s) under embargo until %{date} + lease: + catalog_result_html: File(s) available until %{date} export: additional_options: Additional options all_files: Download all files From bfe42892371ae185e25d220eaee5bbc0e2b902fa Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Mon, 15 Feb 2021 12:43:47 -0500 Subject: [PATCH 06/26] add specs --- app/actors/spot/actors/base_actor.rb | 17 ++-- .../shared_examples/spot_base_actor.rb | 82 +++++++++++++++++++ 2 files changed, 92 insertions(+), 7 deletions(-) diff --git a/app/actors/spot/actors/base_actor.rb b/app/actors/spot/actors/base_actor.rb index b9bce68e2..7dd6335ef 100644 --- a/app/actors/spot/actors/base_actor.rb +++ b/app/actors/spot/actors/base_actor.rb @@ -70,15 +70,18 @@ def transform_rights_statement(env) # # @return [true] def update_discovery_visibility(env) - private_val = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE - public_val = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC - wants_private_visibility = [env.curation_concern.visibility, env.attributes[:visibility]].include?(private_val) + visibility_possibilities = [ + env.curation_concern.visibility, + env.attributes[:visibility], + env.attributes[:visibility_during_embargo], + env.attributes[:visibility_during_lease] + ] - env.curation_concern.discover_groups ||= [] - env.curation_concern.discover_groups -= [public_val] if wants_private_visibility - env.curation_concern.discover_groups += [public_val] unless wants_private_visibility + wants_private = visibility_possibilities.flatten.include?(Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE) - true + env.curation_concern.discover_groups ||= [] + env.curation_concern.discover_groups -= ['public'] if wants_private + env.curation_concern.discover_groups += ['public'] unless wants_private end end end diff --git a/spec/support/shared_examples/spot_base_actor.rb b/spec/support/shared_examples/spot_base_actor.rb index 71759528d..63f86e206 100644 --- a/spec/support/shared_examples/spot_base_actor.rb +++ b/spec/support/shared_examples/spot_base_actor.rb @@ -80,4 +80,86 @@ end end end + + describe '#update_discover_visibility' do + let(:actor) { Hyrax::Actors::InterpretVisibilityActor.new(described_class.new(Hyrax::Actors::Terminator.new)) } + let(:attributes) { { visibility: viz } } + + let(:public_viz) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC } + let(:private_viz) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE } + let(:authenticated_viz) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED } + let(:embargoed_viz) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_EMBARGO } + let(:leased_viz) { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_LEASE } + + shared_examples 'it adjusts work#discover_groups based on desired visibility' do + # we're gonna use these two a lot in this example, so let's set up shared_examples + shared_examples 'it adds "public" to #discover_groups' do + subject { work.discover_groups } + + it { is_expected.to be_an(Array) } + it { is_expected.to include('public') } + end + + shared_examples 'it adds nothing to #discover_groups' do + subject { work.discover_groups } + + it { is_expected.to be_an(Array) } + it { is_expected.to be_empty } + end + + # now the different contexts: + context 'when visibility requested is "public"' do + let(:viz) { public_viz } + + it_behaves_like 'it adds "public" to #discover_groups' + end + + context 'when visibility requested is "private"' do + let(:viz) { private_viz } + + it_behaves_like 'it adds nothing to #discover_groups' + end + + context 'when embargo is requested' do + let(:attributes) do + { + visibility: embargoed_viz, + visibility_during_embargo: viz_during_embargo, + visibility_after_embargo: public_viz, + embargo_release_date: (Time.zone.today + 1.year).to_s + } + end + + context '(work is public during embargo)' do + let(:viz_during_embargo) { public_viz } + + it_behaves_like 'it adds "public" to #discover_groups' + end + + context '(work is authenticated during embargo)' do + let(:viz_during_embargo) { authenticated_viz } + + it_behaves_like 'it adds "public" to #discover_groups' + end + + context '(work is private during embargo)' do + let(:viz_during_embargo) { private_viz } + + it_behaves_like 'it adds nothing to #discover_groups' + end + end + end + + context '#create' do + before { actor.create(env) } + + it_behaves_like 'it adjusts work#discover_groups based on desired visibility' + end + + context '#update' do + before { actor.update(env) } + + it_behaves_like 'it adjusts work#discover_groups based on desired visibility' + end + end end From ecb3feb096069fd117c3982ef60b81ad4605a717 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Mon, 15 Feb 2021 13:38:15 -0500 Subject: [PATCH 07/26] test that pub -> priv removes discover_groups --- spec/support/shared_examples/spot_base_actor.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/support/shared_examples/spot_base_actor.rb b/spec/support/shared_examples/spot_base_actor.rb index 63f86e206..1414c3923 100644 --- a/spec/support/shared_examples/spot_base_actor.rb +++ b/spec/support/shared_examples/spot_base_actor.rb @@ -157,9 +157,19 @@ end context '#update' do + let(:work) { create(work_klass.to_s.downcase.to_sym, :public, discover_groups: ['public']) } + before { actor.update(env) } it_behaves_like 'it adjusts work#discover_groups based on desired visibility' + + context 'when a public item becomes private' do + let(:attributes) { { visibility: private_viz } } + + it 'removes "public" from work#discover_groups' do + expect(work.discover_groups).to be_empty + end + end end end end From 12fa677f13d08dcf22596c225df18fd0551eb5b0 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Wed, 17 Feb 2021 14:03:52 -0500 Subject: [PATCH 08/26] presenters: move common solr doc delegations to base_presenter --- app/presenters/hyrax/image_presenter.rb | 9 ++------- app/presenters/hyrax/publication_presenter.rb | 6 +----- app/presenters/spot/base_presenter.rb | 9 +++++++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/presenters/hyrax/image_presenter.rb b/app/presenters/hyrax/image_presenter.rb index f0800b566..30fb73f4f 100644 --- a/app/presenters/hyrax/image_presenter.rb +++ b/app/presenters/hyrax/image_presenter.rb @@ -5,13 +5,8 @@ class ImagePresenter < ::Spot::BasePresenter humanize_date_fields :date, :date_associated - delegate :contributor, :creator, :date_scope_note, :description, - :donor, :inscription, :keyword, :language_label, - :local_identifier, :note, :original_item_extent, :permalink, - :physical_medium, :publisher, :related_resource, :repository_location, - :requested_by, :research_assistance, :resource_type, - :rights_holder, :rights_statement, :source, - :standard_identifier, :subtitle, :title_alternative, + delegate :date_scope_note, :donor, :inscription, :original_item_extent, + :repository_location, :requested_by, :research_assistance to: :solr_document def subject_ocm diff --git a/app/presenters/hyrax/publication_presenter.rb b/app/presenters/hyrax/publication_presenter.rb index fa58e3f62..e36d0726a 100644 --- a/app/presenters/hyrax/publication_presenter.rb +++ b/app/presenters/hyrax/publication_presenter.rb @@ -4,11 +4,7 @@ class PublicationPresenter < ::Spot::BasePresenter humanize_date_fields :date_issued delegate :abstract, :academic_department, :bibliographic_citation, - :contributor, :creator, :date_available, - :division, :editor, :keyword, :language, :language_label, - :local_identifier, :organization, :permalink, :publisher, - :resource_type, :rights_holder, :source, :standard_identifier, - :subtitle, :title_alternative, + :date_available, :division, :editor, :organization, to: :solr_document # Metadata formats we're able to export as. diff --git a/app/presenters/spot/base_presenter.rb b/app/presenters/spot/base_presenter.rb index 2fd4a3052..d469f242f 100644 --- a/app/presenters/spot/base_presenter.rb +++ b/app/presenters/spot/base_presenter.rb @@ -17,6 +17,15 @@ class BasePresenter < ::Hyrax::WorkShowPresenter include HumanizesDateFields include MetadataOnlyDisplay + # delegate common properties to solr_document, so descendents only need + # to add their unique fields + delegate :contributor, :creator, :description, :identifier, :keyword, :language, + :language_label, :location, :local_identifier, :note, :permalink, :physical_medium, + :publisher, :related_resource, :resource_type, :rights_holder, :rights_statement, + :source, :standard_identifier, :subject, :subtitle, :title_alternative, :title, + :visibility, + to: :solr_document + # @return [String] def export_all_text I18n.t("spot.work.export.download_work_and_metadata_#{multiple_members? ? 'multiple' : 'single'}") From 3506e9f53275d58c70634bef94005434b1b0ceee Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Thu, 18 Feb 2021 13:45:20 -0500 Subject: [PATCH 09/26] :sweat_smile: oops --- app/presenters/hyrax/image_presenter.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/hyrax/image_presenter.rb b/app/presenters/hyrax/image_presenter.rb index 30fb73f4f..ccb89f619 100644 --- a/app/presenters/hyrax/image_presenter.rb +++ b/app/presenters/hyrax/image_presenter.rb @@ -6,7 +6,7 @@ class ImagePresenter < ::Spot::BasePresenter humanize_date_fields :date, :date_associated delegate :date_scope_note, :donor, :inscription, :original_item_extent, - :repository_location, :requested_by, :research_assistance + :repository_location, :requested_by, :research_assistance, to: :solr_document def subject_ocm From ec7287f5803eb84a73e6e4239200971ccac62596 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 10:39:47 -0500 Subject: [PATCH 10/26] check a solr_doc's id for permission, not the object --- app/presenters/concerns/spot/metadata_only_display.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/presenters/concerns/spot/metadata_only_display.rb b/app/presenters/concerns/spot/metadata_only_display.rb index 4ec04b848..bdbfc7e8f 100644 --- a/app/presenters/concerns/spot/metadata_only_display.rb +++ b/app/presenters/concerns/spot/metadata_only_display.rb @@ -13,7 +13,7 @@ module MetadataOnlyDisplay # # @return [true, false] def metadata_only? - @metadata_only ||= !(current_ability.admin? || current_ability.can?(:download, solr_document)) + @metadata_only ||= !(current_ability.admin? || current_ability.can?(:download, id)) end # Text content for the alert informing the user that they can not view a work's files. From ab731e6c7075932ab4b248241e5b070a44e493c2 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 10:40:48 -0500 Subject: [PATCH 11/26] ensure factory file_sets have the right permissions --- spec/factories/file_set.rb | 13 ++++++++++--- spec/factories/image.rb | 18 +++++++++++------- spec/factories/publication.rb | 19 ++++++++++++------- 3 files changed, 33 insertions(+), 17 deletions(-) diff --git a/spec/factories/file_set.rb b/spec/factories/file_set.rb index 16adac265..d3e61ac5b 100644 --- a/spec/factories/file_set.rb +++ b/spec/factories/file_set.rb @@ -18,11 +18,18 @@ end trait :public do - read_groups { ["public"] } + visibility { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC } + read_groups { ['public'] } end - trait :registered do - read_groups { ["registered"] } + trait :authenticated do + visibility { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED } + read_groups { ['registered'] } + end + + trait :private do + visibility { Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE } + read_groups { ['admin'] } end end end diff --git a/spec/factories/image.rb b/spec/factories/image.rb index 43038be64..8af137261 100644 --- a/spec/factories/image.rb +++ b/spec/factories/image.rb @@ -57,14 +57,18 @@ factory :image_with_file_set do after(:create) do |image, evaluator| - fs_opts = { - user: evaluator.user, - title: ['Image FileSet'], - label: evaluator.label - } - + fs_opts = { user: evaluator.user, title: ['Image FileSet'], label: evaluator.label } fs_opts[:content] = evaluator.content if evaluator.content - fs = create(:file_set, :public, **fs_opts) + fs_visibility = case image.visibility + when Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC + :public + when Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED + :authenticated + else + :private + end + + fs = create(:file_set, fs_visibility, **fs_opts) image.ordered_members << fs image.representative_id = fs.id diff --git a/spec/factories/publication.rb b/spec/factories/publication.rb index f7ce32382..ec9daeff1 100644 --- a/spec/factories/publication.rb +++ b/spec/factories/publication.rb @@ -56,14 +56,18 @@ factory :publication_with_file_set do after(:create) do |pub, evaluator| - fs_opts = { - user: evaluator.user, - title: ['Publication FileSet'], - label: evaluator.label - } - + fs_opts = { user: evaluator.user, title: ['Image FileSet'], label: evaluator.label } fs_opts[:content] = evaluator.content if evaluator.content - fs = create(:file_set, :public, **fs_opts) + fs_visibility = case pub.visibility + when Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC + :public + when Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED + :authenticated + else + :private + end + + fs = create(:file_set, fs_visibility, **fs_opts) pub.ordered_members << fs pub.representative_id = fs.id @@ -71,6 +75,7 @@ end end + before(:create) do |work, evaluator| work.apply_depositor_metadata(evaluator.user.user_key) end From d9d65ef4c0747cf530a6b6bcfee46366d60d3661 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 11:20:27 -0500 Subject: [PATCH 12/26] acab rubo --- spec/factories/publication.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/factories/publication.rb b/spec/factories/publication.rb index ec9daeff1..007ad5ba1 100644 --- a/spec/factories/publication.rb +++ b/spec/factories/publication.rb @@ -75,7 +75,6 @@ end end - before(:create) do |work, evaluator| work.apply_depositor_metadata(evaluator.user.user_key) end From 78037c50d0502e2938b6a72e9280985db95b9173 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 11:56:18 -0500 Subject: [PATCH 13/26] mini change --- app/actors/spot/actors/base_actor.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/actors/spot/actors/base_actor.rb b/app/actors/spot/actors/base_actor.rb index 7dd6335ef..93783af74 100644 --- a/app/actors/spot/actors/base_actor.rb +++ b/app/actors/spot/actors/base_actor.rb @@ -80,8 +80,12 @@ def update_discovery_visibility(env) wants_private = visibility_possibilities.flatten.include?(Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PRIVATE) env.curation_concern.discover_groups ||= [] - env.curation_concern.discover_groups -= ['public'] if wants_private - env.curation_concern.discover_groups += ['public'] unless wants_private + + if wants_private + env.curation_concern.discover_groups -= ['public'] + else + env.curation_concern.discover_groups += ['public'] + end end end end From 6b999f336efb7849131ce2fada344059d4eb11ab Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 12:42:50 -0500 Subject: [PATCH 14/26] move presenter metadata_only language to a helper/locales --- app/helpers/application_helper.rb | 25 ++++++++++++++ .../concerns/spot/metadata_only_display.rb | 33 ------------------- app/presenters/spot/base_presenter.rb | 15 ++++++++- .../_index_header_list_default.html.erb | 6 ++-- .../base/_metadata_and_viewer_panel.html.erb | 2 +- config/locales/spot.en.yml | 8 ++--- 6 files changed, 46 insertions(+), 43 deletions(-) delete mode 100644 app/presenters/concerns/spot/metadata_only_display.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3b6edad60..26e98e81a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -13,4 +13,29 @@ def extracted_text_highlight_values_for(document) return [] unless document.has_highlight_field? 'extracted_text_tsimv' document.highlight_field('extracted_text_tsimv').reject(&:blank?) end + + def metadata_only_display_html(document) + scope = ['spot', 'access_message'] + + if document.embargo_release_date.present? + key = 'embargo' + elsif document.lease_expiration_date.present? + key = 'lease' + elsif document.visibility == 'authenticated' && !current_ability.can?(:download, document.id) + key = 'authenticated' + else + key = 'private' + end + + args = { scope: scope, default: [ket, 'This message is unavailable to view.'] } + date_strftime_args = '%B %e, %Y' + + if key == 'embargo' + args[:date] = document.embargo_release_date.strftime(date_strftime_args) + elsif key = 'lease' + args[:date] = document.lease_expiration_date.strftime(date_strftime_args) + end + + I18n.t("#{key}_html", **args) + end end diff --git a/app/presenters/concerns/spot/metadata_only_display.rb b/app/presenters/concerns/spot/metadata_only_display.rb deleted file mode 100644 index bdbfc7e8f..000000000 --- a/app/presenters/concerns/spot/metadata_only_display.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true -module Spot - # Mixin for WorkShowPresenters to determine if an item - module MetadataOnlyDisplay - # Conditions for whether to display only metadata or the files attached: - # - "admin" users can see files for all items - # - if the user can +:download+ a record (which includes those that can +:read+), - # we'll show the file - # - if the item is "authenticated" and the user is logged in, show the file - # - if the item is "public" and not embargoed, show the file - # - # Otherwise, we'll display just the metadata. - # - # @return [true, false] - def metadata_only? - @metadata_only ||= !(current_ability.admin? || current_ability.can?(:download, id)) - end - - # Text content for the alert informing the user that they can not view a work's files. - # This should probably be moved to a helper method that uses the presenter and I18n. - # - # @return [Strinng] - def metadata_only_alert_text - if embargo_release_date.present? - "This item is under embargo until #{solr_document.embargo_release_date.strftime('%B %e, %Y')}.".html_safe - elsif visibility == 'authenticated' && !current_ability.can?(:download, solr_document) - "This item is restricted to members of the Lafayette College community." - else - "This item is unavailable to view." - end - end - end -end diff --git a/app/presenters/spot/base_presenter.rb b/app/presenters/spot/base_presenter.rb index d469f242f..a6eda54a3 100644 --- a/app/presenters/spot/base_presenter.rb +++ b/app/presenters/spot/base_presenter.rb @@ -15,7 +15,6 @@ module Spot class BasePresenter < ::Hyrax::WorkShowPresenter include PresentsAttributes include HumanizesDateFields - include MetadataOnlyDisplay # delegate common properties to solr_document, so descendents only need # to add their unique fields @@ -49,6 +48,20 @@ def location solr_document.location.zip(solr_document.location_label).reject(&:empty?) end + # Conditions for whether to display only metadata or the files attached: + # - "admin" users can see files for all items + # - if the user can +:download+ a record (which includes those that can +:read+), + # we'll show the file + # - if the item is "authenticated" and the user is logged in, show the file + # - if the item is "public" and not embargoed, show the file + # + # Otherwise, we'll display just the metadata. + # + # @return [true, false] + def metadata_only? + @metadata_only ||= !(current_ability.admin? || current_ability.can?(:download, id)) + end + # @return [true, false] def multiple_members? list_of_item_ids_to_display.count > 1 diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index a64f7bdeb..bc808aec9 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -1,10 +1,8 @@

<%= link_to document.title_or_label, document %>

- <% if [:embargo_release_date, :lease_expiration_date].any? { |m| document.public_send(m).present? } %> - <% template = document.embargo_release_date.present? ? 'embargo' : document.lease_expiration_date.present? ? 'lease' : nil %> - <% unless template.nil? %> + <% unless current_user.can?(:download, document.id) %>
- <%= t("spot.work.#{template}.catalog_result_html", date: document.embargo_release_date.strftime('%B %e, %Y')) %> + metadata_only_display_html(document)
<% end %> <% end %> diff --git a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb index 7bce50355..583224644 100644 --- a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb +++ b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb @@ -14,7 +14,7 @@ <%# @todo make this a partial? %> <% if presenter.metadata_only? %>
- <%= presenter.metadata_only_alert_text %> + <%= metadata_only_display_html(presenter.solr_document) %>
<% else %> <%= render 'representative_media', presenter: presenter, viewer: presenter.iiif_viewer? %> diff --git a/config/locales/spot.en.yml b/config/locales/spot.en.yml index b8777d385..99dd7b412 100644 --- a/config/locales/spot.en.yml +++ b/config/locales/spot.en.yml @@ -106,10 +106,10 @@ en: page_title: Terms of Use // %{name} work: - embargo: - catalog_result_html: File(s) under embargo until %{date} - lease: - catalog_result_html: File(s) available until %{date} + access_message: + authenticated_html: File access restricted to members of the Lafayette College community. + embargo_html: File(s) under embargo until %{date} + lease_html: File(s) available until %{date} export: additional_options: Additional options all_files: Download all files From 4a8726dd2c1b3bd832d832046d04e057f5c92b5d Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 13:12:03 -0500 Subject: [PATCH 15/26] cleanup metadata_only_display_html helper a little --- app/helpers/application_helper.rb | 32 +++++++++++++------------------ config/locales/spot.en.yml | 1 + 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 26e98e81a..848b96132 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,26 +15,20 @@ def extracted_text_highlight_values_for(document) end def metadata_only_display_html(document) - scope = ['spot', 'access_message'] + key = if document.embargo_release_date.present? + 'embargo_html' + elsif document.lease_expiration_date.present? + 'lease_html' + elsif document.registered? + 'authenticated_html' + else + # we shouldn't be getting here, but if we do, it's just a blanket "private" message + 'private_html' + end - if document.embargo_release_date.present? - key = 'embargo' - elsif document.lease_expiration_date.present? - key = 'lease' - elsif document.visibility == 'authenticated' && !current_ability.can?(:download, document.id) - key = 'authenticated' - else - key = 'private' - end - - args = { scope: scope, default: [ket, 'This message is unavailable to view.'] } - date_strftime_args = '%B %e, %Y' - - if key == 'embargo' - args[:date] = document.embargo_release_date.strftime(date_strftime_args) - elsif key = 'lease' - args[:date] = document.lease_expiration_date.strftime(date_strftime_args) - end + args = { scope: ['spot', 'access_message'], default: "This item's files are unavailable to view." } + args[:date] = document.embargo_release_date.strftime('%B %e, %Y') if key == 'embargo' + args[:date] = document.lease_expiration_date.strftime('%B %e, %Y') if key == 'lease' I18n.t("#{key}_html", **args) end diff --git a/config/locales/spot.en.yml b/config/locales/spot.en.yml index 99dd7b412..1db45972c 100644 --- a/config/locales/spot.en.yml +++ b/config/locales/spot.en.yml @@ -110,6 +110,7 @@ en: authenticated_html: File access restricted to members of the Lafayette College community. embargo_html: File(s) under embargo until %{date} lease_html: File(s) available until %{date} + private_html: This work's files are unavailable. export: additional_options: Additional options all_files: Download all files From 9b8bb70d0b864d1378cdf0daca6cecd60b8fe82a Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 13:21:51 -0500 Subject: [PATCH 16/26] stray <% end %> --- app/views/catalog/_index_header_list_default.html.erb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index bc808aec9..55243cd24 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -4,6 +4,5 @@
metadata_only_display_html(document)
- <% end %> <% end %>
From a3593c16ff0ccff9e78c2e0af37181e47b7ae294 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 14:20:28 -0500 Subject: [PATCH 17/26] don't assume current_user exists --- app/views/catalog/_index_header_list_default.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index 55243cd24..3200e0975 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -1,6 +1,6 @@

<%= link_to document.title_or_label, document %>

- <% unless current_user.can?(:download, document.id) %> + <% unless current_user && current_user.can?(:download, document.id) %>
metadata_only_display_html(document)
From 4a993b99d566e2f33e384fdf023fea2e0df86d3a Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 14:49:11 -0500 Subject: [PATCH 18/26] oops forgot erb tags --- app/views/catalog/_index_header_list_default.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index 3200e0975..4f89ff684 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -2,7 +2,7 @@

<%= link_to document.title_or_label, document %>

<% unless current_user && current_user.can?(:download, document.id) %>
- metadata_only_display_html(document) + <%= metadata_only_display_html(document) %>
<% end %>
From f5ca9299ae87ea047b4ce280ccab02965f6766a6 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 15:06:09 -0500 Subject: [PATCH 19/26] helper methods + views work --- app/controllers/catalog_controller.rb | 1 - app/helpers/spot/catalog_helper.rb | 9 ++++----- app/views/catalog/_index_header_list_default.html.erb | 2 +- app/views/catalog/_index_highlighting_default.html.erb | 6 ------ app/views/catalog/_index_list_default.html.erb | 7 +++++++ 5 files changed, 12 insertions(+), 13 deletions(-) delete mode 100644 app/views/catalog/_index_highlighting_default.html.erb diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 32e9e6ad4..5fd540942 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -23,7 +23,6 @@ class CatalogController < ApplicationController # partial config config.view.gallery.partials = [:index_header, :index] - config.index.partials = [:index_header, :thumbnail, :index, :index_highlighting] config.show.tile_source_field = :content_metadata_image_iiif_info_ssm config.show.partials.insert(1, :openseadragon) diff --git a/app/helpers/spot/catalog_helper.rb b/app/helpers/spot/catalog_helper.rb index 550c4b023..d8191242a 100644 --- a/app/helpers/spot/catalog_helper.rb +++ b/app/helpers/spot/catalog_helper.rb @@ -6,13 +6,12 @@ module CatalogHelper # # @return [String] def humanize_edtf_values(args) - Array.wrap(args[:value]).map { |val| humanize_edtf_value(val) }.to_sentence + Array.wrap(args[:value]).map { |val| Date.edtf(value).humanize rescue value }.to_sentence end - def humanize_edtf_value(value) - Date.edtf(value).humanize - rescue - value + def display_info_alert?(document) + return true if document.embargo_release_date.present? || document.lease_expiration_date.present? || document.authenticated? + false end end end diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index 4f89ff684..987f63283 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -1,6 +1,6 @@

<%= link_to document.title_or_label, document %>

- <% unless current_user && current_user.can?(:download, document.id) %> + <% if display_info_alert?(document) %>
<%= metadata_only_display_html(document) %>
diff --git a/app/views/catalog/_index_highlighting_default.html.erb b/app/views/catalog/_index_highlighting_default.html.erb deleted file mode 100644 index 00e77ded9..000000000 --- a/app/views/catalog/_index_highlighting_default.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -<% highlight_values = extracted_text_highlight_values_for(document) %> -<% unless highlight_values.length.zero? -%> -
-

<%= highlight_values.join(' ... ').html_safe %>

-
-<% end -%> diff --git a/app/views/catalog/_index_list_default.html.erb b/app/views/catalog/_index_list_default.html.erb index 60404220f..8cbd1ac99 100644 --- a/app/views/catalog/_index_list_default.html.erb +++ b/app/views/catalog/_index_list_default.html.erb @@ -15,5 +15,12 @@
<%= document.permalink %>
<% end %> + + <% highlight_values = extracted_text_highlight_values_for(document) %> + <% unless highlight_values.length.zero? -%> +
+

<%= highlight_values.join(' ... ').html_safe %>

+
+ <% end -%>
From 4ac21cbb5eae7d07c965190677061539229cfb6d Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 15:12:19 -0500 Subject: [PATCH 20/26] oof typos --- app/helpers/spot/catalog_helper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/helpers/spot/catalog_helper.rb b/app/helpers/spot/catalog_helper.rb index d8191242a..f1659163c 100644 --- a/app/helpers/spot/catalog_helper.rb +++ b/app/helpers/spot/catalog_helper.rb @@ -5,12 +5,14 @@ module CatalogHelper # Falls back to the original value. # # @return [String] + # rubocop:disable Style/RescueModifier def humanize_edtf_values(args) - Array.wrap(args[:value]).map { |val| Date.edtf(value).humanize rescue value }.to_sentence + Array.wrap(args[:value]).map { |value| Date.edtf(value).humanize rescue value }.to_sentence end + # rubocop:enable Style/RescueModifier def display_info_alert?(document) - return true if document.embargo_release_date.present? || document.lease_expiration_date.present? || document.authenticated? + return true if document.embargo_release_date.present? || document.lease_expiration_date.present? || document.registered? false end end From 772f72b7f135f5a6338c88c43540073682a475ff Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 15:27:33 -0500 Subject: [PATCH 21/26] more work on rendering the alert --- app/helpers/application_helper.rb | 7 ++++--- app/helpers/spot/catalog_helper.rb | 3 +-- app/presenters/spot/base_presenter.rb | 4 ++-- app/views/catalog/_index_header_list_default.html.erb | 6 +----- app/views/hyrax/base/_metadata_and_viewer_panel.html.erb | 4 +--- 5 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 848b96132..0fabdb608 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -14,7 +14,8 @@ def extracted_text_highlight_values_for(document) document.highlight_field('extracted_text_tsimv').reject(&:blank?) end - def metadata_only_display_html(document) + # @return [String] HTML of bootstrap alert with text + def document_access_display_alert(document) key = if document.embargo_release_date.present? 'embargo_html' elsif document.lease_expiration_date.present? @@ -26,10 +27,10 @@ def metadata_only_display_html(document) 'private_html' end - args = { scope: ['spot', 'access_message'], default: "This item's files are unavailable to view." } + args = { scope: ['spot', 'work', 'access_message'], default: "This item's files are currently unavailable." } args[:date] = document.embargo_release_date.strftime('%B %e, %Y') if key == 'embargo' args[:date] = document.lease_expiration_date.strftime('%B %e, %Y') if key == 'lease' - I18n.t("#{key}_html", **args) + %(

<%= link_to document.title_or_label, document %>

- <% if display_info_alert?(document) %> -
- <%= metadata_only_display_html(document) %> -
- <% end %> + <%= document_access_display_alert(document) if display_info_alert?(document) %>
diff --git a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb index 583224644..71fef302e 100644 --- a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb +++ b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb @@ -13,9 +13,7 @@
<%# @todo make this a partial? %> <% if presenter.metadata_only? %> -
- <%= metadata_only_display_html(presenter.solr_document) %> -
+ <%= document_access_display_alert(presenter) if display_info_alert?(presenter) %> <% else %> <%= render 'representative_media', presenter: presenter, viewer: presenter.iiif_viewer? %>
From 04f5f210df8cfa60b920523ea99c2b0289cbb728 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 15:36:36 -0500 Subject: [PATCH 22/26] cleanup display_alert helper --- app/helpers/application_helper.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0fabdb608..a24eabfe4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -17,20 +17,20 @@ def extracted_text_highlight_values_for(document) # @return [String] HTML of bootstrap alert with text def document_access_display_alert(document) key = if document.embargo_release_date.present? - 'embargo_html' + :embargo elsif document.lease_expiration_date.present? - 'lease_html' + :lease elsif document.registered? - 'authenticated_html' + :authenticated else # we shouldn't be getting here, but if we do, it's just a blanket "private" message - 'private_html' + :private end args = { scope: ['spot', 'work', 'access_message'], default: "This item's files are currently unavailable." } - args[:date] = document.embargo_release_date.strftime('%B %e, %Y') if key == 'embargo' - args[:date] = document.lease_expiration_date.strftime('%B %e, %Y') if key == 'lease' + args[:date] = document.embargo_release_date.strftime('%B %e, %Y') if key == :embargo + args[:date] = document.lease_expiration_date.strftime('%B %e, %Y') if key == :lease - %(
#{I18n.t(key, **args)}
).html_safe end end From f2426193250f7a267de409f72b93c05c067ebf73 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 15:47:40 -0500 Subject: [PATCH 23/26] fix labels in locales --- app/helpers/application_helper.rb | 2 +- config/locales/spot.en.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a24eabfe4..571ad0b90 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -31,6 +31,6 @@ def document_access_display_alert(document) args[:date] = document.embargo_release_date.strftime('%B %e, %Y') if key == :embargo args[:date] = document.lease_expiration_date.strftime('%B %e, %Y') if key == :lease - %(
#{I18n.t(key, **args)}
).html_safe + %(
#{I18n.t(key, **args).html_safe}
).html_safe end end diff --git a/config/locales/spot.en.yml b/config/locales/spot.en.yml index 1db45972c..89b15d170 100644 --- a/config/locales/spot.en.yml +++ b/config/locales/spot.en.yml @@ -107,10 +107,10 @@ en: work: access_message: - authenticated_html: File access restricted to members of the Lafayette College community. - embargo_html: File(s) under embargo until %{date} - lease_html: File(s) available until %{date} - private_html: This work's files are unavailable. + authenticated: File access restricted to members of the Lafayette College community. + embargo: File(s) under embargo until %{date} + lease: File(s) available until %{date} + private: This work's files are unavailable. export: additional_options: Additional options all_files: Download all files From e72d9e0c5e63ffee2a78b5658efb7425136a2452 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 16:03:12 -0500 Subject: [PATCH 24/26] maybe this will help? --- app/helpers/application_helper.rb | 4 ++-- app/views/catalog/_index_header_list_default.html.erb | 8 ++++++-- app/views/hyrax/base/_metadata_and_viewer_panel.html.erb | 7 +++---- app/views/hyrax/base/_restricted_access_alert.html.erb | 3 +++ 4 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 app/views/hyrax/base/_restricted_access_alert.html.erb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 571ad0b90..9871e14b7 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -15,7 +15,7 @@ def extracted_text_highlight_values_for(document) end # @return [String] HTML of bootstrap alert with text - def document_access_display_alert(document) + def document_access_display_text(document) key = if document.embargo_release_date.present? :embargo elsif document.lease_expiration_date.present? @@ -31,6 +31,6 @@ def document_access_display_alert(document) args[:date] = document.embargo_release_date.strftime('%B %e, %Y') if key == :embargo args[:date] = document.lease_expiration_date.strftime('%B %e, %Y') if key == :lease - %(
#{I18n.t(key, **args).html_safe}
).html_safe + I18n.t(key, **args) end end diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index 6aae30c04..f142ad2e7 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -1,4 +1,8 @@
-

<%= link_to document.title_or_label, document %>

- <%= document_access_display_alert(document) if display_info_alert?(document) %> +

<%= link_to(document.title_or_label, document) %>

+ <% if display_info_alert?(document) %> +
+ <%= document_access_display_text(presenter) %> +
+ <% end %>
diff --git a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb index 71fef302e..c2cf0452f 100644 --- a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb +++ b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb @@ -11,13 +11,12 @@
- <%# @todo make this a partial? %> <% if presenter.metadata_only? %> - <%= document_access_display_alert(presenter) if display_info_alert?(presenter) %> + <%= render('restricted_access_alert', presenter: presenter) if display_info_alert?(presenter) %> <% else %> <%= render 'representative_media', presenter: presenter, viewer: presenter.iiif_viewer? %> -
- <% end %> + <% end %> + <%#
%> <%# render 'citations', presenter: presenter %> diff --git a/app/views/hyrax/base/_restricted_access_alert.html.erb b/app/views/hyrax/base/_restricted_access_alert.html.erb new file mode 100644 index 000000000..a9fe295ba --- /dev/null +++ b/app/views/hyrax/base/_restricted_access_alert.html.erb @@ -0,0 +1,3 @@ +
+ <%= document_access_display_text(presenter) %> +
From 9213787b99564f9d88fe21dbb8df357cf31dde0c Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 16:11:37 -0500 Subject: [PATCH 25/26] more view typos + fixes --- app/views/catalog/_index_header_list_default.html.erb | 2 +- app/views/hyrax/base/_metadata_and_viewer_panel.html.erb | 8 +++++--- app/views/hyrax/base/_restricted_access_alert.html.erb | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index f142ad2e7..cb9b0f0ff 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -2,7 +2,7 @@

<%= link_to(document.title_or_label, document) %>

<% if display_info_alert?(document) %>
- <%= document_access_display_text(presenter) %> + <%= document_access_display_text(document) %>
<% end %>
diff --git a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb index c2cf0452f..f09345fa3 100644 --- a/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb +++ b/app/views/hyrax/base/_metadata_and_viewer_panel.html.erb @@ -11,9 +11,11 @@
- <% if presenter.metadata_only? %> - <%= render('restricted_access_alert', presenter: presenter) if display_info_alert?(presenter) %> - <% else %> + <% if display_info_alert?(presenter) %> + <%= render('restricted_access_alert', presenter: presenter) %> + <% end %> + + <% unless presenter.metadata_only? %> <%= render 'representative_media', presenter: presenter, viewer: presenter.iiif_viewer? %> <% end %>
diff --git a/app/views/hyrax/base/_restricted_access_alert.html.erb b/app/views/hyrax/base/_restricted_access_alert.html.erb index a9fe295ba..39ce36cb6 100644 --- a/app/views/hyrax/base/_restricted_access_alert.html.erb +++ b/app/views/hyrax/base/_restricted_access_alert.html.erb @@ -1,3 +1,3 @@
- <%= document_access_display_text(presenter) %> + <%= document_access_display_text(presenter).html_safe %>
From 9783a0f8da13e8f89f7baae92f812f66d6fa8b84 Mon Sep 17 00:00:00 2001 From: adam malantonio Date: Tue, 23 Feb 2021 16:15:37 -0500 Subject: [PATCH 26/26] html_safeify catalog info text --- app/views/catalog/_index_header_list_default.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/catalog/_index_header_list_default.html.erb b/app/views/catalog/_index_header_list_default.html.erb index cb9b0f0ff..bd00b6d4b 100644 --- a/app/views/catalog/_index_header_list_default.html.erb +++ b/app/views/catalog/_index_header_list_default.html.erb @@ -2,7 +2,7 @@

<%= link_to(document.title_or_label, document) %>

<% if display_info_alert?(document) %>
- <%= document_access_display_text(document) %> + <%= document_access_display_text(document).html_safe %>
<% end %>