ttl2html 1.1.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d481c51d33a3f278444c1029dc50602c11d2b4d3e494e78884d4feabada2059
4
- data.tar.gz: c0402991e0ac87f10aa4afc09a89c53ab7aa1103cd4a6f8d7cd42601f3e7cec4
3
+ metadata.gz: 7291dd5276af9d25f9c91f5d798a1ad7614abe6d35ccf36aaa35beceb523d0ae
4
+ data.tar.gz: baca08577305a96a85b7c18015181a578dfbfc70344c73a599ebab582a591a69
5
5
  SHA512:
6
- metadata.gz: aecbba96f8160b240d653eca3d41e5e6370f39b5805e96d07cbaafae5345e411950de991d053db5a0fbf5bdee1293e474035991968af39f751361cb272013c48
7
- data.tar.gz: 0d9992e7381665ef9b137473c46ac3a381674cc6d899ef2a4a16a18853437381eb78362cacef3b59850f29db5820242563c972842eb34cc5f4f5942f3f668120
6
+ metadata.gz: fd0e4667b20caaa5444bf8c5013e8e2d9fabc944628201a340c33865f3ae747def16b4860a70eb11dad6da9b5db014bb2aeb48d8a00ef9a48ea0aa1b3bf6db84
7
+ data.tar.gz: 8e85d33dabd668ce182e0d10483ae95f46c44bb3a421d5153823ae6df6d0768d9ce00b8f0f010f219a8861aaa3f5349c20e1727ac3742383e22be518d2d3cebc
@@ -12,9 +12,10 @@ module TTL2HTML
12
12
  include I18n::Base
13
13
  def initialize(template, param = {})
14
14
  @template = template
15
- @param = param
15
+ @param = param.dup
16
16
  @template_path = [ Dir.pwd, File.join(Dir.pwd, "templates") ]
17
17
  @template_path << File.join(File.dirname(__FILE__), "..", "..", "templates")
18
+ I18n.load_path << Dir[File.join(File.dirname(__FILE__), "..", "..", "locales") + "/*.yml"]
18
19
  I18n.load_path << Dir[File.expand_path("locales") + "/*.yml"]
19
20
  I18n.locale = @param[:locale] if @param[:locale]
20
21
  end
@@ -112,6 +113,33 @@ module TTL2HTML
112
113
  end
113
114
 
114
115
  # helper method:
116
+ def uri_mapping_to_path(uri, suffix = ".html")
117
+ path = nil
118
+ if @param[:uri_mappings]
119
+ @param[:uri_mappings].each do |mapping|
120
+ local_file = uri.sub(@param[:base_uri], "")
121
+ if mapping["regexp"] =~ local_file
122
+ path = local_file.sub(mapping["regexp"], mapping["path"])
123
+ end
124
+ end
125
+ end
126
+ if path.nil?
127
+ if suffix == ".html"
128
+ if @param[:data_global] and @param[:data_global].keys.find{|e| e.start_with?(uri + "/") }
129
+ path = uri + "/index"
130
+ elsif uri.end_with?("/")
131
+ path = uri + "index"
132
+ else
133
+ path = uri
134
+ end
135
+ else
136
+ path = uri
137
+ end
138
+ end
139
+ path = path.sub(@param[:base_uri], "") if @param[:base_uri]
140
+ path << suffix
141
+ path
142
+ end
115
143
  def relative_path(dest)
116
144
  src = @param[:output_file]
117
145
  src = Pathname.new(src).relative_path_from(Pathname.new(@param[:output_dir])) if @param[:output_dir]
@@ -122,21 +150,29 @@ module TTL2HTML
122
150
  def relative_path_uri(dest_uri, base_uri)
123
151
  if dest_uri.start_with? base_uri
124
152
  dest = dest_uri.sub(base_uri, "")
153
+ dest = uri_mapping_to_path(dest, "")
125
154
  relative_path(dest)
126
155
  else
127
156
  dest_uri
128
157
  end
129
158
  end
159
+ def shorten_title(title, length = 140)
160
+ if title.length > length
161
+ title[0..length] + "..."
162
+ else
163
+ title
164
+ end
165
+ end
130
166
  def get_title(data, default_title = "no title")
131
167
  if @param[:title_property_perclass] and data["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
132
168
  @param[:title_property_perclass].each do |klass, property|
133
169
  if data["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].include?(klass) and data[property]
134
- return get_language_literal(data[property])
170
+ return shorten_title(get_language_literal(data[property]))
135
171
  end
136
172
  end
137
173
  end
138
174
  if @param[:title_property] and data[@param[:title_property]]
139
- return get_language_literal(data[@param[:title_property]])
175
+ return shorten_title(get_language_literal(data[@param[:title_property]]))
140
176
  end
141
177
  %w(
142
178
  http://www.w3.org/2000/01/rdf-schema#label
@@ -145,7 +181,7 @@ module TTL2HTML
145
181
  http://schema.org/name
146
182
  http://www.w3.org/2004/02/skos/core#prefLabel
147
183
  ).each do |property|
148
- return get_language_literal(data[property]) if data[property]
184
+ return shorten_title(get_language_literal(data[property])) if data[property]
149
185
  end
150
186
  default_title
151
187
  end
@@ -172,7 +208,7 @@ module TTL2HTML
172
208
  def format_object(object, data)
173
209
  if object =~ /\Ahttps?:\/\//
174
210
  rel_path = relative_path_uri(object, param[:base_uri])
175
- if data[object]
211
+ if param[:data_global][object]
176
212
  "<a href=\"#{rel_path}\">#{get_title(param[:data_global][object]) or object}</a>"
177
213
  else
178
214
  "<a href=\"#{rel_path}\">#{object}</a>"
@@ -183,8 +219,9 @@ module TTL2HTML
183
219
  object
184
220
  end
185
221
  end
186
- def format_triples(triples)
222
+ def format_triples(triples, type = :default)
187
223
  param_local = @param.dup.merge(data: triples)
224
+ param_local[:type] = type
188
225
  if @param[:labels_with_class] and triples["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
189
226
  @param[:labels_with_class].reverse_each do |k, v|
190
227
  triples["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].each do |entity_class|
@@ -197,7 +234,19 @@ module TTL2HTML
197
234
  end
198
235
  end
199
236
  end
237
+ if @param[:orders_with_class] and triples["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
238
+ @param[:orders_with_class].reverse_each do |k, v|
239
+ triples["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].each do |entity_class|
240
+ if entity_class == k
241
+ v.each do |property, order|
242
+ param_local[:orders] ||= {}
243
+ param_local[:orders][property] = order || Float::INFINITY
244
+ end
245
+ end
246
+ end
247
+ end
248
+ end
200
249
  to_html_raw("triples.html.erb", param_local)
201
250
  end
202
251
  end
203
- end
252
+ end
@@ -1 +1 @@
1
- TTL2HTML::VERSION = "1.1.0"
1
+ TTL2HTML::VERSION = "1.3.1"
data/lib/ttl2html.rb CHANGED
@@ -10,9 +10,7 @@ require "ttl2html/template"
10
10
 
11
11
  module TTL2HTML
12
12
  class App
13
- using ProgressBar::Refinements::Enumerator
14
13
  def initialize(config = "config.yml")
15
- @template = {}
16
14
  @config = load_config(config)
17
15
  if not @config[:base_uri]
18
16
  raise "load_config: base_uri not found"
@@ -68,50 +66,41 @@ module TTL2HTML
68
66
  def format_turtle(subject, depth = 1)
69
67
  turtle = RDF::Turtle::Writer.new
70
68
  result = ""
71
- if subject.iri?
72
- result << "<#{subject}>\n#{" "*depth}"
73
- else
69
+ if subject =~ /^_:/
74
70
  result << "[\n#{" "*depth}"
71
+ else
72
+ result << "<#{subject}>\n#{" "*depth}"
75
73
  end
76
- result << @graph.query([subject, nil, nil]).predicates.sort.map do |predicate|
74
+ result << @data[subject.to_s].keys.sort.map do |predicate|
77
75
  str = "<#{predicate}> "
78
- str << @graph.query([subject, predicate, nil]).objects.sort_by do |object|
79
- if object.resource? and not object.iri? # blank node:
80
- @graph.query([object, nil, nil]).statements.sort_by{|e|
81
- [ e.predicate, e.object ]
82
- }.map{|e|
83
- [ e.predicate, e.object ]
84
- }
85
- else
86
- object
87
- end
88
- end.map do |object|
89
- if object.resource? and not object.iri? # blank node:
76
+ str << @data[subject.to_s][predicate].sort.map do |object|
77
+ if object =~ /^_:/ # blank node:
90
78
  format_turtle(object, depth + 1)
79
+ elsif object =~ RDF::URI::IRI
80
+ turtle.format_uri(RDF::URI.new object)
81
+ elsif object.respond_to?(:first) and object.first.kind_of?(Symbol)
82
+ turtle.format_literal(RDF::Literal.new(object[1], language: object[0]))
91
83
  else
92
- case object
93
- when RDF::URI
94
- turtle.format_uri(object)
95
- else
96
- turtle.format_literal(object)
97
- end
84
+ turtle.format_literal(object)
98
85
  end
99
86
  end.join(", ")
100
87
  str
101
88
  end.join(";\n#{" "*depth}")
102
- result << " ." if subject.iri?
89
+ result << " ." if not subject =~ /^_:/
103
90
  result << "\n"
104
- result << "#{" "*(depth-1)}]" if not subject.iri?
91
+ result << "#{" "*(depth-1)}]" if subject =~ /^_:/
105
92
  result
106
93
  end
107
94
  def format_turtle_inverse(object)
108
- turtle = RDF::Turtle::Writer.new
109
95
  result = ""
110
- @graph.query([nil, nil, object]).statements.sort_by do |e|
111
- [ e.subject, e.predicate, object ]
112
- end.map do |e|
113
- next if e.subject.node?
114
- result << "<#{e.subject}> <#{e.predicate}> <#{object}>.\n"
96
+ return result if not object.start_with? @config[:base_uri]
97
+ return result if not @data_inverse.has_key? object
98
+ turtle = RDF::Turtle::Writer.new
99
+ @data_inverse[object].keys.sort.each do |predicate|
100
+ @data_inverse[object.to_s][predicate].sort.each do |subject|
101
+ next if subject =~ /^_:/
102
+ result << "<#{subject}> <#{predicate}> <#{object}>.\n"
103
+ end
115
104
  end
116
105
  result
117
106
  end
@@ -123,7 +112,7 @@ module TTL2HTML
123
112
  end
124
113
  end
125
114
  def output_html_files
126
- template = Template.new("")
115
+ template = Template.new("", @config)
127
116
  shapes = @graph.query([nil,
128
117
  RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
129
118
  RDF::URI("http://www.w3.org/ns/shacl#NodeShape")])
@@ -139,14 +128,23 @@ module TTL2HTML
139
128
  end
140
129
  end
141
130
  end
131
+ @config[:orders_with_class] = shapes2orders(shapes)
132
+ progressbar = ProgressBar.create(title: :output_html_files,
133
+ total: @data.size,
134
+ format: "(%t) %a %e %P% Processed: %c from %C")
142
135
  each_data do |uri, v|
136
+ progressbar.increment
143
137
  template = Template.new("default.html.erb", @config)
144
138
  param = @config.dup
145
139
  param[:uri] = uri
140
+ param[:turtle_uri] = uri_mapping_to_path(uri, ".ttl")
146
141
  param[:data] = v
147
142
  param[:data_inverse] = @data_inverse[uri]
148
143
  param[:data_global] = @data
149
144
  param[:title] = template.get_title(v)
145
+ if param[:breadcrumbs]
146
+ param[:breadcrumbs_items] = build_breadcrumbs(uri, template)
147
+ end
150
148
  file = uri_mapping_to_path(uri, ".html")
151
149
  if @config[:output_dir]
152
150
  Dir.mkdir @config[:output_dir] if not File.exist? @config[:output_dir]
@@ -154,6 +152,7 @@ module TTL2HTML
154
152
  end
155
153
  template.output_to(file, param)
156
154
  end
155
+ progressbar.finish
157
156
  index_html = "index.html"
158
157
  index_html = File.join(@config[:output_dir], "index.html") if @config[:output_dir]
159
158
  if @config.has_key? :top_class
@@ -182,16 +181,22 @@ module TTL2HTML
182
181
  param[:data_global] = @data
183
182
  param[:content] = {}
184
183
  shapes.subjects.each do |subject|
185
- label = nil
184
+ label = comment = nil
186
185
  target_class = @data[subject.to_s]["http://www.w3.org/ns/shacl#targetClass"]
187
186
  if target_class
188
- label = template.get_title(@data[target_class.first], nil) if @data[target_class.first]
189
- label = template.format_property(target_class.first) if label.nil?
187
+ target_class = target_class.first
188
+ if @data[target_class]
189
+ label = template.get_title(@data[target_class], nil)
190
+ comment = template.get_language_literal(@data[target_class]["http://www.w3.org/2000/01/rdf-schema#comment"]) if @data[target_class]["http://www.w3.org/2000/01/rdf-schema#comment"]
191
+ else
192
+ label = template.format_property(target_class)
193
+ end
190
194
  else
191
195
  label = template.get_title(@data[subject.to_s])
192
196
  end
193
197
  param[:content][subject] = {
194
198
  label: label,
199
+ comment: comment,
195
200
  html: template.expand_shape(@data, subject.to_s, @prefix),
196
201
  }
197
202
  end
@@ -199,6 +204,36 @@ module TTL2HTML
199
204
  end
200
205
  end
201
206
 
207
+ def build_breadcrumbs(uri, template, depth = 0)
208
+ results = []
209
+ data = @data[uri]
210
+ if @config[:breadcrumbs]
211
+ if depth == 0
212
+ first_label = template.get_title(data)
213
+ first_label = data[@config[:breadcrumbs].first["label"]].first if @config[:breadcrumbs].first["label"] and data[@config[:breadcrumbs].first["label"]]
214
+ results << { label: first_label }
215
+ end
216
+ @config[:breadcrumbs].each do |e|
217
+ data_target = data
218
+ data_target = @data_inverse[uri] if e["inverse"]
219
+ if data_target and data_target[e["property"]]
220
+ data_target[e["property"]].each do |parent|
221
+ data_parent = @data[parent]
222
+ label = template.get_title(data_parent)
223
+ label = data_parent[e["label"]].first if e["label"] and data_parent[e["label"]]
224
+ results << {
225
+ uri: parent,
226
+ label: label,
227
+ }
228
+ results += build_breadcrumbs(parent, template, depth + 1)
229
+ end
230
+ return results
231
+ end
232
+ end
233
+ end
234
+ results
235
+ end
236
+
202
237
  def shapes2labels(shapes)
203
238
  labels = {}
204
239
  shapes.subjects.each do |shape|
@@ -214,20 +249,40 @@ module TTL2HTML
214
249
  end
215
250
  labels
216
251
  end
252
+ def shapes2orders(shapes)
253
+ orders = {}
254
+ shapes.subjects.each do |shape|
255
+ target_class = @data[shape.to_s]["http://www.w3.org/ns/shacl#targetClass"]&.first
256
+ if target_class
257
+ @data[shape.to_s]["http://www.w3.org/ns/shacl#property"].each do |property|
258
+ path = @data[property]["http://www.w3.org/ns/shacl#path"].first
259
+ order = @data[property]["http://www.w3.org/ns/shacl#order"]
260
+ orders[target_class] ||= {}
261
+ orders[target_class][path] = order&.first&.to_i
262
+ end
263
+ end
264
+ end
265
+ orders
266
+ end
217
267
 
218
268
  def output_turtle_files
269
+ progressbar = ProgressBar.create(title: :output_turtle_files,
270
+ total: @data.size,
271
+ format: "(%t) %a %e %P% Processed: %c from %C")
219
272
  each_data do |uri, v|
273
+ progressbar.increment
220
274
  file = uri_mapping_to_path(uri, ".ttl")
221
275
  if @config[:output_dir]
222
276
  Dir.mkdir @config[:output_dir] if not File.exist? @config[:output_dir]
223
277
  file = File.join(@config[:output_dir], file)
224
278
  end
225
- str = format_turtle(RDF::URI.new uri)
226
- str << format_turtle_inverse(RDF::URI.new uri)
279
+ str = format_turtle(uri)
280
+ str << format_turtle_inverse(uri)
227
281
  open(file, "w") do |io|
228
282
  io.puts str.strip
229
283
  end
230
284
  end
285
+ progressbar.finish
231
286
  end
232
287
  def uri_mapping_to_path(uri, suffix = ".html")
233
288
  path = nil
@@ -293,4 +348,4 @@ module TTL2HTML
293
348
  file
294
349
  end
295
350
  end
296
- end
351
+ end
data/locales/en.yml CHANGED
@@ -23,4 +23,6 @@ en:
23
23
  optional: "Optional"
24
24
  non-repeatable: "Non repeatable"
25
25
  blank-node-structure: "The structural contents of a blank node are as follows:"
26
- blank-node-or-structure: "The structural contents of a blank node are either of the followings:"
26
+ blank-node-or-structure: "The structural contents of a blank node are either of the followings:"
27
+ triples:
28
+ inverse_refered: "Referred to as '%{property}' from:"
data/locales/ja.yml CHANGED
@@ -22,4 +22,6 @@ ja:
22
22
  optional: 省略可能
23
23
  non-repeatable: 繰り返し無し
24
24
  blank-node-structure: ブランクノードの内容は以下の内容からなる構造を持ちます。
25
- blank-node-or-structure: ブランクノードの内容は以下のいずれかの内容からなる構造を持ちます。
25
+ blank-node-or-structure: ブランクノードの内容は以下のいずれかの内容からなる構造を持ちます。
26
+ triples:
27
+ inverse_refered: "'%{property}'としての参照元:"
@@ -6,15 +6,15 @@
6
6
  <div class="container">
7
7
  <div class="row">
8
8
  <div class="col-md-12">
9
- <ol class="breadcrumb">
10
- <li><a href="./"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> Home</a></li>
11
- <li class="active"><%=h t("about.title", title: param[:site_title]) %></li>
9
+ <nav aria-label="breadcrumb">
10
+ <ol class="breadcrumb">
11
+ <li class="breadcrumb-item"><a href="./"><i class="bi bi-house-door-fill"></i> Home</a></li>
12
+ <li class="breadcrumb-item active" aria-current="page"><%=h t("about.title", title: param[:site_title]) %></li>
12
13
  </ol>
13
- </div>
14
+ </nav>
14
15
  </div>
15
-
16
16
  <div class="row">
17
- <div class="col-md-10">
17
+ <div class="col-md">
18
18
  <%- param[:content].keys.sort.each do |shape| -%>
19
19
  <h3><%=h param[:content][shape][:label] %></h3>
20
20
  <p><%= param[:content][shape][:comment] %></p>
@@ -23,3 +23,5 @@
23
23
  <%- end -%>
24
24
  </div>
25
25
  </div>
26
+ </div>
27
+
@@ -1,22 +1,42 @@
1
1
  <div class="jumbotron">
2
2
  <div class="container">
3
3
  <h1><%=h param[:title] %></h1>
4
- <p><small><span class="glyphicon glyphicon-link"></span> <a href="<%=h param[:uri] %>"><%=h param[:uri] %></a></small></p>
4
+ <p><i class="bi bi-link-45deg"></i> <a href="<%=h param[:uri] %>"><%=h param[:uri] %></a></p>
5
5
  </div>
6
6
  </div>
7
7
  <div class="container">
8
+ <%- if param[:breadcrumbs] -%>
9
+ <div class="row">
10
+ <div class="col-md-12">
11
+ <nav aria-label="breadcrumb">
12
+ <ol class="breadcrumb">
13
+ <li class="breadcrumb-item"><a href="./"><i class="bi bi-house-door-fill"></i> Home</a></li>
14
+ <%- param[:breadcrumbs_items].reverse.each_with_index do |e, i| -%>
15
+ <li class="breadcrumb-item<%= ' active' if i == param[:breadcrumbs_items].size-1 %>" aria-current="page">
16
+ <%- if e[:uri] -%>
17
+ <a href="<%=h e[:uri] %>"><%=h e[:label] %></a>
18
+ <%- else -%>
19
+ <%=h e[:label] %>
20
+ <%- end -%>
21
+ </li>
22
+ <%- end -%>
23
+ </ol>
24
+ </nav>
25
+ </div>
26
+ </div>
27
+ <%- end -%>
8
28
  <div class="row">
9
29
  <div class="col-md-12">
10
30
  <h2><%=h t("default.details") %></h2>
11
31
  <%= format_triples(param[:data]) %>
12
32
  </div>
13
33
  </div>
14
- <% if param[:data_inverse] %>
34
+ <%- if param[:data_inverse] -%>
15
35
  <div class="row inverse">
16
36
  <div class="col-md-12">
17
37
  <h2><%=h t("default.inverse_data") %></h2>
18
- <%= format_triples(param[:data_inverse]) %>
38
+ <%= format_triples(param[:data_inverse], :inverse) %>
19
39
  </div>
20
40
  </div>
21
- <% end %>
22
- </div>
41
+ <%- end -%>
42
+ </div>
@@ -1,7 +1,7 @@
1
1
  <div class="jumbotron">
2
2
  <div class="container">
3
3
  <h1><%=h param[:site_title] %></h1>
4
- <p><small><span class="glyphicon glyphicon-link"></span> <a href="<%=h param[:base_uri] %>"><%=h param[:base_uri] %></a></small></p>
4
+ <p><i class="bi bi-link-45deg"></i> <a href="<%=h param[:base_uri] %>"><%=h param[:base_uri] %></a></p>
5
5
  </div>
6
6
  </div>
7
7
  <div class="container">
@@ -4,17 +4,25 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
6
  <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
7
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
7
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
8
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.1/font/bootstrap-icons.css">
8
9
  <title><% if param[:title] %><%=h param[:title] %><% end %><% if param[:site_title] %> - <%=h param[:site_title] %><% end %></title>
9
10
  <meta name="twitter:card" content="summary">
10
11
  <meta name="twitter:title" content="<% if param[:title] %><%=h param[:title] %><% end %><% if param[:site_title] %> - <%=h param[:site_title] %><% end %>">
11
12
  </head>
12
13
  <body>
13
- <nav class="navbar navbar-inverse">
14
- <div class="container">
15
- <ul class="nav navbar-nav navbar-right">
16
- <li<%= ' class="active"' if param[:active] == :home %>><a class="navbar-brand" href="/">Home</a></li>
17
- <li<%= ' class="active"' if param[:active] == :about %>><a href="/about">About</a></li>
14
+ <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
15
+ <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
16
+ <span class="navbar-toggler-icon"></span>
17
+ </button>
18
+ <div class="collapse navbar-collapse" id="navbarSupportedContent">
19
+ <ul class="navbar-nav mr-auto">
20
+ <li class="nav-item<%= ' class="active"' if param[:active] == :home %>">
21
+ <a class="navbar-brand" href="/">Home</a>
22
+ </li>
23
+ <li class="nav-item<%= ' class="active"' if param[:active] == :about %>">
24
+ <a class="navbar-brand" href="/about">About</a>
25
+ </li>
18
26
  </ul>
19
27
  </div>
20
28
  </nav>
@@ -22,13 +30,13 @@
22
30
  <hr>
23
31
  <footer>
24
32
  <%- if param[:uri] -%>
25
- <p class="pull-right"><a href="<%=h param[:uri] %>.ttl"><img src="https://www.w3.org/RDF/icons/rdf_flyer.24" alt="<%=h t("layout.rdf_data") %>"></a></p>
33
+ <p class="text-right"><a href="<%=h relative_path(param[:turtle_uri]) %>"><img src="https://www.w3.org/RDF/icons/rdf_flyer.24" alt="<%=h t("layout.rdf-data") %>"></a></p>
26
34
  <%- end -%>
27
35
  </footer>
28
36
 
29
37
  <!-- jQuery first, then Popper.js, then Bootstrap JS -->
30
- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
31
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
32
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
38
+ <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
39
+ <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
40
+ <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
33
41
  </body>
34
42
  </html>
@@ -1,16 +1,24 @@
1
- <dl>
2
- <% param[:data].each do |k, v| %>
3
- <dt><%=h format_property(k, param[:labels]) %></dt>
4
- <% if v.respond_to? :has_key? %>
5
- <% v.each do |lang, v2| %>
6
- <dd lang="<%=h lang %>"><%= format_object v2, param[:data] %></dd>
1
+ <dl class="row">
2
+ <%- param[:data].sort_by{|k, v|
3
+ order = param[:orders][k] if param[:orders] and param[:orders][k]
4
+ order = Float::INFINITY if order.nil?
5
+ [ order, k ]
6
+ }.each do |k, v| -%>
7
+ <%- if param[:type] == :inverse -%>
8
+ <dt class="col-sm-3"><%=h t('triples.inverse_refered', property: format_property(k, param[:labels])) %></dt>
9
+ <%- else -%>
10
+ <dt class="col-sm-3"><%=h format_property(k, param[:labels]) %></dt>
11
+ <%- end -%>
12
+ <%- if v.respond_to? :has_key? -%>
13
+ <% v.each_with_index do |v2, idx| %>
14
+ <dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" lang="<%=h v2[0] %>"><%= format_object v2[1], param[:data] %></dd>
7
15
  <% end %>
8
- <% elsif v.size > 1 %>
9
- <% v.each do |v2| %>
10
- <dd><%= format_object v2, param[:data] %></dd>
11
- <% end %>
12
- <% else %>
13
- <dd><%= format_object v.first, param[:data] %></dd>
14
- <% end %>
16
+ <%- elsif v.size > 1 -%>
17
+ <%- v.each_with_index do |v2, idx| -%>
18
+ <dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>"><%= format_object v2, param[:data] %></dd>
19
+ <%- end -%>
20
+ <%- else -%>
21
+ <dd class="col-sm-9"><%= format_object v.first, param[:data] %></dd>
22
+ <%- end -%>
15
23
  <%- end -%>
16
- </dl>
24
+ </dl>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ttl2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masao Takaku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-21 00:00:00.000000000 Z
11
+ date: 2021-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri