Skip to content

Commit 5825737

Browse files
committed
Merge pull request #31 from w3c/index-update
Index update
2 parents 529c915 + b0b723f commit 5825737

File tree

160 files changed

+69973
-7737
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

160 files changed

+69973
-7737
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# rdf-tests
22
Repository for the RDF Tests Community Group
33

4-
See the [gh-pages](https://w3c.github.io/rdf-tests) branch for the main contents.
4+
See the [gh-pages](https://w3c.github.io/rdf-tests) branch for the main contents.
5+
6+
The index.html files are built using a Ruby tool-chain based on the corresponding manifest.ttl files. Update using `rake`. Requires Ruby, rdf-turtle and json-ld gems to be installed.

Rakefile

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Build generated files
2+
require 'rdf/turtle'
3+
require 'json/ld'
4+
require 'haml'
5+
6+
task default: :index
7+
8+
MANIFESTS = Dir.glob("**/manifest*.ttl")
9+
10+
desc "Build HTML manifests"
11+
task index: MANIFESTS.
12+
select {|m| File.exist?(m)}.
13+
map {|m| m.sub(/manifest(.*)\.ttl$/, 'index\1.html')}
14+
15+
MANIFESTS.each do |ttl|
16+
html = ttl.sub(/manifest(.*)\.ttl$/, 'index\1.html')
17+
18+
# Find frame closest to file
19+
frame, template = nil, nil
20+
Pathname.new(ttl).ascend do |p|
21+
f = File.join(p, 'manifest-frame.jsonld')
22+
frame ||= f if File.exist?(f)
23+
24+
t = File.join(p, 'template.haml')
25+
template ||= t if File.exist?(t)
26+
end
27+
frame ||= 'manifest-frame.jsonld'
28+
29+
if template
30+
desc "Build #{html}"
31+
file html => [ttl, frame, template] do
32+
puts "Genrate #{html}"
33+
temp, man = File.read(template), nil
34+
35+
RDF::Reader.open(ttl) do |reader|
36+
out = JSON::LD::Writer.buffer(frame: frame, simple_compact_iris: true) do |writer|
37+
writer << reader
38+
end
39+
40+
man = JSON.parse(out)
41+
if man['@graph'].is_a?(Array) && man['@graph'].length == 1
42+
# Remove '@graph'
43+
man['@graph'][0].each do |k, v|
44+
man[k] = v
45+
end
46+
man.delete('@graph')
47+
48+
# Remove nil 'entries'
49+
man.delete('mf:entries') if man['mf:entries'].nil?
50+
51+
# Fix up test entries
52+
Array(man['entries']).each do |entry|
53+
# Fix results which aren't IRIs
54+
if res = entry['mf:result'] && entry['mf:result']['@value']
55+
entry.delete('mf:result')
56+
entry['result'] = res == 'true'
57+
end
58+
59+
# Fix some empty arrays (rdf-mt)
60+
%w(recognizedDatatypes unrecognizedDatatypes).each do |p|
61+
if entry["mf:#{p}"].is_a?(Hash) && entry["mf:#{p}"]['@list'] == []
62+
entry[p] = []
63+
entry.delete("mf:#{p}")
64+
end
65+
end
66+
end
67+
else
68+
Kernel.abort "Expected manifest to have a single @graph entry"
69+
end
70+
end
71+
72+
File.open(html, "w") do |f|
73+
f.write Haml::Engine.new(temp, format: :html5).
74+
render(self,
75+
man: man,
76+
ttl: ttl.split('/').last
77+
)
78+
end
79+
end
80+
end
81+
end

manifest-frame.jsonld

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"@context": {
3+
"xsd": "http://www.w3.org/2001/XMLSchema#",
4+
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
5+
"mf": "http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#",
6+
"mq": "http://www.w3.org/2001/sw/DataAccess/tests/test-query#",
7+
"rdft": "http://www.w3.org/ns/rdftest#",
8+
9+
"action": {"@id": "mf:action", "@type": "@id"},
10+
"approval": {"@id": "rdft:approval", "@type": "@id"},
11+
"comment": "rdfs:comment",
12+
"entries": {"@id": "mf:entries", "@container": "@list", "@type": "@id"},
13+
"include": {"@id": "mf:include", "@container": "@list", "@type": "@id"},
14+
"label": "rdfs:label",
15+
"name": "mf:name",
16+
"result": {"@id": "mf:result", "@type": "@id"}
17+
},
18+
"@type": "mf:Manifest",
19+
"entries": {"@embed": true}
20+
}

0 commit comments

Comments
 (0)