ttl2html 1.3.4 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ttl2html +1 -2
- data/lib/ttl2html/template.rb +51 -40
- data/lib/ttl2html/util.rb +32 -0
- data/lib/ttl2html/version.rb +1 -1
- data/lib/ttl2html.rb +154 -87
- data/locales/en.yml +5 -1
- data/locales/ja.yml +5 -0
- data/templates/about.html.erb +14 -3
- data/templates/default.html.erb +6 -3
- data/templates/index-list.html.erb +20 -0
- data/templates/index.html.erb +3 -11
- data/templates/layout.html.erb +34 -8
- data/templates/shape-table.html.erb +15 -3
- data/templates/triples-blank.html.erb +4 -0
- data/templates/triples-inverse.html.erb +20 -0
- data/templates/triples.html.erb +5 -9
- data/templates/version.html.erb +6 -2
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 858625044e6a0e9ff78bacc944b6aebb8dc4fb95f07cda76d3eab790d0602163
|
4
|
+
data.tar.gz: 0d514bacd1ddd635dfa36ca7aca8e74b2a5ff78e15b16e21a2124eaa04660e40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9958babbf93cd931926e4f56cc348fe16130f908a324d1978cd2d2f35c9ebca2646c4b86fa9ef97365377cb4ca23e7365f460e024207a3ccef8439fb545cde92
|
7
|
+
data.tar.gz: ceb241313491e6b67c633aa235c9bc74c5e2bf76fc6b4bc1479c9874e9aed07995f0655da48e2e29e36a4a22dc5efa14476e4394fce5b7465a3a3ef759f9990b
|
data/bin/ttl2html
CHANGED
data/lib/ttl2html/template.rb
CHANGED
@@ -15,7 +15,7 @@ module TTL2HTML
|
|
15
15
|
def initialize(template, param = {})
|
16
16
|
@template = template
|
17
17
|
@param = param.dup
|
18
|
-
@template_path = [
|
18
|
+
@template_path = [ File.join(Dir.pwd, "templates") ]
|
19
19
|
@template_path << File.join(File.dirname(__FILE__), "..", "..", "templates")
|
20
20
|
I18n.load_path << Dir[File.join(File.dirname(__FILE__), "..", "..", "locales") + "/*.yml"]
|
21
21
|
I18n.load_path << Dir[File.expand_path("locales") + "/*.yml"]
|
@@ -59,6 +59,7 @@ module TTL2HTML
|
|
59
59
|
def expand_shape(data, uri, prefixes = {})
|
60
60
|
return nil if not data[uri]
|
61
61
|
return nil if not data[uri]["http://www.w3.org/ns/shacl#property"]
|
62
|
+
prefix_used = {}
|
62
63
|
result = data[uri]["http://www.w3.org/ns/shacl#property"].sort_by do |e|
|
63
64
|
e["http://www.w3.org/ns/shacl#order"]
|
64
65
|
end.map do |property|
|
@@ -67,6 +68,7 @@ module TTL2HTML
|
|
67
68
|
prefixes.each do |prefix, val|
|
68
69
|
if path.index(val) == 0
|
69
70
|
shorten_path = path.sub(/\A#{val}/, "#{prefix}:")
|
71
|
+
prefix_used[prefix] = val
|
70
72
|
end
|
71
73
|
end
|
72
74
|
repeatable = false
|
@@ -107,52 +109,33 @@ module TTL2HTML
|
|
107
109
|
nodeKind: data[property]["http://www.w3.org/ns/shacl#nodeKind"] ? data[property]["http://www.w3.org/ns/shacl#nodeKind"].first : nil,
|
108
110
|
nodes: nodes,
|
109
111
|
node_mode: node_mode,
|
112
|
+
prefix: prefix_used,
|
110
113
|
}
|
111
114
|
end
|
112
115
|
template = "shape-table.html.erb"
|
113
116
|
tmpl = Template.new(template)
|
114
|
-
tmpl.to_html_raw(template, {properties: result})
|
117
|
+
tmpl.to_html_raw(template, { properties: result, prefix: prefix_used })
|
115
118
|
end
|
116
119
|
|
117
120
|
# helper method:
|
118
|
-
|
121
|
+
include TTL2HTML::Util
|
122
|
+
def relative_path(dest)
|
119
123
|
path = nil
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
if path.nil?
|
129
|
-
if suffix == ".html"
|
130
|
-
if @param[:data_global] and @param[:data_global].keys.find{|e| e.start_with?(uri + "/") }
|
131
|
-
path = uri + "/index"
|
132
|
-
elsif uri.end_with?("/")
|
133
|
-
path = uri + "index"
|
134
|
-
else
|
135
|
-
path = uri
|
136
|
-
end
|
137
|
-
else
|
138
|
-
path = uri
|
139
|
-
end
|
124
|
+
dest_uri = RDF::IRI.parse(dest)
|
125
|
+
if dest_uri.absolute?
|
126
|
+
path = dest
|
127
|
+
else
|
128
|
+
src = @param[:output_file]
|
129
|
+
src = Pathname.new(src).relative_path_from(Pathname.new(@param[:output_dir])) if @param[:output_dir]
|
130
|
+
path = Pathname(dest).relative_path_from(Pathname(File.dirname src))
|
131
|
+
path = path.to_s + "/" if File.directory? path
|
140
132
|
end
|
141
|
-
path = path.sub(@param[:base_uri], "") if @param[:base_uri]
|
142
|
-
path << suffix
|
143
133
|
path
|
144
134
|
end
|
145
|
-
def
|
146
|
-
src = @param[:output_file]
|
147
|
-
src = Pathname.new(src).relative_path_from(Pathname.new(@param[:output_dir])) if @param[:output_dir]
|
148
|
-
path = Pathname(dest).relative_path_from(Pathname(File.dirname src))
|
149
|
-
path = path.to_s + "/" if File.directory? path
|
150
|
-
path
|
151
|
-
end
|
152
|
-
def relative_path_uri(dest_uri, base_uri)
|
135
|
+
def relative_path_uri(dest_uri, base_uri = @param[:base_uri])
|
153
136
|
if dest_uri.start_with? base_uri
|
154
137
|
dest = dest_uri.sub(base_uri, "")
|
155
|
-
dest = uri_mapping_to_path(dest, "")
|
138
|
+
dest = uri_mapping_to_path(dest, @param, "")
|
156
139
|
relative_path(dest)
|
157
140
|
else
|
158
141
|
dest_uri
|
@@ -176,6 +159,7 @@ module TTL2HTML
|
|
176
159
|
end
|
177
160
|
end
|
178
161
|
def get_title(data, default_title = "no title")
|
162
|
+
return default_title if data.nil?
|
179
163
|
if @param[:title_property_perclass] and data["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
|
180
164
|
@param[:title_property_perclass].each do |klass, property|
|
181
165
|
if data["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].include?(klass) and data[property]
|
@@ -210,14 +194,18 @@ module TTL2HTML
|
|
210
194
|
object
|
211
195
|
end
|
212
196
|
end
|
213
|
-
def format_property(property, labels = {})
|
214
|
-
if
|
197
|
+
def format_property(property, labels = {}, subject = nil)
|
198
|
+
subject = @param[:blank_subject] if not subject and @param[:blank_subject]
|
199
|
+
subject_class = @param[:data_global][subject][RDF.type.to_s]&.first if subject
|
200
|
+
if subject_class and @param[:labels_with_class][subject_class] and @param[:labels_with_class][subject_class][property]
|
201
|
+
@param[:labels_with_class][subject_class][property]
|
202
|
+
elsif labels and labels[property]
|
215
203
|
labels[property]
|
216
204
|
else
|
217
205
|
property.split(/[\/\#]/).last.capitalize
|
218
206
|
end
|
219
207
|
end
|
220
|
-
def format_object(object, data)
|
208
|
+
def format_object(object, data, type = {})
|
221
209
|
if object =~ /\Ahttps?:\/\//
|
222
210
|
rel_path = relative_path_uri(object, param[:base_uri])
|
223
211
|
if param[:data_global][object]
|
@@ -226,12 +214,16 @@ module TTL2HTML
|
|
226
214
|
"<a href=\"#{rel_path}\">#{object}</a>"
|
227
215
|
end
|
228
216
|
elsif object =~ /\A_:/ and param[:data_global][object]
|
229
|
-
|
217
|
+
if type[:inverse] and param[:data_inverse_global][object]
|
218
|
+
format_triples(param[:data_inverse_global][object], inverse: true, blank: true)
|
219
|
+
else
|
220
|
+
format_triples(param[:data_global][object], blank: true)
|
221
|
+
end
|
230
222
|
else
|
231
223
|
object
|
232
224
|
end
|
233
225
|
end
|
234
|
-
def format_triples(triples, type =
|
226
|
+
def format_triples(triples, type = {})
|
235
227
|
param_local = @param.dup.merge(data: triples)
|
236
228
|
param_local[:type] = type
|
237
229
|
if @param[:labels_with_class] and triples["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
|
@@ -258,7 +250,26 @@ module TTL2HTML
|
|
258
250
|
end
|
259
251
|
end
|
260
252
|
end
|
261
|
-
|
253
|
+
if type[:inverse] == true
|
254
|
+
if type[:blank] == true
|
255
|
+
#p param_local[:data]
|
256
|
+
#p param_local[:data_inverse]
|
257
|
+
#p param_local[:data_inverse].values.first.first
|
258
|
+
param_local[:blank_subject] = param_local[:data].values.first.first
|
259
|
+
param_local[:blank_triples] = {
|
260
|
+
param_local[:data].keys.first => param_local[:data_global][param_local[:blank_subject]][param_local[:data].keys.first]
|
261
|
+
}
|
262
|
+
#p param_local[:blank_subject]
|
263
|
+
#p param_local[:blank_triples]
|
264
|
+
param_local[:type] = {}
|
265
|
+
#pp param_local
|
266
|
+
to_html_raw("triples-blank.html.erb", param_local)
|
267
|
+
else
|
268
|
+
to_html_raw("triples-inverse.html.erb", param_local)
|
269
|
+
end
|
270
|
+
else
|
271
|
+
to_html_raw("triples.html.erb", param_local)
|
272
|
+
end
|
262
273
|
end
|
263
274
|
def format_version_info(version)
|
264
275
|
param_local = @param.dup.merge(data: version)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module TTL2HTML
|
2
|
+
module Util
|
3
|
+
def uri_mapping_to_path(uri, param, suffix = ".html")
|
4
|
+
path = nil
|
5
|
+
if param[:uri_mappings]
|
6
|
+
param[:uri_mappings].each do |mapping|
|
7
|
+
local_file = uri.sub(param[:base_uri], "")
|
8
|
+
if mapping["regexp"] =~ local_file
|
9
|
+
path = local_file.sub(mapping["regexp"], mapping["path"])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
if path.nil?
|
14
|
+
if suffix == ".html"
|
15
|
+
if @data.keys.find{|e| e.start_with?(uri + "/") }
|
16
|
+
path = uri + "/index"
|
17
|
+
elsif uri.end_with?("/")
|
18
|
+
path = uri + "index"
|
19
|
+
else
|
20
|
+
path = uri
|
21
|
+
end
|
22
|
+
else
|
23
|
+
path = uri
|
24
|
+
end
|
25
|
+
end
|
26
|
+
path = path.sub(param[:base_uri], "")
|
27
|
+
path << suffix
|
28
|
+
#p [uri, path]
|
29
|
+
path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/ttl2html/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
TTL2HTML::VERSION = "
|
1
|
+
TTL2HTML::VERSION = "2.0.1"
|
data/lib/ttl2html.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "zlib"
|
4
|
+
require "uri"
|
4
5
|
require "yaml"
|
5
6
|
require "nokogiri"
|
6
7
|
require "rdf/turtle"
|
7
8
|
require "ruby-progressbar"
|
8
9
|
|
10
|
+
require "ttl2html/util"
|
9
11
|
require "ttl2html/template"
|
10
12
|
|
11
13
|
module TTL2HTML
|
12
14
|
class App
|
15
|
+
include Util
|
13
16
|
def initialize(config = "config.yml")
|
14
17
|
@config = load_config(config)
|
15
18
|
if not @config[:base_uri]
|
@@ -18,11 +21,10 @@ module TTL2HTML
|
|
18
21
|
@data = {}
|
19
22
|
@data_inverse = {}
|
20
23
|
@prefix = {}
|
21
|
-
@graph = RDF::Graph.new
|
22
24
|
end
|
23
25
|
|
24
26
|
def load_config(file)
|
25
|
-
config = {}
|
27
|
+
config = { output_turtle: true }
|
26
28
|
open(file) do |io|
|
27
29
|
YAML.safe_load(io, permitted_classes: [Regexp]).each do |k, v|
|
28
30
|
config[k.intern] = v
|
@@ -39,10 +41,8 @@ module TTL2HTML
|
|
39
41
|
else
|
40
42
|
io = File.open(file)
|
41
43
|
end
|
42
|
-
RDF::
|
43
|
-
@prefix.merge! reader.prefixes
|
44
|
+
RDF::Format.for(:turtle).reader.new(io) do |reader|
|
44
45
|
reader.statements.each do |statement|
|
45
|
-
@graph.insert(statement)
|
46
46
|
s = statement.subject
|
47
47
|
v = statement.predicate
|
48
48
|
o = statement.object
|
@@ -55,12 +55,13 @@ module TTL2HTML
|
|
55
55
|
@data[s.to_s][v.to_s] ||= []
|
56
56
|
@data[s.to_s][v.to_s] << o.to_s
|
57
57
|
end
|
58
|
-
if o.is_a? RDF::URI
|
58
|
+
if o.is_a? RDF::URI or o.is_a? RDF::Node
|
59
59
|
@data_inverse[o.to_s] ||= {}
|
60
60
|
@data_inverse[o.to_s][v.to_s] ||= []
|
61
61
|
@data_inverse[o.to_s][v.to_s] << s.to_s
|
62
62
|
end
|
63
63
|
end
|
64
|
+
@prefix.merge! reader.prefixes
|
64
65
|
end
|
65
66
|
STDERR.puts "#{count} triples. #{@data.size} subjects."
|
66
67
|
@data
|
@@ -120,9 +121,12 @@ module TTL2HTML
|
|
120
121
|
end
|
121
122
|
def output_html_files
|
122
123
|
template = Template.new("", @config)
|
123
|
-
shapes =
|
124
|
-
|
125
|
-
|
124
|
+
shapes = []
|
125
|
+
@data.each do |s, v|
|
126
|
+
if v[RDF.type.to_s] and @data[s][RDF.type.to_s].include?("http://www.w3.org/ns/shacl#NodeShape")
|
127
|
+
shapes << s
|
128
|
+
end
|
129
|
+
end
|
126
130
|
labels = shapes2labels(shapes)
|
127
131
|
versions = extract_versions
|
128
132
|
toplevel = extract_toplevel
|
@@ -142,53 +146,80 @@ module TTL2HTML
|
|
142
146
|
template = Template.new("default.html.erb", @config)
|
143
147
|
param = @config.dup
|
144
148
|
param[:uri] = uri
|
145
|
-
param[:turtle_uri] =
|
149
|
+
param[:turtle_uri] = uri + ".ttl"
|
146
150
|
param[:data] = v
|
147
151
|
param[:data_inverse] = @data_inverse[uri]
|
152
|
+
param[:data_inverse_global] = @data_inverse
|
148
153
|
param[:data_global] = @data
|
149
154
|
param[:title] = template.get_title(v)
|
150
155
|
if param[:breadcrumbs]
|
151
156
|
param[:breadcrumbs_items] = build_breadcrumbs(uri, template)
|
152
157
|
end
|
153
|
-
file = uri_mapping_to_path(uri, ".html")
|
158
|
+
file = uri_mapping_to_path(uri, @config, ".html")
|
154
159
|
if @config[:output_dir]
|
155
160
|
Dir.mkdir @config[:output_dir] if not File.exist? @config[:output_dir]
|
156
161
|
file = File.join(@config[:output_dir], file)
|
157
162
|
end
|
163
|
+
if template.find_template_path("_default.html.erb")
|
164
|
+
param[:additional_content] = template.to_html_raw("_default.html.erb", param)
|
165
|
+
end
|
158
166
|
template.output_to(file, param)
|
159
167
|
end
|
160
168
|
index_html = "index.html"
|
161
169
|
index_html = File.join(@config[:output_dir], "index.html") if @config[:output_dir]
|
162
170
|
if @config.has_key? :top_class
|
163
|
-
subjects =
|
164
|
-
|
165
|
-
|
171
|
+
subjects = []
|
172
|
+
@data.each do |s, v|
|
173
|
+
if @data[s][RDF.type.to_s] and @data[s][RDF.type.to_s].include?(@config[:top_class])
|
174
|
+
subjects << s
|
175
|
+
end
|
176
|
+
end
|
166
177
|
if subjects.empty?
|
167
178
|
STDERR.puts "WARN: top_class parameter specified as [#{@config[:top_class]}], but there is no instance data."
|
168
|
-
STDERR.puts " Skip generation of top page."
|
169
179
|
else
|
170
180
|
template = Template.new("index.html.erb", @config)
|
171
181
|
param = @config.dup
|
182
|
+
param[:class_label] = template.get_title(@data[@config[:top_class]], nil)
|
172
183
|
param[:data_global] = @data
|
184
|
+
param[:data_inverse_global] = @data_inverse
|
173
185
|
param[:versions] = versions
|
174
186
|
param[:toplevel] = toplevel
|
175
187
|
subjects.sort.each do |subject|
|
188
|
+
objects = []
|
189
|
+
if @config.has_key? :top_additional_property
|
190
|
+
@config[:top_additional_property].each do |property|
|
191
|
+
if @data[subject][property]
|
192
|
+
objects += @data[subject][property]
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
176
196
|
param[:index_data] ||= []
|
177
|
-
param[:index_data] <<
|
197
|
+
param[:index_data] << {
|
198
|
+
subject.to_s => objects
|
199
|
+
}
|
178
200
|
end
|
201
|
+
param[:output_file] = index_html
|
202
|
+
param[:index_list] = template.to_html_raw("index-list.html.erb", param)
|
179
203
|
template.output_to(index_html, param)
|
180
204
|
end
|
181
205
|
end
|
182
|
-
if shapes.size > 0 or versions.size > 0 or toplevel.size > 0
|
206
|
+
if template.find_template_path("about.html") or shapes.size > 0 or versions.size > 0 or toplevel.size > 0
|
183
207
|
about_html = @config[:about_file] || "about.html"
|
184
208
|
about_html = File.join(@config[:output_dir], about_html) if @config[:output_dir]
|
185
209
|
template = Template.new("about.html.erb", @config)
|
186
210
|
param = @config.dup
|
211
|
+
param[:content] = template.to_html_raw("about.html", {}) if template.find_template_path("about.html")
|
187
212
|
param[:data_global] = @data
|
188
213
|
param[:versions] = versions
|
189
214
|
param[:toplevel] = toplevel
|
190
215
|
param[:shapes] = {}
|
191
|
-
shapes.
|
216
|
+
shapes.each do |subject|
|
217
|
+
orders = []
|
218
|
+
if param[:shape_orders]
|
219
|
+
param[:shape_orders].index(subject)
|
220
|
+
orders << ( param[:shape_orders].index(subject) or Float::INFINITY )
|
221
|
+
end
|
222
|
+
orders << subject
|
192
223
|
label = comment = nil
|
193
224
|
target_class = @data[subject.to_s]["http://www.w3.org/ns/shacl#targetClass"]
|
194
225
|
if target_class
|
@@ -206,6 +237,8 @@ module TTL2HTML
|
|
206
237
|
label: label,
|
207
238
|
comment: comment,
|
208
239
|
html: template.expand_shape(@data, subject.to_s, @prefix),
|
240
|
+
target_class: target_class,
|
241
|
+
order: orders,
|
209
242
|
}
|
210
243
|
end
|
211
244
|
template.output_to(about_html, param)
|
@@ -224,51 +257,87 @@ module TTL2HTML
|
|
224
257
|
@config[:breadcrumbs].each do |e|
|
225
258
|
data_target = data
|
226
259
|
data_target = @data_inverse[uri] if e["inverse"]
|
227
|
-
if data_target
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
260
|
+
if data_target
|
261
|
+
if e["property"].kind_of? Array
|
262
|
+
parent = nil
|
263
|
+
data_target_sub = data_target
|
264
|
+
e["property"].each do |prop|
|
265
|
+
if data_target_sub[prop["property"]]
|
266
|
+
data_target_sub[prop["property"]].each do |o|
|
267
|
+
parent = o
|
268
|
+
data_target_sub = @data[parent]
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
if parent
|
273
|
+
results << build_breadcrumbs_sub(parent, template)
|
274
|
+
results += build_breadcrumbs(parent, template, depth + 1)
|
275
|
+
return results
|
276
|
+
end
|
277
|
+
elsif data_target[e["property"]]
|
278
|
+
data_target[e["property"]].each do |parent|
|
279
|
+
results << build_breadcrumbs_sub(parent, template, e["label"])
|
280
|
+
results += build_breadcrumbs(parent, template, depth + 1)
|
281
|
+
return results
|
282
|
+
end
|
237
283
|
end
|
238
|
-
return results
|
239
284
|
end
|
240
285
|
end
|
241
286
|
end
|
242
287
|
results
|
243
288
|
end
|
289
|
+
def build_breadcrumbs_sub(parent, template, label_prop = nil)
|
290
|
+
data_parent = @data[parent]
|
291
|
+
label = template.get_title(data_parent)
|
292
|
+
label = data_parent[label_prop].first if label_prop and data_parent[label_prop]
|
293
|
+
{
|
294
|
+
uri: parent,
|
295
|
+
label: label,
|
296
|
+
}
|
297
|
+
end
|
244
298
|
|
245
|
-
def
|
246
|
-
|
247
|
-
|
248
|
-
target_class = @data[shape.to_s]["http://www.w3.org/ns/shacl#targetClass"]&.first
|
299
|
+
def shapes_parse(shapes)
|
300
|
+
shapes.each do |shape|
|
301
|
+
target_class = @data[shape]["http://www.w3.org/ns/shacl#targetClass"]&.first
|
249
302
|
if target_class
|
250
|
-
@data[shape.to_s]["http://www.w3.org/ns/shacl#property"]
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
303
|
+
properties = @data[shape.to_s]["http://www.w3.org/ns/shacl#property"]
|
304
|
+
if @data[shape.to_s]["http://www.w3.org/ns/shacl#or"]
|
305
|
+
properties ||= []
|
306
|
+
node_list = @data[shape.to_s]["http://www.w3.org/ns/shacl#or"].first
|
307
|
+
while node_list and @data[node_list] do
|
308
|
+
sub_shape = @data[node_list]["http://www.w3.org/1999/02/22-rdf-syntax-ns#first"].first
|
309
|
+
if @data[sub_shape] and @data[sub_shape]["http://www.w3.org/ns/shacl#property"]
|
310
|
+
properties += @data[sub_shape]["http://www.w3.org/ns/shacl#property"]
|
311
|
+
end
|
312
|
+
node_list = @data[node_list]["http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"].first
|
313
|
+
end
|
314
|
+
end
|
315
|
+
if not properties.empty?
|
316
|
+
properties.each do |property|
|
317
|
+
path = @data[property]["http://www.w3.org/ns/shacl#path"].first
|
318
|
+
yield target_class, property
|
319
|
+
end
|
255
320
|
end
|
256
321
|
end
|
257
322
|
end
|
323
|
+
end
|
324
|
+
def shapes2labels(shapes)
|
325
|
+
labels = {}
|
326
|
+
shapes_parse(shapes) do |target_class, property|
|
327
|
+
path = @data[property]["http://www.w3.org/ns/shacl#path"].first
|
328
|
+
name = @data[property]["http://www.w3.org/ns/shacl#name"]
|
329
|
+
labels[target_class] ||= {}
|
330
|
+
labels[target_class][path] = name
|
331
|
+
end
|
258
332
|
labels
|
259
333
|
end
|
260
334
|
def shapes2orders(shapes)
|
261
335
|
orders = {}
|
262
|
-
shapes
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
order = @data[property]["http://www.w3.org/ns/shacl#order"]
|
268
|
-
orders[target_class] ||= {}
|
269
|
-
orders[target_class][path] = order&.first&.to_i
|
270
|
-
end
|
271
|
-
end
|
336
|
+
shapes_parse(shapes) do |target_class, property|
|
337
|
+
path = @data[property]["http://www.w3.org/ns/shacl#path"].first
|
338
|
+
order = @data[property]["http://www.w3.org/ns/shacl#order"]
|
339
|
+
orders[target_class] ||= {}
|
340
|
+
orders[target_class][path] = order&.first&.to_i
|
272
341
|
end
|
273
342
|
orders
|
274
343
|
end
|
@@ -276,17 +345,25 @@ module TTL2HTML
|
|
276
345
|
def extract_versions
|
277
346
|
versions = []
|
278
347
|
["http://purl.org/pav/hasVersion", "http://purl.org/pav/hasCurrentVersion", "http://purl.org/dc/terms/hasVersion"].each do |prop|
|
279
|
-
objects =
|
348
|
+
objects = []
|
349
|
+
@data.each do |s, v|
|
350
|
+
if @data[s][prop]
|
351
|
+
objects += @data[s][prop]
|
352
|
+
end
|
353
|
+
end
|
280
354
|
objects.each do |o|
|
281
355
|
uri = o.to_s
|
282
356
|
version = @data[uri]
|
283
357
|
next if not version
|
358
|
+
next if not version["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
|
284
359
|
next if not version["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].include? "http://rdfs.org/ns/void#Dataset"
|
285
360
|
description = version["http://purl.org/dc/terms/description"]
|
361
|
+
link = nil
|
286
362
|
if not description
|
287
363
|
qrev = version["http://www.w3.org/ns/prov#qualifiedRevision"]&.first
|
288
|
-
if
|
364
|
+
if @data[qrev]
|
289
365
|
description = @data[qrev]["http://www.w3.org/2000/01/rdf-schema#comment"]
|
366
|
+
link = @data[qrev]["http://www.w3.org/2000/01/rdf-schema#seeAlso"]&.first
|
290
367
|
end
|
291
368
|
end
|
292
369
|
subset = []
|
@@ -306,6 +383,7 @@ module TTL2HTML
|
|
306
383
|
date: date,
|
307
384
|
description: description,
|
308
385
|
subset: subset,
|
386
|
+
link: link,
|
309
387
|
}
|
310
388
|
end
|
311
389
|
end
|
@@ -313,15 +391,24 @@ module TTL2HTML
|
|
313
391
|
end
|
314
392
|
def extract_toplevel
|
315
393
|
result = {}
|
316
|
-
toplevel =
|
394
|
+
toplevel = nil
|
395
|
+
@data.each do |s, v|
|
396
|
+
if @data[s]["http://purl.org/pav/hasCurrentVersion"]
|
397
|
+
toplevel = s
|
398
|
+
end
|
399
|
+
end
|
317
400
|
data = @data[toplevel.to_s]
|
318
401
|
if toplevel
|
319
402
|
license = {}
|
320
403
|
if data["http://purl.org/dc/terms/license"]
|
321
404
|
license_data = @data[data["http://purl.org/dc/terms/license"].first]
|
322
|
-
|
323
|
-
|
324
|
-
|
405
|
+
if license_data
|
406
|
+
license[:url] = license_data["http://www.w3.org/1999/02/22-rdf-syntax-ns#value"]&.first
|
407
|
+
license[:icon] = license_data["http://xmlns.com/foaf/0.1/thumbnail"]&.first
|
408
|
+
license[:label] = license_data["http://www.w3.org/2000/01/rdf-schema#label"]
|
409
|
+
elsif data["http://purl.org/dc/terms/license"].first =~ URI::regexp
|
410
|
+
license[:url] = license[:label] = data["http://purl.org/dc/terms/license"].first
|
411
|
+
end
|
325
412
|
end
|
326
413
|
if data["http://purl.org/dc/terms/publisher"]
|
327
414
|
publisher_data = @data[data["http://purl.org/dc/terms/publisher"].first]
|
@@ -353,58 +440,38 @@ module TTL2HTML
|
|
353
440
|
|
354
441
|
def output_turtle_files
|
355
442
|
each_data(:output_turtle_files) do |uri, v|
|
356
|
-
file = uri_mapping_to_path(uri, ".ttl")
|
443
|
+
file = uri_mapping_to_path(uri, @config, ".ttl")
|
357
444
|
if @config[:output_dir]
|
358
445
|
Dir.mkdir @config[:output_dir] if not File.exist? @config[:output_dir]
|
359
446
|
file = File.join(@config[:output_dir], file)
|
360
447
|
end
|
361
|
-
|
448
|
+
dir = File.dirname(file)
|
449
|
+
FileUtils.mkdir_p(dir) if not File.exist?(dir)
|
450
|
+
str = format_turtle(uri)
|
362
451
|
str << format_turtle_inverse(uri)
|
363
452
|
open(file, "w") do |io|
|
364
453
|
io.puts str.strip
|
365
454
|
end
|
366
455
|
end
|
367
456
|
end
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
local_file = uri.sub(@config[:base_uri], "")
|
373
|
-
if mapping["regexp"] =~ local_file
|
374
|
-
path = local_file.sub(mapping["regexp"], mapping["path"])
|
375
|
-
end
|
376
|
-
end
|
377
|
-
end
|
378
|
-
if path.nil?
|
379
|
-
if suffix == ".html"
|
380
|
-
if @data.keys.find{|e| e.start_with?(uri + "/") }
|
381
|
-
path = uri + "/index"
|
382
|
-
elsif uri.end_with?("/")
|
383
|
-
path = uri + "index"
|
384
|
-
else
|
385
|
-
path = uri
|
386
|
-
end
|
387
|
-
else
|
388
|
-
path = uri
|
389
|
-
end
|
390
|
-
end
|
391
|
-
path = path.sub(@config[:base_uri], "")
|
392
|
-
path << suffix
|
393
|
-
#p [uri, path]
|
394
|
-
path
|
457
|
+
|
458
|
+
def output_files
|
459
|
+
output_html_files
|
460
|
+
output_turtle_files if @config[:output_turtle]
|
395
461
|
end
|
462
|
+
|
396
463
|
def cleanup
|
397
464
|
@data.select do |uri, v|
|
398
465
|
uri.start_with? @config[:base_uri]
|
399
466
|
end.sort_by do |uri, v|
|
400
467
|
-(uri.size)
|
401
468
|
end.each do |uri, v|
|
402
|
-
html_file = uri_mapping_to_path(uri, ".html")
|
469
|
+
html_file = uri_mapping_to_path(uri, @config, ".html")
|
403
470
|
html_file = File.join(@config[:output_dir], html_file) if @config[:output_dir]
|
404
|
-
File.unlink html_file
|
405
|
-
ttl_file = uri_mapping_to_path(uri, ".ttl")
|
471
|
+
File.unlink html_file if File.exist? html_file
|
472
|
+
ttl_file = uri_mapping_to_path(uri, @config, ".ttl")
|
406
473
|
ttl_file = File.join(@config[:output_dir], ttl_file) if @config[:output_dir]
|
407
|
-
File.unlink ttl_file
|
474
|
+
File.unlink ttl_file if File.exist? ttl_file
|
408
475
|
dir = uri.sub(@config[:base_uri], "")
|
409
476
|
dir = File.join(@config[:output_dir], dir) if @config[:output_dir]
|
410
477
|
Dir.rmdir dir if File.exist? dir
|
data/locales/en.yml
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
en:
|
2
2
|
about:
|
3
3
|
title: "About %{title}"
|
4
|
-
|
4
|
+
shape-heading: "Resources description"
|
5
5
|
shape-note: "The properties for the %{resource} resources are as follows:"
|
6
|
+
shape-target: Target class
|
7
|
+
shape-namespace: "The namespace URIs used in the table are as follows:"
|
6
8
|
versions: Versions
|
7
9
|
version-release: "Version %{version} released."
|
8
10
|
version-triples: "%{triples} triples"
|
11
|
+
version-link: "Please refer to <a href=\"%{link}\">here</a> for the revision details."
|
9
12
|
contact: Contact
|
10
13
|
contact-contribution: "This dataset was developed by %{name}"
|
11
14
|
contact-email: "For dataset inquiries, please contact at <a href=\"%{email}\">%{email}</a>"
|
@@ -35,3 +38,4 @@ en:
|
|
35
38
|
blank-node-or-structure: "The structural contents of a blank node are either of the followings:"
|
36
39
|
triples:
|
37
40
|
inverse_refered: "Referred to as '%{property}' from:"
|
41
|
+
blank_node: "Blank node"
|
data/locales/ja.yml
CHANGED
@@ -1,10 +1,14 @@
|
|
1
1
|
ja:
|
2
2
|
about:
|
3
3
|
title: "%{title}について"
|
4
|
+
shape-heading: "各リソースの説明"
|
4
5
|
shape-note: "%{resource}リソースが持つプロパティを下表に示します"
|
6
|
+
shape-target: 対象クラス
|
7
|
+
shape-namespace: "表内で用いている名前空間URIは以下の通りです"
|
5
8
|
versions: 更新履歴
|
6
9
|
version-release: "バージョン%{version}を公開。"
|
7
10
|
version-triples: "%{triples}トリプル"
|
11
|
+
version-link: "更新の詳細については<a href=\"%{link}\">こちら</a>をご覧ください。"
|
8
12
|
contact: 連絡先
|
9
13
|
contact-contribution: "本データセットは %{name} が開発したものです"
|
10
14
|
contact-email: "データセットに関する問い合わせは <a href=\"%{email}\">%{email}</a> までお問い合わせください。"
|
@@ -34,3 +38,4 @@ ja:
|
|
34
38
|
blank-node-or-structure: ブランクノードの内容は以下のいずれかの内容からなる構造を持ちます。
|
35
39
|
triples:
|
36
40
|
inverse_refered: "'%{property}'としての参照元:"
|
41
|
+
blank_node: "空ノード"
|
data/templates/about.html.erb
CHANGED
@@ -17,11 +17,22 @@
|
|
17
17
|
</nav>
|
18
18
|
</div>
|
19
19
|
</div>
|
20
|
-
<%- if param[:
|
20
|
+
<%- if param[:content] -%>
|
21
21
|
<div class="row">
|
22
22
|
<div class="col-md">
|
23
|
-
|
23
|
+
<%= param[:content] %>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
<%- end -%>
|
27
|
+
<%- if param[:shapes].size > 0 -%>
|
28
|
+
<div class="row">
|
29
|
+
<div class="col-md">
|
30
|
+
<h2 id="shapes"><%=h t("about.shape-heading") %></h2>
|
31
|
+
<%- param[:shapes].keys.sort_by{|k| param[:shapes][k][:order] }.each do |shape| -%>
|
24
32
|
<h3><%=h param[:shapes][shape][:label] %></h3>
|
33
|
+
<%- if param[:shapes][shape][:target_class] -%>
|
34
|
+
<ul><li><%= t("about.shape-target") %>: <a href="<%=h param[:shapes][shape][:target_class] %>"><%=h param[:shapes][shape][:target_class] %></a></li></ul>
|
35
|
+
<%- end -%>
|
25
36
|
<p><%= param[:shapes][shape][:comment] %></p>
|
26
37
|
<p><%=h t("about.shape-note", resource: param[:shapes][shape][:label]) %></p>
|
27
38
|
<%= param[:shapes][shape][:html] -%>
|
@@ -29,7 +40,7 @@
|
|
29
40
|
</div>
|
30
41
|
</div>
|
31
42
|
<%- end -%>
|
32
|
-
<%- if param[:versions] -%>
|
43
|
+
<%- if param[:versions].size > 0 -%>
|
33
44
|
<div class="row">
|
34
45
|
<div class="col-md">
|
35
46
|
<h2 id="versions"><%=h t("about.versions") %> <i class="bi bi-info-circle"></i></h2>
|
data/templates/default.html.erb
CHANGED
@@ -10,11 +10,11 @@
|
|
10
10
|
<div class="col-md-12">
|
11
11
|
<nav aria-label="breadcrumb">
|
12
12
|
<ol class="breadcrumb">
|
13
|
-
<li class="breadcrumb-item"><a href="
|
13
|
+
<li class="breadcrumb-item"><a href="<%=h relative_path_uri(param[:base_uri]) %>"><i class="bi bi-house-door-fill"></i> Home</a></li>
|
14
14
|
<%- param[:breadcrumbs_items].reverse.each_with_index do |e, i| -%>
|
15
15
|
<li class="breadcrumb-item<%= ' active' if i == param[:breadcrumbs_items].size-1 %>" aria-current="page">
|
16
16
|
<%- if e[:uri] -%>
|
17
|
-
<a href="<%=h e[:uri] %>"><%=h e[:label] %></a>
|
17
|
+
<a href="<%=h relative_path_uri(e[:uri]) %>"><%=h e[:label] %></a>
|
18
18
|
<%- else -%>
|
19
19
|
<%=h e[:label] %>
|
20
20
|
<%- end -%>
|
@@ -31,11 +31,14 @@
|
|
31
31
|
<%= format_triples(param[:data]) %>
|
32
32
|
</div>
|
33
33
|
</div>
|
34
|
+
<%- if param[:additional_content] -%>
|
35
|
+
<%= param[:additional_content] %>
|
36
|
+
<%- end -%>
|
34
37
|
<%- if param[:data_inverse] -%>
|
35
38
|
<div class="row inverse">
|
36
39
|
<div class="col-md-12">
|
37
40
|
<h2><%=h t("default.inverse_data") %></h2>
|
38
|
-
<%= format_triples(param[:data_inverse], :
|
41
|
+
<%= format_triples(param[:data_inverse], inverse: true) %>
|
39
42
|
</div>
|
40
43
|
</div>
|
41
44
|
<%- end -%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="row">
|
2
|
+
<div class="col-md-12">
|
3
|
+
<h2><%=h t("index.list", resource: param[:class_label]) %></h2>
|
4
|
+
<ul>
|
5
|
+
<%- param[:index_data].each do |e| -%>
|
6
|
+
<%- e.each do |s, o| -%>
|
7
|
+
<li><%= format_object(s, param[:data_global]) %>
|
8
|
+
<%- if o and o.size > 0 -%>
|
9
|
+
<ul>
|
10
|
+
<%- o.each do |o2| -%>
|
11
|
+
<li><%= format_object(o2.to_s, param[:data_global]) %></li>
|
12
|
+
<%- end -%>
|
13
|
+
</ul>
|
14
|
+
<%- end -%>
|
15
|
+
</li>
|
16
|
+
<%- end -%>
|
17
|
+
<%- end -%>
|
18
|
+
</ul>
|
19
|
+
</div>
|
20
|
+
</div>
|
data/templates/index.html.erb
CHANGED
@@ -5,19 +5,11 @@
|
|
5
5
|
<p><%= get_language_literal(param[:toplevel][:description]) %></p>
|
6
6
|
<%- end -%>
|
7
7
|
<p><i class="bi bi-link-45deg"></i> <a href="<%=h param[:base_uri] %>"><%=h param[:base_uri] %></a></p>
|
8
|
+
<p><a class="btn btn-info" href="<%=h relative_path(param[:about_file] || "about.html") %>"><%=h t("about.title", title: param[:site_title]) %> »</a></p>
|
8
9
|
</div>
|
9
10
|
</div>
|
10
11
|
<div class="container">
|
11
|
-
|
12
|
-
<div class="col-md-12">
|
13
|
-
<h2><%=h t("index.list", resource: param[:class_label]) %></h2>
|
14
|
-
<ul>
|
15
|
-
<%- param[:index_data].each do |e| -%>
|
16
|
-
<li><%= format_object(e, param[:data_global]) %></li>
|
17
|
-
<%- end -%>
|
18
|
-
</ul>
|
19
|
-
</div>
|
20
|
-
</div>
|
12
|
+
<%= param[:index_list] %>
|
21
13
|
<%- if param[:versions].size > 0 -%>
|
22
14
|
<div class="row">
|
23
15
|
<div class="col-md">
|
@@ -39,4 +31,4 @@
|
|
39
31
|
</div>
|
40
32
|
</div>
|
41
33
|
<%- end -%>
|
42
|
-
</div>
|
34
|
+
</div>
|
data/templates/layout.html.erb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
-
<html>
|
2
|
+
<html lang="<%= param[:locale] || I18n.default_locale %>">
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
6
|
-
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
|
7
6
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
|
8
7
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.1/font/bootstrap-icons.css">
|
9
8
|
<%- if param[:css_file] -%>
|
@@ -15,11 +14,30 @@
|
|
15
14
|
<title><%=h html_title(param) %></title>
|
16
15
|
<meta name="twitter:card" content="summary">
|
17
16
|
<meta name="twitter:title" content="<%=h html_title(param) %>">
|
17
|
+
<meta property="og:title" content="<%=h html_title(param) %>">
|
18
|
+
<meta property="og:type" content="website">
|
19
|
+
<%- if param[:uri] -%>
|
20
|
+
<meta property="og:url" content="<%=h param[:uri] %>">
|
21
|
+
<%- end -%>
|
22
|
+
<%- if param[:logo] -%>
|
23
|
+
<meta property="og:image" content="<%=h URI.parse(param[:base_uri]) + param[:logo] %>">
|
24
|
+
<%- end -%>
|
25
|
+
<%- if param[:google_analytics] -%>
|
26
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=<%=h param[:google_analytics] %>"></script>
|
27
|
+
<script>
|
28
|
+
window.dataLayer = window.dataLayer || [];
|
29
|
+
function gtag(){dataLayer.push(arguments);}
|
30
|
+
gtag('js', new Date());
|
31
|
+
gtag('config', '<%=u param[:google_analytics] %>');
|
32
|
+
</script>
|
33
|
+
<%- end -%>
|
18
34
|
</head>
|
19
35
|
<body>
|
20
|
-
<nav class="navbar navbar-expand-lg navbar-light">
|
36
|
+
<nav class="navbar navbar-expand-lg <%=h param[:navbar_class] || "navbar-light" %>">
|
21
37
|
<%- if param[:logo] -%>
|
22
|
-
<a class="navbar-brand" href="
|
38
|
+
<a class="navbar-brand" href="<%=h relative_path_uri(param[:base_uri]) %>">
|
39
|
+
<img src="<%=h relative_path(param[:logo]) %>" style="max-height: 54px" alt="<%=h param[:site_title] %>">
|
40
|
+
</a>
|
23
41
|
<%- end -%>
|
24
42
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
25
43
|
<span class="navbar-toggler-icon"></span>
|
@@ -27,19 +45,24 @@
|
|
27
45
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
28
46
|
<ul class="navbar-nav mr-auto">
|
29
47
|
<li class="nav-item<%= ' active' if @template == "index.html.erb" %>">
|
30
|
-
<a class="nav-link" href="
|
48
|
+
<a class="nav-link" href="<%=h relative_path_uri(param[:base_uri]) %>">Home</a>
|
31
49
|
</li>
|
32
50
|
<li class="nav-item<%= ' active' if @template == "about.html.erb" %>">
|
33
|
-
<a class="nav-link" href="
|
51
|
+
<a class="nav-link" href="<%=h relative_path(param[:about_file] || "about.html") %>">About</a>
|
34
52
|
</li>
|
53
|
+
<%- if param[:additional_link] -%>
|
54
|
+
<%- param[:additional_link].each do |link| -%>
|
55
|
+
<li class="nav-item"><a class="nav-link" href="<%=h link["href"] %>"><%=h link["label"] %></a></li>
|
56
|
+
<%- end -%>
|
57
|
+
<%- end -%>
|
35
58
|
</ul>
|
36
59
|
</div>
|
37
60
|
</nav>
|
38
61
|
<%= param[:content] %>
|
39
62
|
<hr>
|
40
63
|
<footer>
|
41
|
-
<%- if param[:
|
42
|
-
|
64
|
+
<%- if param[:turtle_uri] -%>
|
65
|
+
<p class="float-right"><a href="<%=h param[:turtle_uri] %>"><img src="https://www.w3.org/RDF/icons/rdf_flyer.24" alt="<%=h t("layout.rdf-data") %>"></a></p>
|
43
66
|
<%- end -%>
|
44
67
|
<%- if param[:admin_name] -%>
|
45
68
|
<p>
|
@@ -55,5 +78,8 @@
|
|
55
78
|
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
|
56
79
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
57
80
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
|
81
|
+
<%- if param[:javascript_file] -%>
|
82
|
+
<script src="<%=h relative_path(param[:javascript_file]) %>"></script>
|
83
|
+
<%- end -%>
|
58
84
|
</body>
|
59
85
|
</html>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
<table class="table table-
|
1
|
+
<table class="table table-sm">
|
2
2
|
<tr>
|
3
3
|
<th><%=h t('shape-table.header.property-name') %></th>
|
4
4
|
<th><%=h t('shape-table.header.description') %></th>
|
@@ -56,5 +56,17 @@
|
|
56
56
|
<%- end -%>
|
57
57
|
<%- end -%>
|
58
58
|
</tbody>
|
59
|
-
|
60
|
-
|
59
|
+
<%- if param[:prefix] and not param[:prefix].empty? -%>
|
60
|
+
<tfoot>
|
61
|
+
<tr><td colspan="5">
|
62
|
+
<%=h t('about.shape-namespace') %>
|
63
|
+
<dl class="row small">
|
64
|
+
<%- param[:prefix].each do |prefix, url| -%>
|
65
|
+
<dt class="col-sm-2"><code><%=h prefix %>:</code></dt>
|
66
|
+
<dd class="col-sm-10"><%=h url %></dd>
|
67
|
+
<%- end -%>
|
68
|
+
</dl>
|
69
|
+
<%- end -%>
|
70
|
+
</td></tr>
|
71
|
+
</tfoot>
|
72
|
+
</table>
|
@@ -0,0 +1,20 @@
|
|
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
|
+
<dt class="col-sm-3"><%=h t('triples.inverse_refered', property: format_property(k, param[:labels], v.first)) %></dt>
|
8
|
+
<%- if v.respond_to? :has_key? -%>
|
9
|
+
<% v.each_with_index do |v2, idx| %>
|
10
|
+
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" lang="<%=h v2[0] %>"><%= format_object v2[1], param[:data], param[:type] %></dd>
|
11
|
+
<% end %>
|
12
|
+
<%- elsif v.size > 1 -%>
|
13
|
+
<%- v.each_with_index do |v2, idx| -%>
|
14
|
+
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>"><%= format_object v2, param[:data], param[:type] %></dd>
|
15
|
+
<%- end -%>
|
16
|
+
<%- else -%>
|
17
|
+
<dd class="col-sm-9"><%= format_object v.first, param[:data], param[:type] %></dd>
|
18
|
+
<%- end -%>
|
19
|
+
<%- end -%>
|
20
|
+
</dl>
|
data/templates/triples.html.erb
CHANGED
@@ -4,21 +4,17 @@
|
|
4
4
|
order = Float::INFINITY if order.nil?
|
5
5
|
[ order, k ]
|
6
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
7
|
<dt class="col-sm-3"><%=h format_property(k, param[:labels]) %></dt>
|
11
|
-
<%- end -%>
|
12
8
|
<%- if v.respond_to? :has_key? -%>
|
13
|
-
|
14
|
-
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" lang="<%=h v2[0] %>"><%= format_object v2[1], param[:data] %></dd>
|
15
|
-
|
9
|
+
<%- v.each_with_index do |v2, idx| -%>
|
10
|
+
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>" lang="<%=h v2[0] %>"><%= format_object v2[1], param[:data], param[:type] %></dd>
|
11
|
+
<%- end -%>
|
16
12
|
<%- elsif v.size > 1 -%>
|
17
13
|
<%- 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>
|
14
|
+
<dd class="col-sm-9<%= ' offset-sm-3' if idx > 0 %>"><%= format_object v2, param[:data], param[:type] %></dd>
|
19
15
|
<%- end -%>
|
20
16
|
<%- else -%>
|
21
|
-
<dd class="col-sm-9"><%= format_object v.first, param[:data] %></dd>
|
17
|
+
<dd class="col-sm-9"><%= format_object v.first, param[:data], param[:type] %></dd>
|
22
18
|
<%- end -%>
|
23
19
|
<%- end -%>
|
24
20
|
</dl>
|
data/templates/version.html.erb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
<dt><%=h param[:data][:date] %></dt>
|
2
2
|
<dd><%=h t("about.version-release", version: param[:data][:version]) %></dd>
|
3
|
-
<dd><%=h get_language_literal(param[:data][:description])
|
3
|
+
<dd><%=h get_language_literal(param[:data][:description]) %>
|
4
|
+
<%- if param[:data][:link] -%>
|
5
|
+
<%= t("about.version-link", link: param[:data][:link]) %>
|
6
|
+
<%- end -%>
|
7
|
+
</dd>
|
4
8
|
<%- if param[:data][:datadump] -%>
|
5
9
|
<dd><ul>
|
6
10
|
<li><a href="<%=h param[:data][:datadump] %>"><%=h File.basename(param[:data][:datadump]) %></a>
|
@@ -24,5 +28,5 @@
|
|
24
28
|
</ul>
|
25
29
|
</li>
|
26
30
|
<%- end -%>
|
27
|
-
</dd>
|
31
|
+
</ul></dd>
|
28
32
|
<%- end -%>
|
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:
|
4
|
+
version: 2.0.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:
|
11
|
+
date: 2022-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -150,15 +150,19 @@ files:
|
|
150
150
|
- bin/xlsx2shape
|
151
151
|
- lib/ttl2html.rb
|
152
152
|
- lib/ttl2html/template.rb
|
153
|
+
- lib/ttl2html/util.rb
|
153
154
|
- lib/ttl2html/version.rb
|
154
155
|
- lib/xlsx2shape.rb
|
155
156
|
- locales/en.yml
|
156
157
|
- locales/ja.yml
|
157
158
|
- templates/about.html.erb
|
158
159
|
- templates/default.html.erb
|
160
|
+
- templates/index-list.html.erb
|
159
161
|
- templates/index.html.erb
|
160
162
|
- templates/layout.html.erb
|
161
163
|
- templates/shape-table.html.erb
|
164
|
+
- templates/triples-blank.html.erb
|
165
|
+
- templates/triples-inverse.html.erb
|
162
166
|
- templates/triples.html.erb
|
163
167
|
- templates/version.html.erb
|
164
168
|
homepage: https://github.com/masao/ttl2html
|
@@ -180,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
184
|
- !ruby/object:Gem::Version
|
181
185
|
version: '0'
|
182
186
|
requirements: []
|
183
|
-
rubygems_version: 3.3.
|
187
|
+
rubygems_version: 3.3.7
|
184
188
|
signing_key:
|
185
189
|
specification_version: 4
|
186
190
|
summary: ttl2html
|