Skip to content

Commit

Permalink
change metadata lists to use dl and dd
Browse files Browse the repository at this point in the history
  • Loading branch information
wkdewey committed Nov 22, 2022
1 parent b2f3458 commit 73acff4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 47 deletions.
5 changes: 3 additions & 2 deletions app/helpers/orchid/display_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def metadata(res, label, api_field, link: true, separator: " | ", show_label: tr
end
end
html << dataArray
.map { |i| "<span>#{i}</span>" }
.map { |i| "#{i}" }
.join(separator)

sanitize html
Expand All @@ -38,6 +38,7 @@ def metadata_create_field_link(api_field, item)
item_label = facet_label(type: api_field, normalized: item, label: item)
link_to sanitize(item_label), prefix_path(route_path, search_params),
rel: "nofollow"
"<dd>#{link}</dd>"
end

# regardless of whether the results are a simple array or an array
Expand All @@ -58,7 +59,7 @@ def metadata_get_field_values(res, api_field)
# or could be used by overriding applications if desired
def metadata_label(label, length: nil)
# TODO add pluralization that uses locale
"<strong>#{label}:</strong> "
"<dt><strong>#{label}:</strong> </dt>"
end

end
20 changes: 6 additions & 14 deletions app/views/items/_search_res_items.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,27 @@
<h3><%= search_item_link(item) %></h3>
<div class="row">
<div class="<%= item["highlight"].present? ? "col-md-4" : "col-md-12" %> search_results_info">
<ul>
<dl>
<% if item["date_display"].present? %>
<li>
<%= metadata(item, t("search.results.item.date",
<%= metadata(item, t("search.results.item.date",
default: "Date"), "date_display", link: false) %>
</li>
<% end %>
<%# creator is a multivalued, nested field %>
<% if item["creator"].present? %>
<li>
<%= metadata(item, t("search.results.item.creator",
<%= metadata(item, t("search.results.item.creator",
default: "Creator"), "creator.name", link: false) %>
</li>
<% end %>
<%# format can be a multivalued or single keyword field %>
<% if item["format"].present? %>
<li>
<%= metadata(item, t("search.results.item.format",
<%= metadata(item, t("search.results.item.format",
default: "Format"), "format", link: false) %>
</li>
<% end %>
<%# source can be a multivalued or single keyword field %>
<% if item["source"].present? %>
<li>
<%= metadata(item, t("search.results.item.source",
<%= metadata(item, t("search.results.item.source",
default: "Source"), "source", link: false) %>
</li>
<% end %>
</ul>
</dl>
</div>
<% if item["highlight"].present? %>
<div class="col-md-8 search_results_text">
Expand Down
47 changes: 16 additions & 31 deletions app/views/items/_show_metadata.html.erb
Original file line number Diff line number Diff line change
@@ -1,59 +1,44 @@
<div class="metadata">
<ul>
<dl>
<% if @res["title"].present? %>
<li>
<%= metadata(@res, t("item.metadata.title", default: "Title"),
<%= metadata(@res, t("item.metadata.title", default: "Title"),
"title", link: false) %>
</li>
<% end %>
<% if @res["date_display"].present? %>
<li>
<%= metadata(@res, t("item.metadata.date", default: "Date"),
<%= metadata(@res, t("item.metadata.date", default: "Date"),
"date_display") %>
</li>
<% end %>
<% if @res["creator"].present? %>
<li>
<%= metadata(@res, t("item.metadata.creators", default: "Author(s)"),
<%= metadata(@res, t("item.metadata.creators", default: "Author(s)"),
"creator.name") %>
</li>
<% end %>
<% if @res["format"].present? %>
<li>
<%= metadata(@res, t("item.metadata.format", default: "Format"),
<%= metadata(@res, t("item.metadata.format", default: "Format"),
"format") %>
</li>
<% end %>
<% if @res["category"].present? %>
<li>
<%= metadata(@res, t("item.metadata.category", default: "Category"),
<%= metadata(@res, t("item.metadata.category", default: "Category"),
"category") %>
</li>
<% end %>
<% if @res["subcategory"].present? %>
<li>
<%= metadata(@res, t("item.metadata.subcategory",
<%= metadata(@res, t("item.metadata.subcategory",
default: "Subcategory"), "subcategory") %>
</li>
<% end %>
<% if @res["works"].present? %>
<li>
<%= sanitize metadata(@res, t("item.metadata.works", default: "Works"),
<%= metadata(@res, t("item.metadata.works", default: "Works"),
"works") %>
</li>
<% end %>
<% if @res["places"].present? %>
<li>
<%= metadata(@res, t("item.metadata.places", default: "Place(s)"),
<%= metadata(@res, t("item.metadata.places", default: "Place(s)"),
"places") %>
</li>
<% end %>
<%# When copying this template into projects, consider adding rel tag to the source link
to note the format and if the link is external %>
<% if @res["uri_data"].present? %>
<li><strong>Source Document: </strong>
<a href="<%= @res["uri_data"] %>"><%= File.basename(@res["uri_data"]) %></a>
</li>
<dt><strong>Source Document: </strong></dt>
<dl><a href="<%= @res["uri_data"] %>"><%= File.basename(@res["uri_data"]) %></a></dl>
<% end %>
</ul>
</dl>
<%# When copying this template into projects, consider adding rel tag to the source link
to note the format and if the link is external %>


</div>

0 comments on commit 73acff4

Please sign in to comment.