diff --git a/lib/ro_crate/ro-crate-preview.html.erb b/lib/ro_crate/ro-crate-preview.html.erb index cea9075..a9fe05a 100644 --- a/lib/ro_crate/ro-crate-preview.html.erb +++ b/lib/ro_crate/ro-crate-preview.html.erb @@ -1,3 +1,23 @@ +<% + def entity_to_html(entity) + if entity.is_a?(Array) + if entity.length == 1 + entity_to_html(entity.first) + else + "" + end + elsif entity.is_a?(ROCrate::Entity) + label = entity['name'] || entity.id + if entity.external? + "#{label}" + else + label + end + else + entity + end + end +%> @@ -18,36 +38,32 @@
<% if author %>
Author
-
<%= author %>
+
<%= entity_to_html author %>
<% end %> <% if contact_point %>
Contact
-
<%= contact_point %>
+
<%= entity_to_html contact_point %>
<% end %> <% if publisher %>
Publisher
-
<%= publisher %>
+
<%= entity_to_html publisher %>
<% end %> <% if license %>
License
-
<%= license %>
+
<%= entity_to_html license %>
<% end %>

Contents