ttl2html 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ttl2html/template.rb +8 -5
- data/lib/ttl2html/version.rb +1 -1
- data/lib/ttl2html.rb +10 -4
- data/templates/default.html.erb +2 -2
- data/templates/index.html.erb +5 -3
- data/templates/layout.html.erb +10 -8
- data/templates/shape-table.html.erb +3 -1
- data/templates/triples.html.erb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 946f8e7de3a456635e40617b88ce014dcd7b54442557ded55a51ca3ad6dfb5b1
|
|
4
|
+
data.tar.gz: 4bbb58d451d13e71f84c2bd1efe9ca897b695691768337ebb45d97c19badbcfa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0db603f9cd36379e948f3a5a30e65db301af01d8df0a98c59dffcdc125934a8f006af140fb318d439466020ac1a4f7cebc2987f7ab06b49f3724431b1541f2d3
|
|
7
|
+
data.tar.gz: 51516e8a7b73c4260ad5d7f23a440462dda00c8300ace92bf567a955b14386981f38ed427d27a9e707873c5c83699beac709aa61aa9a81a7b53ca9167a819ebb
|
data/lib/ttl2html/template.rb
CHANGED
|
@@ -5,6 +5,7 @@ require "pathname"
|
|
|
5
5
|
require "erb"
|
|
6
6
|
require "i18n"
|
|
7
7
|
require "action_view"
|
|
8
|
+
require "nokogiri"
|
|
8
9
|
|
|
9
10
|
module TTL2HTML
|
|
10
11
|
class Template
|
|
@@ -107,6 +108,7 @@ module TTL2HTML
|
|
|
107
108
|
required: data[property]["http://www.w3.org/ns/shacl#minCount"] ? data[property]["http://www.w3.org/ns/shacl#minCount"].first.to_i > 0 : false,
|
|
108
109
|
repeatable: repeatable,
|
|
109
110
|
nodeKind: data[property]["http://www.w3.org/ns/shacl#nodeKind"] ? data[property]["http://www.w3.org/ns/shacl#nodeKind"].first : nil,
|
|
111
|
+
class: data[property]["http://www.w3.org/ns/shacl#class"] ? data[property]["http://www.w3.org/ns/shacl#class"].first : nil,
|
|
110
112
|
nodes: nodes,
|
|
111
113
|
node_mode: node_mode,
|
|
112
114
|
prefix: prefix_used,
|
|
@@ -158,9 +160,10 @@ module TTL2HTML
|
|
|
158
160
|
end
|
|
159
161
|
def shorten_title(title, length = 140)
|
|
160
162
|
if title.to_s.length > length
|
|
161
|
-
title.to_s[0..length]
|
|
163
|
+
short_title = Nokogiri::HTML::DocumentFragment.parse(title.to_s[0..length])
|
|
164
|
+
short_title.to_html + "..."
|
|
162
165
|
else
|
|
163
|
-
title
|
|
166
|
+
ERB::Util.html_escape title
|
|
164
167
|
end
|
|
165
168
|
end
|
|
166
169
|
def get_title(data, default_title = "no title")
|
|
@@ -208,7 +211,7 @@ module TTL2HTML
|
|
|
208
211
|
if /\Ahttps?:\/\// =~ object.to_s
|
|
209
212
|
rel_path = relative_path_uri(object, param[:base_uri])
|
|
210
213
|
if param[:data_global][object]
|
|
211
|
-
result = "<a href=\"#{rel_path}\">#{get_title(param[:data_global][object]) or object}</a>"
|
|
214
|
+
result = "<a href=\"#{rel_path}\">#{get_title(param[:data_global][object]) or ERB::Util.html_escape(object)}</a>"
|
|
212
215
|
subtitle = get_subtitle(param[:data_global][object])
|
|
213
216
|
if subtitle
|
|
214
217
|
result += " <small>#{subtitle}</small>"
|
|
@@ -216,7 +219,7 @@ module TTL2HTML
|
|
|
216
219
|
result
|
|
217
220
|
end
|
|
218
221
|
else
|
|
219
|
-
"<a href=\"#{rel_path}\">#{object}</a>"
|
|
222
|
+
"<a href=\"#{rel_path}\">#{ERB::Util.html_escape object}</a>"
|
|
220
223
|
end
|
|
221
224
|
elsif /\A_:/ =~ object.to_s and param[:data_global][object]
|
|
222
225
|
if type[:inverse] and param[:data_inverse_global][object]
|
|
@@ -225,7 +228,7 @@ module TTL2HTML
|
|
|
225
228
|
format_triples(param[:data_global][object], blank: true)
|
|
226
229
|
end
|
|
227
230
|
else
|
|
228
|
-
object
|
|
231
|
+
ERB::Util.html_escape object
|
|
229
232
|
end
|
|
230
233
|
end
|
|
231
234
|
def format_triples(triples, type = {})
|
data/lib/ttl2html/version.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
TTL2HTML::VERSION = "2.
|
|
1
|
+
TTL2HTML::VERSION = "2.3.0"
|
data/lib/ttl2html.rb
CHANGED
|
@@ -34,7 +34,7 @@ module TTL2HTML
|
|
|
34
34
|
end
|
|
35
35
|
[ :css_file, :javascript_file ].each do |k|
|
|
36
36
|
if config[k]
|
|
37
|
-
config[k] =
|
|
37
|
+
config[k] = Array(config[k]).flatten
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
config
|
|
@@ -82,6 +82,7 @@ module TTL2HTML
|
|
|
82
82
|
end
|
|
83
83
|
result << @data[subject.to_s].keys.sort.map do |predicate|
|
|
84
84
|
str = "<#{predicate}> "
|
|
85
|
+
#p [subject, predicate, @data[subject.to_s][predicate]]
|
|
85
86
|
str << @data[subject.to_s][predicate].sort_by do |object|
|
|
86
87
|
#p [subject, predicate, object, depth]
|
|
87
88
|
if object.to_s =~ /^_:/ and @data[object.to_s]
|
|
@@ -94,7 +95,7 @@ module TTL2HTML
|
|
|
94
95
|
format_turtle(object, depth + 1)
|
|
95
96
|
]
|
|
96
97
|
else
|
|
97
|
-
object.to_s
|
|
98
|
+
[Float::INFINITY, Float::INFINITY, Float::INFINITY, object.to_s]
|
|
98
99
|
end
|
|
99
100
|
end.map do |object|
|
|
100
101
|
if /^_:/ =~ object.to_s # blank node:
|
|
@@ -152,6 +153,8 @@ module TTL2HTML
|
|
|
152
153
|
labels = shapes2labels(shapes)
|
|
153
154
|
versions = extract_versions
|
|
154
155
|
toplevel = extract_toplevel
|
|
156
|
+
about_required = template.find_template_path("about.html") || !shapes.empty? || !versions.empty? || !toplevel.empty?
|
|
157
|
+
about_file = (@config[:about_file] || "about.html") if about_required
|
|
155
158
|
@config[:labels_with_class] ||= {}
|
|
156
159
|
labels.each do |klass, props|
|
|
157
160
|
props.each do |property, label|
|
|
@@ -188,6 +191,7 @@ module TTL2HTML
|
|
|
188
191
|
if template.find_template_path("_default.html.erb")
|
|
189
192
|
param[:additional_content] = template.to_html_raw("_default.html.erb", param)
|
|
190
193
|
end
|
|
194
|
+
param[:about_file] = about_file if about_required
|
|
191
195
|
template.output_to(file, param)
|
|
192
196
|
end
|
|
193
197
|
index_html = "index.html"
|
|
@@ -226,14 +230,16 @@ module TTL2HTML
|
|
|
226
230
|
end
|
|
227
231
|
param[:output_file] = index_html
|
|
228
232
|
param[:index_list] = template.to_html_raw("index-list.html.erb", param)
|
|
233
|
+
param[:about_file] = about_file if about_required
|
|
229
234
|
template.output_to(index_html, param)
|
|
230
235
|
end
|
|
231
236
|
end
|
|
232
|
-
if
|
|
233
|
-
about_html =
|
|
237
|
+
if about_required
|
|
238
|
+
about_html = about_file
|
|
234
239
|
about_html = File.join(@config[:output_dir], about_html) if @config[:output_dir]
|
|
235
240
|
template = Template.new("about.html.erb", @config)
|
|
236
241
|
param = @config.dup
|
|
242
|
+
param[:about_file] = about_file
|
|
237
243
|
param[:content] = template.to_html_raw("about.html", {}) if template.find_template_path("about.html")
|
|
238
244
|
param[:data_global] = @data
|
|
239
245
|
param[:versions] = versions
|
data/templates/default.html.erb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<div class="jumbotron">
|
|
2
2
|
<div class="container">
|
|
3
|
-
<h1><%=
|
|
3
|
+
<h1><%= param[:title] %></h1>
|
|
4
4
|
<%- if param[:subtitle] -%>
|
|
5
|
-
<p class="lead"><%=
|
|
5
|
+
<p class="lead"><%= param[:subtitle] %></p>
|
|
6
6
|
<%- end -%>
|
|
7
7
|
<p><i class="bi bi-link-45deg"></i> <a href="<%=h param[:uri] %>"><%=h param[:uri] %></a></p>
|
|
8
8
|
</div>
|
data/templates/index.html.erb
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
<div class="description"><%= param[:description] %></div>
|
|
9
9
|
<%- end -%>
|
|
10
10
|
<p><i class="bi bi-link-45deg"></i> <a href="<%=h param[:base_uri] %>"><%=h param[:base_uri] %></a></p>
|
|
11
|
-
|
|
11
|
+
<%- if param[:about_file] -%>
|
|
12
|
+
<p><a class="btn btn-info" href="<%=h relative_path(param[:about_file]) %>"><%=h t("about.title", title: param[:site_title]) %> »</a></p>
|
|
13
|
+
<%- end -%>
|
|
12
14
|
</div>
|
|
13
15
|
</div>
|
|
14
16
|
<div class="container">
|
|
@@ -20,8 +22,8 @@
|
|
|
20
22
|
<dl>
|
|
21
23
|
<%= format_version_info(param[:versions].last) %>
|
|
22
24
|
</dl>
|
|
23
|
-
<%- if param[:versions].size > 1 -%>
|
|
24
|
-
<p><a href="
|
|
25
|
+
<%- if param[:about_file] and param[:versions].size > 1 -%>
|
|
26
|
+
<p><a href="<%=h relative_path(param[:about_file]) %>#versions">» <%=h t("index.past-versions") %></a></p>
|
|
25
27
|
<%- end -%>
|
|
26
28
|
<%- if param[:toplevel] and not param[:toplevel][:license].empty? -%>
|
|
27
29
|
<p class="license">
|
data/templates/layout.html.erb
CHANGED
|
@@ -8,16 +8,16 @@
|
|
|
8
8
|
<%- if @template == "about.html.erb" and param[:about_toc] -%>
|
|
9
9
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc/dist/bootstrap-toc.min.css">
|
|
10
10
|
<%- end -%>
|
|
11
|
-
<%- param[:css_file].each do |file| -%>
|
|
11
|
+
<%- Array(param[:css_file]).each do |file| -%>
|
|
12
12
|
<link rel="stylesheet" href="<%=h relative_path(file) %>">
|
|
13
|
-
<%- end
|
|
13
|
+
<%- end -%>
|
|
14
14
|
<%- if param[:custom_css] -%>
|
|
15
15
|
<style type="text/css"><%=h param[:custom_css] %></style>
|
|
16
16
|
<%- end -%>
|
|
17
|
-
<title><%=
|
|
17
|
+
<title><%= html_title(param) %></title>
|
|
18
18
|
<meta name="twitter:card" content="summary">
|
|
19
|
-
<meta name="twitter:title" content="<%=
|
|
20
|
-
<meta property="og:title" content="<%=
|
|
19
|
+
<meta name="twitter:title" content="<%= html_title(param) %>">
|
|
20
|
+
<meta property="og:title" content="<%= html_title(param) %>">
|
|
21
21
|
<%- if param[:ogp] and param[:ogp]["type"] -%>
|
|
22
22
|
<meta property="og:type" content="<%=h param[:ogp]["type"] %>">
|
|
23
23
|
<%- else -%>
|
|
@@ -63,9 +63,11 @@
|
|
|
63
63
|
<li class="nav-item<%= ' active' if @template == "index.html.erb" %>">
|
|
64
64
|
<a class="nav-link" href="<%=h relative_path_uri(param[:base_uri]) %>">Home</a>
|
|
65
65
|
</li>
|
|
66
|
+
<%- if param[:about_file] -%>
|
|
66
67
|
<li class="nav-item<%= ' active' if @template == "about.html.erb" %>">
|
|
67
|
-
<a class="nav-link" href="<%=h relative_path(param[:about_file]
|
|
68
|
+
<a class="nav-link" href="<%=h relative_path(param[:about_file]) %>">About</a>
|
|
68
69
|
</li>
|
|
70
|
+
<%- end -%>
|
|
69
71
|
<%- if param[:additional_link] -%>
|
|
70
72
|
<%- param[:additional_link].each do |link| -%>
|
|
71
73
|
<li class="nav-item"><a class="nav-link" href="<%=h link["href"] %>"><%=h link["label"] %></a></li>
|
|
@@ -100,8 +102,8 @@
|
|
|
100
102
|
<%- if @template == "about.html.erb" and param[:about_toc] -%>
|
|
101
103
|
<script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc/dist/bootstrap-toc.min.js"></script>
|
|
102
104
|
<%- end -%>
|
|
103
|
-
<%- param[:javascript_file].each do |file| -%>
|
|
105
|
+
<%- Array(param[:javascript_file]).each do |file| -%>
|
|
104
106
|
<script src="<%=h relative_path(file) %>"></script>
|
|
105
|
-
<%- end
|
|
107
|
+
<%- end -%>
|
|
106
108
|
</body>
|
|
107
109
|
</html>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<table class="table table-sm">
|
|
2
|
+
<thead>
|
|
2
3
|
<tr>
|
|
3
4
|
<th><%=h t('shape-table.header.property-name') %></th>
|
|
4
5
|
<th><%=h t('shape-table.header.description') %></th>
|
|
@@ -7,6 +8,7 @@
|
|
|
7
8
|
<%=h t('shape-table.header.repeatable') %></th>
|
|
8
9
|
<th><%=h t('shape-table.header.note') %></th>
|
|
9
10
|
</tr>
|
|
11
|
+
</thead>
|
|
10
12
|
<tbody>
|
|
11
13
|
<%- param[:properties].each do |property| -%>
|
|
12
14
|
<tr>
|
|
@@ -16,7 +18,7 @@
|
|
|
16
18
|
<td class="url"><code><%=h property[:shorten_path] %></code></td>
|
|
17
19
|
<%- end -%>
|
|
18
20
|
<td><%= property[:name] %></td>
|
|
19
|
-
<%- if property[:nodeKind] == "http://www.w3.org/ns/shacl#IRI" -%>
|
|
21
|
+
<%- if property[:nodeKind] == "http://www.w3.org/ns/shacl#IRI" or property[:class] -%>
|
|
20
22
|
<td class="url"><%= property[:example] %></td>
|
|
21
23
|
<%- else -%>
|
|
22
24
|
<td><%= property[:example] %></td>
|
data/templates/triples.html.erb
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
<%- if param[:type][:blank] -%>
|
|
2
|
+
<dl class="row<%= if param[:type][:blank] then ' border' end %>" itemscope>
|
|
3
|
+
<%- else -%>
|
|
4
|
+
<dl class="row<%= if param[:type][:blank] then ' border' end %>" itemscope itemid="<%=h param[:uri] %>">
|
|
5
|
+
<%- end -%>
|
|
2
6
|
<%- param[:data].sort_by{|k, v|
|
|
3
7
|
order = param[:orders][k] if param[:orders] and param[:orders][k]
|
|
4
8
|
order = Float::INFINITY if order.nil?
|
|
@@ -7,9 +11,11 @@
|
|
|
7
11
|
<dt class="col-sm-3"><%=h format_property(k, param[:labels]) %></dt>
|
|
8
12
|
<%- v.sort_by{|e| sort_criteria(e, param[:data_global]) }.each_with_index do |v2, idx| -%>
|
|
9
13
|
<%- if v2.respond_to? :language and v2.language? -%>
|
|
10
|
-
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" lang="<%=h v2.language %>"><%= format_object v2, param[:data], param[:type] %></dd>
|
|
14
|
+
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" lang="<%=h v2.language %>" itemprop="<%=h k %>"><%= format_object v2, param[:data], param[:type] %></dd>
|
|
15
|
+
<%- elsif /\Ahttps?:\/\// =~ v2.to_s -%>
|
|
16
|
+
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" itemscope itemprop="<%=h k %>" itemid="<%=h v2.to_s %>"><%= format_object v2, param[:data], param[:type] %></dd>
|
|
11
17
|
<%- else -%>
|
|
12
|
-
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>"><%= format_object v2, param[:data], param[:type] %></dd>
|
|
18
|
+
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" itemprop="<%=h k %>"><%= format_object v2, param[:data], param[:type] %></dd>
|
|
13
19
|
<%- end -%>
|
|
14
20
|
<%- end -%>
|
|
15
21
|
<%- end -%>
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ttl2html
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Masao Takaku
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2025-
|
|
10
|
+
date: 2025-12-22 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: nokogiri
|