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

💄 Match catalog search results match to Hyrax #2344

Merged
merged 1 commit into from
Sep 23, 2024
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
29 changes: 15 additions & 14 deletions app/views/catalog/_index_list_default.html.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
<%# OVERRIDE Hyrax 5.0.1 to enable markdown for index field values in search results %>
<%# OVERRIDE Hyrax 5.0.1 to handle search only accounts %>

<div class="col-md-6">
<div class="ol-md-9 col-lg-6">
<div class="metadata">
<dl class="dl-horizontal">
<dl>
<% doc_presenter = index_presenter(document) %>
<% index_fields(document).each do |field_name, field| -%>
<% if should_render_index_field? document, field %>
<dt data-solr-field-name="<%= field_name %>"><%= render_index_field_label document, field: field_name %></dt>
<dd><%= markdown(doc_presenter.field_value field) %></dd>
<% end %>
<% if should_render_index_field? document, field %>
<div class="row">
<dt class="col-5 text-right" data-solr-field-name="<%= field_name %>"><%= render_index_field_label document, field: field_name %></dt>
<dd class="col-7"><%= markdown(doc_presenter.field_value field) %></dd>
</div>
<% end %>
<% end %>
<% if current_account.search_only %>
<% if document.account_institution_name.first.present? %>
<small class="search-only-institution-link">
<% if document.account_institution_name.first.present? %>
<small class="search-only-institution-link">
<span>From: <%= link_to "//#{document.account_cname.first}", target: :_blank do %>
<%= document.account_institution_name&.join %>
<% end %></span>
</small>
<% end %>
</small>
<% end %>
<% end %>
</dl>
</div>
</div>
<% if document.collection? %>
<% collection_presenter = Hyrax::CollectionPresenter.new(document, current_ability) %>
<div class="col-md-4">
<div class="col-md-12 col-lg-3">
<div class="collection-counts-wrapper">
<div class="collection-counts-item">
<span><%= collection_presenter.total_viewable_collections %></span>Collections
<span><%= collection_presenter.total_viewable_collections %></span>Collections
</div>
<div class="collection-counts-item">
<span><%= collection_presenter.total_viewable_works %></span>Works
<span><%= collection_presenter.total_viewable_works %></span>Works
</div>
</div>
</div>
<% end %>

2 changes: 1 addition & 1 deletion config/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
description: "Show General Login Link at Top Right of Page."

feature :treat_some_user_inputs_as_markdown,
default: true,
default: false,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feature was brought over from PALs specifically, i don't think it should be a default for ALL hyku

description: "Treat some user inputs (e.g. titles and descriptions) as markdown."
end
19 changes: 16 additions & 3 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,22 @@
let(:header) { '# header' }
let(:bold) { '*bold*' }

it 'renders markdown into html' do
expect(helper.markdown(header)).to eq("<h1>header</h1>\n")
expect(helper.markdown(bold)).to eq("<p><em>bold</em></p>\n")
context 'when treat_some_user_inputs_as_markdown is true' do
it 'renders markdown into html' do
allow(Flipflop).to receive(:treat_some_user_inputs_as_markdown?).and_return(true)

expect(helper.markdown(header)).to eq("<h1>header</h1>\n")
expect(helper.markdown(bold)).to eq("<p><em>bold</em></p>\n")
end
end

context 'when treat_some_user_inputs_as_markdown is false' do
it 'does not render markdown into html' do
allow(Flipflop).to receive(:treat_some_user_inputs_as_markdown?).and_return(false)

expect(helper.markdown(header)).to eq('# header')
expect(helper.markdown(bold)).to eq('*bold*')
end
end
end

Expand Down
Loading