Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates how hyperlink fields are presented #708

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ def self.modified_field
}
end

config.add_search_field('content_genre') do |field|
solr_name = 'content_genre_ssi'
field.solr_local_parameters = {
qf: solr_name,
pf: solr_name
}
end

config.add_search_field('subject') do |field|
solr_name = "subject_tesim"
field.solr_local_parameters = {
Expand Down Expand Up @@ -277,6 +285,30 @@ def self.modified_field
}
end

config.add_search_field('research_categories') do |field|
solr_name = "research_categories_ssim"
field.solr_local_parameters = {
qf: solr_name,
pf: solr_name
}
end

config.add_search_field('parent_title') do |field|
solr_name = "parent_title_ssi"
field.solr_local_parameters = {
qf: solr_name,
pf: solr_name
}
end

config.add_search_field('publisher_version') do |field|
solr_name = "publisher_version_ssi"
field.solr_local_parameters = {
qf: solr_name,
pf: solr_name
}
end

# "sort results by" select (pulldown)
# label in pulldown is followed by the name of the SOLR field to sort by and
# whether the sort is ascending or descending (it must be asc or desc
Expand Down
21 changes: 21 additions & 0 deletions app/renderers/hyrax/renderers/custom_faceted_attribute_renderer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true
# frozen_string_literal: true
module Hyrax
module Renderers
class CustomFacetedAttributeRenderer < AttributeRenderer
private

def li_value(value)
link_to(ERB::Util.h(value), search_path(value))
end

def search_path(value)
Rails.application.routes.url_helpers.search_catalog_path("f[#{search_field}][]": value, locale: I18n.locale)
end

def search_field
options.fetch(:search_field, field)
end
end
end
end
19 changes: 13 additions & 6 deletions app/views/hyrax/base/_attribute_rows.html.erb
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
<!-- Hyrax v5.0.1 Override - the fields below are no longer dynamically delivered via Hyrax' config settings.
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 %>
<% custom_facet_renderer = ::Hyrax::Renderers::CustomFacetedAttributeRenderer %>
<% facet_renderer = ::Hyrax::Renderers::FacetedAttributeRenderer %>
<% external_link_renderer = ::Hyrax::Renderers::ExternalLinkAttributeRenderer %>
<% content_type_term = SelfDeposit::ContentTypesService.label(presenter.solr_document['emory_content_type_tesi']) %>
<!-- Persistent URL block start -->
<%= render 'purl', presenter: presenter %>
<!-- Persistent URL block end -->
<%= presenter.attribute_to_html(:date_modified, label: t('hyrax.base.show.last_modified'), html_dl: true) %>
<%= facet_renderer.new(:content_genre, presenter.solr_document['content_genre_ssi'], {}).render_dl_row %>
<%= custom_facet_renderer.new('content_genre',
presenter.solr_document['content_genre_ssi'], {search_field: 'content_genre_ssi'}).render_dl_row %>
<%= render 'creator', presenter: presenter %>
<%= presenter.attribute_to_html(:language, render_as: :faceted, html_dl: true) %>
<%= facet_renderer.new(:date_issued, presenter.solr_document['date_issued_ssi'], {}).render_dl_row %>
<%= custom_facet_renderer.new('language',
presenter.solr_document['language_tesim'], {search_field: 'language_tesim'}).render_dl_row %>
<%= custom_facet_renderer.new('date_issued',
presenter.solr_document['date_issued_ssi'], {search_field: 'date_issued_year_ssi'}).render_dl_row %>
<%= presenter.attribute_to_html(:publisher, render_as: :faceted, html_dl: true) %>
<%= facet_renderer.new(:publisher_version, presenter.solr_document['publisher_version_ssi'], {}).render_dl_row %>
<%= custom_facet_renderer.new('publisher_version',
presenter.solr_document['publisher_version_ssi'], {search_field: 'publisher_version_ssi'}).render_dl_row %>
<% if current_user.try(:admin?) %>
<%= presenter.attribute_to_html(:rights_statement, render_as: :rights_statement, html_dl: true) %>
<% end %>
<%= presenter.attribute_to_html(:rights_notes, html_dl: true) %>
<%= ::Hyrax::Renderers::LicenseAttributeRenderer.new(:license, presenter.solr_document['license_tesi'], {}).render_dl_row %>
<%= generic_renderer.new(:final_published_versions, presenter.solr_document['final_published_versions_tesim'], {}).render_dl_row %>
<%= facet_renderer.new(:parent_title, presenter.solr_document['parent_title_ssi'], {}).render_dl_row %>
<%= custom_facet_renderer.new('parent_title',
presenter.solr_document['parent_title_ssi'], {search_field: 'parent_title_ssi'}).render_dl_row %>
<%= facet_renderer.new(:conference_name, presenter.solr_document['conference_name_ssi'], {}).render_dl_row %>
<%= generic_renderer.new(:issn, presenter.solr_document['issn_tesi'], {}).render_dl_row %>
<%= generic_renderer.new(:isbn, presenter.solr_document['isbn_tesi'], {}).render_dl_row %>
Expand All @@ -39,7 +45,8 @@
<%= 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) %>
<%= presenter.attribute_to_html(:subject, render_as: :faceted, html_dl: true) %>
<%= facet_renderer.new(:research_categories, presenter.solr_document['research_categories_ssim'], {}).render_dl_row %>
<%= custom_facet_renderer.new('research_categories',
presenter.solr_document['research_categories_ssim'], {search_field: 'research_categories_ssim'}).render_dl_row %>
<% if current_user.try(:admin?) %>
<%= generic_renderer.new(:emory_ark, presenter.solr_document['emory_ark_tesim'], {}).render_dl_row %>
<%= generic_renderer.new(:internal_rights_note, presenter.solr_document['internal_rights_note_tesi'], {}).render_dl_row %>
Expand Down
14 changes: 14 additions & 0 deletions app/views/hyrax/base/relationships_parent_row.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<dt> <%= t(".label", type: type.humanize) %> </dt>
<dd>
<% if items.blank? %>
<p><%= t('.empty', type: type.humanize) %></p>
<% else %>
<ul class="tabular">
<% items.each do |item| %>
<li class='attribute attribute-title'>
<%= link_to item.title.first, search_catalog_path("f[admin_set_tesim][]": item.title.first) %>
</li>
<% end %>
</ul>
<% end %>
</dd>
17 changes: 17 additions & 0 deletions app/views/hyrax/base/relationships_parent_rows.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<% custom_facet_renderer = ::Hyrax::Renderers::CustomFacetedAttributeRenderer %>
<%# Render presenters which aren't specified in the 'presenter_types' %>
<% presenter.grouped_presenters(except: presenter.presenter_types).each_pair do |model_name, items| %>
<%= render 'relationships_parent_row', type: model_name, items: items, presenter: presenter %>
<% end %>

<%# Render grouped presenters. Show rows if there are any items of that type %>
<% presenter.presenter_types.each do |type| %>
<% presenter.grouped_presenters(filtered_by: type).each_pair do |_, items| %>
<%= render 'relationships_parent_row', type: type, items: items, presenter: presenter %>
<% end %>
<% end %>

<% if current_user %>
<%= custom_facet_renderer.new('admin_set_tesim',
presenter.solr_document['admin_set_tesim'], {}).render_dl_row %>
<% end %>