From 320917778cad0cddad215cfe1ae13c046d5f1949 Mon Sep 17 00:00:00 2001 From: C Barton <43180845+CB987@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:58:14 -0500 Subject: [PATCH] 694 supplemental links (#705) * Changes this field to render a link rather than a facet. * Overrides renderer file so that external link opens in new tab. * Fixes ruby syntax that circle ci didn't like * Gives renderer a variable. --- .../renderers/external_link_attribute_renderer.rb | 15 +++++++++++++++ app/views/hyrax/base/_attribute_rows.html.erb | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/renderers/hyrax/renderers/external_link_attribute_renderer.rb diff --git a/app/renderers/hyrax/renderers/external_link_attribute_renderer.rb b/app/renderers/hyrax/renderers/external_link_attribute_renderer.rb new file mode 100644 index 00000000..c53f0051 --- /dev/null +++ b/app/renderers/hyrax/renderers/external_link_attribute_renderer.rb @@ -0,0 +1,15 @@ +# +# frozen_string_literal: true +module Hyrax + module Renderers + class ExternalLinkAttributeRenderer < AttributeRenderer + private + + def li_value(value) + auto_link(value, :urls, target: "_blank", rel: "noopener noreferrer") do |link| + " #{link}" + end + end + end + end +end diff --git a/app/views/hyrax/base/_attribute_rows.html.erb b/app/views/hyrax/base/_attribute_rows.html.erb index 043e7362..71d758ac 100644 --- a/app/views/hyrax/base/_attribute_rows.html.erb +++ b/app/views/hyrax/base/_attribute_rows.html.erb @@ -2,6 +2,7 @@ Instead, they are hard coded here. We, in turn, have overridden this partial so we can institute our own choices/order. --> <% generic_renderer = ::Hyrax::Renderers::AttributeRenderer %> <% facet_renderer = ::Hyrax::Renderers::FacetedAttributeRenderer %> +<% external_link_renderer = ::Hyrax::Renderers::ExternalLinkAttributeRenderer %> <% content_type_term = SelfDeposit::ContentTypesService.label(presenter.solr_document['emory_content_type_tesi']) %> <%= render 'purl', presenter: presenter %> @@ -33,7 +34,7 @@ <%= facet_renderer.new(:sponsor, presenter.solr_document['sponsor_ssi'], {}).render_dl_row %> <%= facet_renderer.new(:grant_agencies, presenter.solr_document['grant_agencies_ssim'], {}).render_dl_row %> <%= generic_renderer.new(:grant_information, presenter.solr_document['grant_information_tesim'], {}).render_dl_row %> -<%= facet_renderer.new(:related_datasets, presenter.solr_document['related_datasets_ssim'], {}).render_dl_row %> +<%= external_link_renderer.new(:related_datasets, presenter.solr_document['related_datasets_ssim'], {}).render_dl_row %> <%= presenter.attribute_to_html(:abstract, html_dl: true) %> <%= generic_renderer.new(:author_notes, presenter.solr_document['author_notes_tesi'], {}).render_dl_row %> <%= presenter.attribute_to_html(:keyword, render_as: :faceted, html_dl: true) %>