ttl2html 0.3.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ttl2html/template.rb +62 -6
- data/lib/ttl2html/version.rb +1 -1
- data/lib/ttl2html.rb +100 -55
- data/locales/en.yml +26 -0
- data/locales/ja.yml +25 -0
- data/templates/about.html.erb +5 -4
- data/templates/default.html.erb +2 -2
- data/templates/index.html.erb +1 -1
- data/templates/layout.html.erb +1 -1
- data/templates/shape-table.html.erb +14 -9
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9d57dc99fea0827d317a9dc3597cae9c69d1ac38dbcd66000327f1b913dea03
|
4
|
+
data.tar.gz: d30441245cd56e6322fe3ab0b27351a83900b6c6826b3c5a6d611bffa8245d3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c5068b43cc54072f3958f46b5192c5fe118d5942c0b53d4f2fc35f8e35560a6768a2905d1cd946efc8462faa51b2d2ea4d844f8f73f982e18fb73ea5a812ee5
|
7
|
+
data.tar.gz: 6dc8f656583fc5d8a96baab454b1ea47e446e5694c55f457b3e236e91945595d8b2838d7a7b628d918d7a9c85bb138e081e8919453edce96228572a93dd617eb
|
data/lib/ttl2html/template.rb
CHANGED
@@ -3,16 +3,21 @@
|
|
3
3
|
require "fileutils"
|
4
4
|
require "pathname"
|
5
5
|
require "erb"
|
6
|
+
require "i18n"
|
6
7
|
|
7
8
|
module TTL2HTML
|
8
9
|
class Template
|
9
10
|
attr_reader :param
|
10
11
|
include ERB::Util
|
12
|
+
include I18n::Base
|
11
13
|
def initialize(template, param = {})
|
12
14
|
@template = template
|
13
|
-
@param = param
|
15
|
+
@param = param.dup
|
14
16
|
@template_path = [ Dir.pwd, File.join(Dir.pwd, "templates") ]
|
15
17
|
@template_path << File.join(File.dirname(__FILE__), "..", "..", "templates")
|
18
|
+
I18n.load_path << Dir[File.join(File.dirname(__FILE__), "..", "..", "locales") + "/*.yml"]
|
19
|
+
I18n.load_path << Dir[File.expand_path("locales") + "/*.yml"]
|
20
|
+
I18n.locale = @param[:locale] if @param[:locale]
|
16
21
|
end
|
17
22
|
def output_to(file, param = {})
|
18
23
|
@param.update(param)
|
@@ -92,9 +97,9 @@ module TTL2HTML
|
|
92
97
|
{
|
93
98
|
path: path,
|
94
99
|
shorten_path: shorten_path,
|
95
|
-
name: data[property]["http://www.w3.org/ns/shacl#name"]
|
100
|
+
name: get_language_literal(data[property]["http://www.w3.org/ns/shacl#name"]),
|
96
101
|
example: data[property]["http://www.w3.org/2004/02/skos/core#example"] ? data[property]["http://www.w3.org/2004/02/skos/core#example"].first : nil,
|
97
|
-
description: data[property]["http://www.w3.org/ns/shacl#description"]
|
102
|
+
description: get_language_literal(data[property]["http://www.w3.org/ns/shacl#description"]),
|
98
103
|
required: data[property]["http://www.w3.org/ns/shacl#minCount"] ? data[property]["http://www.w3.org/ns/shacl#minCount"].first.to_i > 0 : false,
|
99
104
|
repeatable: repeatable,
|
100
105
|
nodeKind: data[property]["http://www.w3.org/ns/shacl#nodeKind"] ? data[property]["http://www.w3.org/ns/shacl#nodeKind"].first : nil,
|
@@ -108,6 +113,33 @@ module TTL2HTML
|
|
108
113
|
end
|
109
114
|
|
110
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
|
111
143
|
def relative_path(dest)
|
112
144
|
src = @param[:output_file]
|
113
145
|
src = Pathname.new(src).relative_path_from(Pathname.new(@param[:output_dir])) if @param[:output_dir]
|
@@ -118,12 +150,20 @@ module TTL2HTML
|
|
118
150
|
def relative_path_uri(dest_uri, base_uri)
|
119
151
|
if dest_uri.start_with? base_uri
|
120
152
|
dest = dest_uri.sub(base_uri, "")
|
153
|
+
dest = uri_mapping_to_path(dest, "")
|
121
154
|
relative_path(dest)
|
122
155
|
else
|
123
156
|
dest_uri
|
124
157
|
end
|
125
158
|
end
|
126
159
|
def get_title(data, default_title = "no title")
|
160
|
+
if @param[:title_property_perclass] and data["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
|
161
|
+
@param[:title_property_perclass].each do |klass, property|
|
162
|
+
if data["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].include?(klass) and data[property]
|
163
|
+
return get_language_literal(data[property])
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
127
167
|
if @param[:title_property] and data[@param[:title_property]]
|
128
168
|
return get_language_literal(data[@param[:title_property]])
|
129
169
|
end
|
@@ -140,7 +180,11 @@ module TTL2HTML
|
|
140
180
|
end
|
141
181
|
def get_language_literal(object)
|
142
182
|
if object.respond_to? :has_key?
|
143
|
-
object.
|
183
|
+
if object.has_key?(I18n.locale)
|
184
|
+
object[I18n.locale]
|
185
|
+
else
|
186
|
+
object.values.first
|
187
|
+
end
|
144
188
|
elsif object.is_a? Array
|
145
189
|
object.first
|
146
190
|
else
|
@@ -157,7 +201,7 @@ module TTL2HTML
|
|
157
201
|
def format_object(object, data)
|
158
202
|
if object =~ /\Ahttps?:\/\//
|
159
203
|
rel_path = relative_path_uri(object, param[:base_uri])
|
160
|
-
if
|
204
|
+
if param[:data_global][object]
|
161
205
|
"<a href=\"#{rel_path}\">#{get_title(param[:data_global][object]) or object}</a>"
|
162
206
|
else
|
163
207
|
"<a href=\"#{rel_path}\">#{object}</a>"
|
@@ -169,7 +213,19 @@ module TTL2HTML
|
|
169
213
|
end
|
170
214
|
end
|
171
215
|
def format_triples(triples)
|
172
|
-
param_local = @param.merge(data: triples)
|
216
|
+
param_local = @param.dup.merge(data: triples)
|
217
|
+
if @param[:labels_with_class] and triples["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"]
|
218
|
+
@param[:labels_with_class].reverse_each do |k, v|
|
219
|
+
triples["http://www.w3.org/1999/02/22-rdf-syntax-ns#type"].each do |entity_class|
|
220
|
+
if entity_class == k
|
221
|
+
v.each do |property, label_value|
|
222
|
+
param_local[:labels] ||= {}
|
223
|
+
param_local[:labels][property] = label_value
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
173
229
|
to_html_raw("triples.html.erb", param_local)
|
174
230
|
end
|
175
231
|
end
|
data/lib/ttl2html/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
TTL2HTML::VERSION = "
|
1
|
+
TTL2HTML::VERSION = "1.2.0"
|
data/lib/ttl2html.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "zlib"
|
3
4
|
require "yaml"
|
4
5
|
require "nokogiri"
|
5
6
|
require "rdf/turtle"
|
@@ -9,9 +10,7 @@ require "ttl2html/template"
|
|
9
10
|
|
10
11
|
module TTL2HTML
|
11
12
|
class App
|
12
|
-
using ProgressBar::Refinements::Enumerator
|
13
13
|
def initialize(config = "config.yml")
|
14
|
-
@template = {}
|
15
14
|
@config = load_config(config)
|
16
15
|
if not @config[:base_uri]
|
17
16
|
raise "load_config: base_uri not found"
|
@@ -67,49 +66,41 @@ module TTL2HTML
|
|
67
66
|
def format_turtle(subject, depth = 1)
|
68
67
|
turtle = RDF::Turtle::Writer.new
|
69
68
|
result = ""
|
70
|
-
if subject
|
71
|
-
result << "<#{subject}>\n#{" "*depth}"
|
72
|
-
else
|
69
|
+
if subject =~ /^_:/
|
73
70
|
result << "[\n#{" "*depth}"
|
71
|
+
else
|
72
|
+
result << "<#{subject}>\n#{" "*depth}"
|
74
73
|
end
|
75
|
-
result << @
|
74
|
+
result << @data[subject.to_s].keys.sort.map do |predicate|
|
76
75
|
str = "<#{predicate}> "
|
77
|
-
str << @
|
78
|
-
if object
|
79
|
-
@graph.query([object, nil, nil]).statements.sort_by{|e|
|
80
|
-
[ e.predicate, e.object ]
|
81
|
-
}.map{|e|
|
82
|
-
[ e.predicate, e.object ]
|
83
|
-
}
|
84
|
-
else
|
85
|
-
object
|
86
|
-
end
|
87
|
-
end.map do |object|
|
88
|
-
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:
|
89
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]))
|
90
83
|
else
|
91
|
-
|
92
|
-
when RDF::URI
|
93
|
-
turtle.format_uri(object)
|
94
|
-
else
|
95
|
-
turtle.format_literal(object)
|
96
|
-
end
|
84
|
+
turtle.format_literal(object)
|
97
85
|
end
|
98
86
|
end.join(", ")
|
99
87
|
str
|
100
88
|
end.join(";\n#{" "*depth}")
|
101
|
-
result << " ." if subject
|
89
|
+
result << " ." if not subject =~ /^_:/
|
102
90
|
result << "\n"
|
103
|
-
result << "#{" "*(depth-1)}]" if
|
91
|
+
result << "#{" "*(depth-1)}]" if subject =~ /^_:/
|
104
92
|
result
|
105
93
|
end
|
106
94
|
def format_turtle_inverse(object)
|
107
|
-
turtle = RDF::Turtle::Writer.new
|
108
95
|
result = ""
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
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
|
113
104
|
end
|
114
105
|
result
|
115
106
|
end
|
@@ -121,7 +112,27 @@ module TTL2HTML
|
|
121
112
|
end
|
122
113
|
end
|
123
114
|
def output_html_files
|
115
|
+
template = Template.new("", @config)
|
116
|
+
shapes = @graph.query([nil,
|
117
|
+
RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
|
118
|
+
RDF::URI("http://www.w3.org/ns/shacl#NodeShape")])
|
119
|
+
labels = shapes2labels(shapes)
|
120
|
+
@config[:labels_with_class] ||= {}
|
121
|
+
labels.each do |klass, props|
|
122
|
+
props.each do |property, label|
|
123
|
+
@config[:labels_with_class][klass] ||= {}
|
124
|
+
if @config[:labels_with_class][klass][property]
|
125
|
+
next
|
126
|
+
else
|
127
|
+
@config[:labels_with_class][klass][property] = template.get_language_literal(label)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
progressbar = ProgressBar.create(title: :output_html_files,
|
132
|
+
total: @data.size,
|
133
|
+
format: "(%t) %a %e %P% Processed: %c from %C")
|
124
134
|
each_data do |uri, v|
|
135
|
+
progressbar.increment
|
125
136
|
template = Template.new("default.html.erb", @config)
|
126
137
|
param = @config.dup
|
127
138
|
param[:uri] = uri
|
@@ -129,21 +140,14 @@ module TTL2HTML
|
|
129
140
|
param[:data_inverse] = @data_inverse[uri]
|
130
141
|
param[:data_global] = @data
|
131
142
|
param[:title] = template.get_title(v)
|
132
|
-
|
133
|
-
file = uri + "/index.html"
|
134
|
-
elsif uri.end_with?("/")
|
135
|
-
file = uri + "index.html"
|
136
|
-
else
|
137
|
-
file = uri + ".html"
|
138
|
-
end
|
139
|
-
#p uri, param
|
140
|
-
file = file.sub(@config[:base_uri], "")
|
143
|
+
file = uri_mapping_to_path(uri, ".html")
|
141
144
|
if @config[:output_dir]
|
142
145
|
Dir.mkdir @config[:output_dir] if not File.exist? @config[:output_dir]
|
143
146
|
file = File.join(@config[:output_dir], file)
|
144
147
|
end
|
145
148
|
template.output_to(file, param)
|
146
149
|
end
|
150
|
+
progressbar.finish
|
147
151
|
index_html = "index.html"
|
148
152
|
index_html = File.join(@config[:output_dir], "index.html") if @config[:output_dir]
|
149
153
|
if @config.has_key? :top_class
|
@@ -164,9 +168,6 @@ module TTL2HTML
|
|
164
168
|
template.output_to(index_html, param)
|
165
169
|
end
|
166
170
|
end
|
167
|
-
shapes = @graph.query([nil,
|
168
|
-
RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
|
169
|
-
RDF::URI("http://www.w3.org/ns/shacl#NodeShape")])
|
170
171
|
if shapes.size > 0
|
171
172
|
about_html = @config[:about_file] || "about.html"
|
172
173
|
about_html = File.join(@config[:output_dir], about_html) if @config[:output_dir]
|
@@ -191,20 +192,69 @@ module TTL2HTML
|
|
191
192
|
template.output_to(about_html, param)
|
192
193
|
end
|
193
194
|
end
|
195
|
+
|
196
|
+
def shapes2labels(shapes)
|
197
|
+
labels = {}
|
198
|
+
shapes.subjects.each do |shape|
|
199
|
+
target_class = @data[shape.to_s]["http://www.w3.org/ns/shacl#targetClass"]&.first
|
200
|
+
if target_class
|
201
|
+
@data[shape.to_s]["http://www.w3.org/ns/shacl#property"].each do |property|
|
202
|
+
path = @data[property]["http://www.w3.org/ns/shacl#path"].first
|
203
|
+
name = @data[property]["http://www.w3.org/ns/shacl#name"]
|
204
|
+
labels[target_class] ||= {}
|
205
|
+
labels[target_class][path] = name
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
labels
|
210
|
+
end
|
211
|
+
|
194
212
|
def output_turtle_files
|
213
|
+
progressbar = ProgressBar.create(title: :output_turtle_files,
|
214
|
+
total: @data.size,
|
215
|
+
format: "(%t) %a %e %P% Processed: %c from %C")
|
195
216
|
each_data do |uri, v|
|
196
|
-
|
197
|
-
file
|
217
|
+
progressbar.increment
|
218
|
+
file = uri_mapping_to_path(uri, ".ttl")
|
198
219
|
if @config[:output_dir]
|
199
220
|
Dir.mkdir @config[:output_dir] if not File.exist? @config[:output_dir]
|
200
221
|
file = File.join(@config[:output_dir], file)
|
201
222
|
end
|
202
|
-
str = format_turtle(
|
203
|
-
str << format_turtle_inverse(
|
223
|
+
str = format_turtle(uri)
|
224
|
+
str << format_turtle_inverse(uri)
|
204
225
|
open(file, "w") do |io|
|
205
226
|
io.puts str.strip
|
206
227
|
end
|
207
228
|
end
|
229
|
+
progressbar.finish
|
230
|
+
end
|
231
|
+
def uri_mapping_to_path(uri, suffix = ".html")
|
232
|
+
path = nil
|
233
|
+
if @config[:uri_mappings]
|
234
|
+
@config[:uri_mappings].each do |mapping|
|
235
|
+
local_file = uri.sub(@config[:base_uri], "")
|
236
|
+
if mapping["regexp"] =~ local_file
|
237
|
+
path = local_file.sub(mapping["regexp"], mapping["path"])
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
241
|
+
if path.nil?
|
242
|
+
if suffix == ".html"
|
243
|
+
if @data.keys.find{|e| e.start_with?(uri + "/") }
|
244
|
+
path = uri + "/index"
|
245
|
+
elsif uri.end_with?("/")
|
246
|
+
path = uri + "index"
|
247
|
+
else
|
248
|
+
path = uri
|
249
|
+
end
|
250
|
+
else
|
251
|
+
path = uri
|
252
|
+
end
|
253
|
+
end
|
254
|
+
path = path.sub(@config[:base_uri], "")
|
255
|
+
path << suffix
|
256
|
+
#p [uri, path]
|
257
|
+
path
|
208
258
|
end
|
209
259
|
def cleanup
|
210
260
|
@data.select do |uri, v|
|
@@ -212,15 +262,10 @@ module TTL2HTML
|
|
212
262
|
end.sort_by do |uri, v|
|
213
263
|
-(uri.size)
|
214
264
|
end.each do |uri, v|
|
215
|
-
|
216
|
-
file = uri + "/index.html"
|
217
|
-
else
|
218
|
-
file = uri + ".html"
|
219
|
-
end
|
220
|
-
html_file = file.sub(@config[:base_uri], "")
|
265
|
+
html_file = uri_mapping_to_path(uri, ".html")
|
221
266
|
html_file = File.join(@config[:output_dir], html_file) if @config[:output_dir]
|
222
267
|
File.unlink html_file
|
223
|
-
ttl_file = uri
|
268
|
+
ttl_file = uri_mapping_to_path(uri, ".ttl")
|
224
269
|
ttl_file = File.join(@config[:output_dir], ttl_file) if @config[:output_dir]
|
225
270
|
File.unlink ttl_file
|
226
271
|
dir = uri.sub(@config[:base_uri], "")
|
@@ -247,4 +292,4 @@ module TTL2HTML
|
|
247
292
|
file
|
248
293
|
end
|
249
294
|
end
|
250
|
-
end
|
295
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
en:
|
2
|
+
about:
|
3
|
+
title: "About %{title}"
|
4
|
+
The properties for the textbook resources are as follows:
|
5
|
+
shape-note: "The properties for the %{resource} resources are as follows:"
|
6
|
+
default:
|
7
|
+
details: Details
|
8
|
+
inverse_data: Referred resources
|
9
|
+
index:
|
10
|
+
list: "List of %{resource}"
|
11
|
+
layout:
|
12
|
+
rdf-data: RDF data
|
13
|
+
shape-table:
|
14
|
+
header:
|
15
|
+
property-name: "Property name"
|
16
|
+
description: "Description"
|
17
|
+
example: "Example of the property value(s)"
|
18
|
+
required: "Required?"
|
19
|
+
repeatable: "Repeatable?"
|
20
|
+
note: "Notes"
|
21
|
+
required: "Required"
|
22
|
+
repeatable: "Repeatable"
|
23
|
+
optional: "Optional"
|
24
|
+
non-repeatable: "Non repeatable"
|
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:"
|
data/locales/ja.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
ja:
|
2
|
+
about:
|
3
|
+
title: "%{title}について"
|
4
|
+
shape-note: "%{resource}リソースが持つプロパティを下表に示します"
|
5
|
+
default:
|
6
|
+
details: 詳細情報
|
7
|
+
inverse_data: 被参照情報
|
8
|
+
index:
|
9
|
+
list: "%{resource} 一覧"
|
10
|
+
layout:
|
11
|
+
rdf-data: RDFデータ
|
12
|
+
shape-table:
|
13
|
+
header:
|
14
|
+
property-name: プロパティ名
|
15
|
+
description: 説明
|
16
|
+
example: プロパティ値の例
|
17
|
+
required: 必須・省略の別
|
18
|
+
repeatable: 繰り返しの有無
|
19
|
+
note: 備考
|
20
|
+
required: 必須
|
21
|
+
repeatable: 繰り返し有り
|
22
|
+
optional: 省略可能
|
23
|
+
non-repeatable: 繰り返し無し
|
24
|
+
blank-node-structure: ブランクノードの内容は以下の内容からなる構造を持ちます。
|
25
|
+
blank-node-or-structure: ブランクノードの内容は以下のいずれかの内容からなる構造を持ちます。
|
data/templates/about.html.erb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="jumbotron">
|
2
2
|
<div class="container">
|
3
|
-
<h1><%=h param[:site_title]
|
3
|
+
<h1><%=h t("about.title", title: param[:site_title]) %></h1>
|
4
4
|
</div>
|
5
5
|
</div>
|
6
6
|
<div class="container">
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<div class="col-md-12">
|
9
9
|
<ol class="breadcrumb">
|
10
10
|
<li><a href="./"><span class="glyphicon glyphicon-home" aria-hidden="true"></span> Home</a></li>
|
11
|
-
<li class="active"><%=h param[:site_title]
|
11
|
+
<li class="active"><%=h t("about.title", title: param[:site_title]) %></li>
|
12
12
|
</ol>
|
13
13
|
</div>
|
14
14
|
</div>
|
@@ -16,8 +16,9 @@
|
|
16
16
|
<div class="row">
|
17
17
|
<div class="col-md-10">
|
18
18
|
<%- param[:content].keys.sort.each do |shape| -%>
|
19
|
-
<h3><%=h param[:content][shape][:label]
|
20
|
-
<p><%=
|
19
|
+
<h3><%=h param[:content][shape][:label] %></h3>
|
20
|
+
<p><%= param[:content][shape][:comment] %></p>
|
21
|
+
<p><%=h t("about.shape-note", resource: param[:content][shape][:label]) %></p>
|
21
22
|
<%= param[:content][shape][:html] -%>
|
22
23
|
<%- end -%>
|
23
24
|
</div>
|
data/templates/default.html.erb
CHANGED
@@ -7,14 +7,14 @@
|
|
7
7
|
<div class="container">
|
8
8
|
<div class="row">
|
9
9
|
<div class="col-md-12">
|
10
|
-
<h2
|
10
|
+
<h2><%=h t("default.details") %></h2>
|
11
11
|
<%= format_triples(param[:data]) %>
|
12
12
|
</div>
|
13
13
|
</div>
|
14
14
|
<% if param[:data_inverse] %>
|
15
15
|
<div class="row inverse">
|
16
16
|
<div class="col-md-12">
|
17
|
-
<h2
|
17
|
+
<h2><%=h t("default.inverse_data") %></h2>
|
18
18
|
<%= format_triples(param[:data_inverse]) %>
|
19
19
|
</div>
|
20
20
|
</div>
|
data/templates/index.html.erb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<div class="container">
|
8
8
|
<div class="row">
|
9
9
|
<div class="col-md-12">
|
10
|
-
<h2><%=h param[:class_label]
|
10
|
+
<h2><%=h t("index.list", resource: param[:class_label]) %></h2>
|
11
11
|
<ul>
|
12
12
|
<% param[:index_data].each do |e| %>
|
13
13
|
<li><%= format_object(e, param[:data_global]) %></li>
|
data/templates/layout.html.erb
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
<hr>
|
23
23
|
<footer>
|
24
24
|
<%- 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="
|
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>
|
26
26
|
<%- end -%>
|
27
27
|
</footer>
|
28
28
|
|
@@ -1,6 +1,11 @@
|
|
1
1
|
<table class="table table-condensed">
|
2
2
|
<tr>
|
3
|
-
<th
|
3
|
+
<th><%=h t('shape-table.header.property-name') %></th>
|
4
|
+
<th><%=h t('shape-table.header.description') %></th>
|
5
|
+
<th><%=h t('shape-table.header.example') %></th>
|
6
|
+
<th><%=h t('shape-table.header.required') %><br>
|
7
|
+
<%=h t('shape-table.header.repeatable') %></th>
|
8
|
+
<th><%=h t('shape-table.header.note') %></th>
|
4
9
|
</tr>
|
5
10
|
<tbody>
|
6
11
|
<%- param[:properties].each do |property| -%>
|
@@ -10,7 +15,7 @@
|
|
10
15
|
<%- else -%>
|
11
16
|
<td><code><%=h property[:shorten_path] %></code></td>
|
12
17
|
<%- end -%>
|
13
|
-
<td><%= property[:
|
18
|
+
<td><%= property[:name] %></td>
|
14
19
|
<%- if property[:nodeKind] == "http://www.w3.org/ns/shacl#IRI" -%>
|
15
20
|
<td class="url"><%= property[:example] %></td>
|
16
21
|
<%- else -%>
|
@@ -19,31 +24,31 @@
|
|
19
24
|
<td>
|
20
25
|
<div>
|
21
26
|
<%- if property[:required] -%>
|
22
|
-
<strong
|
27
|
+
<strong><%=h t('shape-table.required') %></strong>
|
23
28
|
<%- else -%>
|
24
|
-
|
29
|
+
<%=h t('shape-table.optional') %>
|
25
30
|
<%- end -%>
|
26
31
|
</div>
|
27
32
|
<div>
|
28
33
|
<%- if property[:repeatable] -%>
|
29
|
-
|
34
|
+
<%=h t('shape-table.repeatable') %>
|
30
35
|
<%- else -%>
|
31
|
-
|
36
|
+
<%=h t('shape-table.non-repeatable') %>
|
32
37
|
<%- end -%>
|
33
38
|
</div>
|
34
39
|
</td>
|
35
|
-
<td><%= property[:
|
40
|
+
<td><%= property[:description] %></td>
|
36
41
|
</tr>
|
37
42
|
<%- if property[:nodeKind] == "http://www.w3.org/ns/shacl#BlankNode" -%>
|
38
43
|
<tr>
|
39
44
|
<td colspan="4">
|
40
45
|
<%- if property[:node_mode] == :or -%>
|
41
|
-
|
46
|
+
<%=h t("shape-table.blank-node-or-structure") %>
|
42
47
|
<%- property[:nodes].each do |e| -%>
|
43
48
|
<div class="blank_node"><%= e.sub(/class="table"/, 'class="table table-condensed"') %></div>
|
44
49
|
<%- end -%>
|
45
50
|
<%- else -%>
|
46
|
-
|
51
|
+
<%=h t("shape-table.blank-node-structure") %>
|
47
52
|
<div class="blank_node"><%= property[:nodes].sub(/class="table"/, 'class="table table-condensed"') %></div>
|
48
53
|
<%- end -%>
|
49
54
|
</td>
|
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: 1.2.0
|
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
|
+
date: 2021-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: i18n
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: ruby-progressbar
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +138,8 @@ files:
|
|
124
138
|
- lib/ttl2html/template.rb
|
125
139
|
- lib/ttl2html/version.rb
|
126
140
|
- lib/xlsx2shape.rb
|
141
|
+
- locales/en.yml
|
142
|
+
- locales/ja.yml
|
127
143
|
- templates/about.html.erb
|
128
144
|
- templates/default.html.erb
|
129
145
|
- templates/index.html.erb
|