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

Descriptive terms #275

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions app/helpers/orchid/display_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def metadata(res, label, api_field, link: true, separator: " | ")
end
end
html << dataArray
.map { |i| "<span>#{i}</span>" }
.map { |i| "#{i}" }
Copy link
Member

Choose a reason for hiding this comment

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

I think changing this to

.map { |i| "<dd>#{i}</dd>" |

is what we want to replace all of the old <li> tags with <dd> tags

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed as suggested

.join(separator)

sanitize html
Expand All @@ -36,6 +36,7 @@ def metadata_create_field_link(api_field, item)
item_label = value_label(api_field, item)
link_to item_label, prefix_path(route_path, search_params),
rel: "nofollow"
"<dd>#{link}</dd>"
Copy link
Member

@techgique techgique Dec 20, 2022

Choose a reason for hiding this comment

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

There's no link variable in scope here. The return of link_to would have to be assigned to one first. But I think there's another oversight here. This is the only place we have <dd> and </dd> tags. This code here only affects output when the metadata method isn't called with link: false, but it is in many places. So they won't be wrapping non-link metadata info as the non-centralized <li> tags in the template were before. I think we actually want to just remove this line here and handle output of the <dd> tags in the .map above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as suggested

end

# regardless of whether the results are a simple array or an array
Expand All @@ -56,7 +57,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>
<%= 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>