ttl2html 2.2.0 → 2.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 221f8ca33a9e3988ed12acf79e6c028a04e67e7733916611d2795e2c34a64056
4
- data.tar.gz: 5ac1d7e52e7e65c016ed285d640d5bb03890cfc52048ce91801b949480a34252
3
+ metadata.gz: 13f4951cbe8d12cf99dd6563a2facae07c180d8e48bbab595f3cce942cf1da0f
4
+ data.tar.gz: 8232fb9eb944019274b5323cf44739ee147b032b60358d8e894a8daa36ab551f
5
5
  SHA512:
6
- metadata.gz: bf90d497ed178964e0f950f5c91902061347417e2e911ed965d4d61af00c11d5835d7d0360364c0874c1e70412e9e11a3069ef8dfcf7e5aadffd33bb5301dffe
7
- data.tar.gz: 5ed644ef6b70846d6a355b7405df15950b5061d28085ab341794edeb3f188393525849c732449dfcec70e866c49a9562d32561f38435fed396358a269be98a7c
6
+ metadata.gz: c31c198f569f638e9ab5007f9776cb979144464b6be6e3f21601b07a098559af1b50d97e7eed1e77958c7240eefd3ae49e422bf7f54738a6f957ee868d9f2fd1
7
+ data.tar.gz: 8ad682b50a9cd60843d52a503fa7ffbd2a4359553d254c0c7721587d1d371c36cc533da5188c9135b411ec5f0c9c5c12aa2cc23d9bf65b0448e626a264891508
@@ -320,5 +320,31 @@ module TTL2HTML
320
320
  def valid_value?(value)
321
321
  value && !(value.respond_to?(:empty?) && value.empty?)
322
322
  end
323
+ def sort_criteria(val, data_global)
324
+ resource = data_global[val]
325
+ results = []
326
+ [
327
+ "http://purl.org/linked-data/cube#order",
328
+ "http://schema.org/position",
329
+ ].each do |order_elem|
330
+ if resource and resource[order_elem]
331
+ order_val = resource[order_elem].first.to_s
332
+ if data_global[order_val] and data_global[order_val][RDF::RDFV::value.to_s]
333
+ results << data_global[order_val][RDF::RDFV::value.to_s].first.to_i
334
+ else
335
+ results << order_val.to_i
336
+ end
337
+ else
338
+ results << Float::INFINITY
339
+ end
340
+ end
341
+ if val.to_s =~ /^_:/
342
+ results << resource.to_s
343
+ else
344
+ results << val.to_s
345
+ end
346
+ #p [val, results]
347
+ results
348
+ end
323
349
  end
324
350
  end
@@ -1 +1 @@
1
- TTL2HTML::VERSION = "2.2.0"
1
+ TTL2HTML::VERSION = "2.2.2"
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] = [ config[k] ].flatten
37
+ config[k] = Array(config[k]).flatten
38
38
  end
39
39
  end
40
40
  config
@@ -83,10 +83,13 @@ module TTL2HTML
83
83
  result << @data[subject.to_s].keys.sort.map do |predicate|
84
84
  str = "<#{predicate}> "
85
85
  str << @data[subject.to_s][predicate].sort_by do |object|
86
- if /^_:/ =~ object.to_s and @data[object.to_s]
86
+ #p [subject, predicate, object, depth]
87
+ if object.to_s =~ /^_:/ and @data[object.to_s]
87
88
  qb_order = "http://purl.org/linked-data/cube#order"
89
+ schema_position = "http://schema.org/position"
88
90
  shacl_order = "http://www.w3.org/ns/shacl#order"
89
- [ @data[object.to_s][qb_order] ? @data[object.to_s][qb_order].first.to_i : Float::INFINITY,
91
+ [ @data[object.to_s][schema_position] ? @data[object.to_s][schema_position].first.to_i : Float::INFINITY,
92
+ @data[object.to_s][qb_order] ? @data[object.to_s][qb_order].first.to_i : Float::INFINITY,
90
93
  @data[object.to_s][shacl_order] ? @data[object.to_s][shacl_order].first.to_i : Float::INFINITY,
91
94
  format_turtle(object, depth + 1)
92
95
  ]
@@ -149,6 +152,8 @@ module TTL2HTML
149
152
  labels = shapes2labels(shapes)
150
153
  versions = extract_versions
151
154
  toplevel = extract_toplevel
155
+ about_required = template.find_template_path("about.html") || !shapes.empty? || !versions.empty? || !toplevel.empty?
156
+ about_file = (@config[:about_file] || "about.html") if about_required
152
157
  @config[:labels_with_class] ||= {}
153
158
  labels.each do |klass, props|
154
159
  props.each do |property, label|
@@ -185,6 +190,7 @@ module TTL2HTML
185
190
  if template.find_template_path("_default.html.erb")
186
191
  param[:additional_content] = template.to_html_raw("_default.html.erb", param)
187
192
  end
193
+ param[:about_file] = about_file if about_required
188
194
  template.output_to(file, param)
189
195
  end
190
196
  index_html = "index.html"
@@ -223,14 +229,16 @@ module TTL2HTML
223
229
  end
224
230
  param[:output_file] = index_html
225
231
  param[:index_list] = template.to_html_raw("index-list.html.erb", param)
232
+ param[:about_file] = about_file if about_required
226
233
  template.output_to(index_html, param)
227
234
  end
228
235
  end
229
- if template.find_template_path("about.html") or shapes.size > 0 or versions.size > 0 or toplevel.size > 0
230
- about_html = @config[:about_file] || "about.html"
236
+ if about_required
237
+ about_html = about_file
231
238
  about_html = File.join(@config[:output_dir], about_html) if @config[:output_dir]
232
239
  template = Template.new("about.html.erb", @config)
233
240
  param = @config.dup
241
+ param[:about_file] = about_file
234
242
  param[:content] = template.to_html_raw("about.html", {}) if template.find_template_path("about.html")
235
243
  param[:data_global] = @data
236
244
  param[:versions] = versions
@@ -499,7 +507,7 @@ module TTL2HTML
499
507
  end
500
508
  dir = File.dirname(file)
501
509
  FileUtils.mkdir_p(dir) if not File.exist?(dir)
502
- str = format_turtle(uri)
510
+ str = format_turtle(uri)
503
511
  str << format_turtle_inverse(uri)
504
512
  open(file, "w") do |io|
505
513
  io.puts str.strip
@@ -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
- <p><a class="btn btn-info" href="<%=h relative_path(param[:about_file] || "about.html") %>"><%=h t("about.title", title: param[:site_title]) %> &raquo;</a></p>
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]) %> &raquo;</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="about#versions">&raquo; <%=h t("index.past-versions") %></a></p>
25
+ <%- if param[:about_file] and param[:versions].size > 1 -%>
26
+ <p><a href="<%=h relative_path(param[:about_file]) %>#versions">&raquo; <%=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">
@@ -8,9 +8,9 @@
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 if param[:css_file] -%>
13
+ <%- end -%>
14
14
  <%- if param[:custom_css] -%>
15
15
  <style type="text/css"><%=h param[:custom_css] %></style>
16
16
  <%- end -%>
@@ -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] || "about.html") %>">About</a>
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 if param[:javascript_file] -%>
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>
@@ -5,13 +5,7 @@
5
5
  [ order, k ]
6
6
  }.each do |k, v| -%>
7
7
  <dt class="col-sm-3"><%=h format_property(k, param[:labels]) %></dt>
8
- <%- v.sort_by{|e|
9
- if /\A_:/ =~ e.to_s and param[:data_global][e]
10
- param[:data_global][e].to_s
11
- else
12
- e
13
- end
14
- }.each_with_index do |v2, idx| -%>
8
+ <%- v.sort_by{|e| sort_criteria(e, param[:data_global]) }.each_with_index do |v2, idx| -%>
15
9
  <%- if v2.respond_to? :language and v2.language? -%>
16
10
  <dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" lang="<%=h v2.language %>"><%= format_object v2, param[:data], param[:type] %></dd>
17
11
  <%- else -%>
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.2.0
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masao Takaku
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-07 00:00:00.000000000 Z
10
+ date: 2025-09-11 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: nokogiri