Skip to content

Commit

Permalink
💄 Match catalog search results match to Hyrax
Browse files Browse the repository at this point in the history
This commit will along the look of the catalog search results page to
look closer to the way Hyrax looks.  The problem stems from the
markdown feature.  For plain text it adds a `<p>` tag which has a margin
bottom.  I think the best thing to do is turn it off for default and any
tenant that is currently using it should turn it back on.
  • Loading branch information
kirkkwang committed Sep 23, 2024
1 parent 4c4a1df commit 89a755c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
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,
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

0 comments on commit 89a755c

Please sign in to comment.