-
Notifications
You must be signed in to change notification settings - Fork 2
/
ro-crate-preview.html.erb
72 lines (71 loc) · 1.82 KB
/
ro-crate-preview.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<%
def entity_to_html(entity)
if entity.is_a?(Array)
if entity.length == 1
entity_to_html(entity.first)
else
"<ul><li>#{entity.map { |e| entity_to_html(e) }.join('</li><li>')}</li></ul>"
end
elsif entity.is_a?(ROCrate::Entity)
label = entity['name'] || entity.id
if entity.external?
"<a href=\"#{entity.id}\" target=\"_blank\">#{label}</a>"
else
label
end
else
entity
end
end
%>
<!DOCTYPE html>
<html lang="en">
<head>
<title><%= name || "New RO-Crate" %></title>
<script type="application/ld+json"><%= metadata.generate %></script>
<meta name="generator" content="https://github.com/ResearchObject/ro-crate-ruby">
<meta name="keywords" content="RO-Crate">
<meta charset="utf-8">
</head>
<body>
<h1><%= name || "New RO-Crate" %></h1>
<% if url %>
<a href="<%= url %>" target="_blank"><%= url %></a>
<% end %>
<p>
<%= description %>
</p>
<dl>
<% if author %>
<dt>Author</dt>
<dd><%= entity_to_html author %></dd>
<% end %>
<% if contact_point %>
<dt>Contact</dt>
<dd><%= entity_to_html contact_point %></dd>
<% end %>
<% if publisher %>
<dt>Publisher</dt>
<dd><%= entity_to_html publisher %></dd>
<% end %>
<% if license %>
<dt>License</dt>
<dd><%= entity_to_html license %></dd>
<% end %>
</dl>
<h2>Contents</h2>
<ul>
<% data_entities.each do |data_entity| %>
<li>
<strong><%= entity_to_html data_entity %></strong>
<% if data_entity.content_size %>
<br/>Size: <%= entity_to_html data_entity.content_size %>
<% end %>
<% if data_entity.encoding_format %>
<br/>Format: <%= entity_to_html data_entity.encoding_format %>
<% end %>
</li>
<% end %>
</ul>
</body>
</html>