rdf-rdfa 1.1.6.1 → 1.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +11 -13
- data/VERSION +1 -1
- data/lib/rdf/rdfa/context.rb +3 -3
- data/lib/rdf/rdfa/context/xhtml.rb +26 -26
- data/lib/rdf/rdfa/context/xml.rb +40 -40
- data/lib/rdf/rdfa/expansion.rb +6 -6
- data/lib/rdf/rdfa/format.rb +10 -10
- data/lib/rdf/rdfa/reader.rb +95 -95
- data/lib/rdf/rdfa/reader/nokogiri.rb +1 -1
- data/lib/rdf/rdfa/vocab.rb +0 -187
- data/lib/rdf/rdfa/writer.rb +40 -40
- data/lib/rdf/rdfa/writer/haml_templates.rb +54 -54
- metadata +11 -71
@@ -280,7 +280,7 @@ module RDF::RDFa
|
|
280
280
|
# Document errors
|
281
281
|
def doc_errors
|
282
282
|
# FIXME: Nokogiri version 1.5.5 thinks many HTML5 elements are invalid
|
283
|
-
@doc.errors.reject {|e| e.to_s =~ /(Tag (?:article|aside|audio|canvas|command|datalist|details|embed|figure|footer|header|hgroup|keygen|mark|meter|nav|output|progress|ruby|section|time|video|wbr) invalid|Missing attribute name)/}
|
283
|
+
@doc.errors.reject {|e| e.to_s =~ /(Tag (?:article|aside|audio|canvas|command|datalist|details|embed|figure|footer|header|hgroup|keygen|main|mark|meter|nav|output|progress|ruby|section|time|video|wbr) invalid|Missing attribute name)/}
|
284
284
|
end
|
285
285
|
|
286
286
|
##
|
data/lib/rdf/rdfa/vocab.rb
CHANGED
@@ -1,192 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
module RDF
|
3
|
-
class PTR < Vocabulary("http://www.w3.org/2009/pointers#")
|
4
|
-
# Class definitions
|
5
|
-
term :ByteOffsetCompoundPointer,
|
6
|
-
comment: %(Pointer to a byte range with a defined start and a byte offset from there.).freeze,
|
7
|
-
label: "Byte Offset Compound Pointer".freeze,
|
8
|
-
subClassOf: "ptr:CompoundPointer".freeze,
|
9
|
-
type: "rdfs:Class".freeze
|
10
|
-
term :ByteOffsetPointer,
|
11
|
-
comment: %(Single pointer using a byte offset from the start of the reference.).freeze,
|
12
|
-
label: "Byte Offset Pointer".freeze,
|
13
|
-
subClassOf: "ptr:OffsetPointer".freeze,
|
14
|
-
type: "rdfs:Class".freeze
|
15
|
-
term :ByteSnippetCompoundPointer,
|
16
|
-
comment: %(Pointer to a range with a defined start and a byte snippet from there.).freeze,
|
17
|
-
label: "Byte Snippet Compound Pointer".freeze,
|
18
|
-
subClassOf: "ptr:CompoundPointer".freeze,
|
19
|
-
type: "rdfs:Class".freeze
|
20
|
-
term :CSSSelectorPointer,
|
21
|
-
comment: %(Single pointer using a CSS selector.).freeze,
|
22
|
-
label: "CSS selector Pointer".freeze,
|
23
|
-
subClassOf: "ptr:ExpressionPointer".freeze,
|
24
|
-
type: "rdfs:Class".freeze
|
25
|
-
term :CharOffsetCompoundPointer,
|
26
|
-
comment: %(Pointer to a char range with a defined start and a char offset from there.).freeze,
|
27
|
-
label: "Char Offset Compound Pointer".freeze,
|
28
|
-
subClassOf: "ptr:CompoundPointer".freeze,
|
29
|
-
type: "rdfs:Class".freeze
|
30
|
-
term :CharOffsetPointer,
|
31
|
-
comment: %(Single pointer using a character offset from the start of the reference.).freeze,
|
32
|
-
label: "Char Offset Pointer".freeze,
|
33
|
-
subClassOf: "ptr:OffsetPointer".freeze,
|
34
|
-
type: "rdfs:Class".freeze
|
35
|
-
term :CharSnippetCompoundPointer,
|
36
|
-
comment: %(Pointer to a range with a defined start and a character snippet from there.).freeze,
|
37
|
-
label: "Char Snippet Compound Pointer".freeze,
|
38
|
-
subClassOf: "ptr:CompoundPointer".freeze,
|
39
|
-
type: "rdfs:Class".freeze
|
40
|
-
term :CompoundPointer,
|
41
|
-
comment: %(An abstract method made of a pair of pointers to a defined section to be subclassed for extensibility.).freeze,
|
42
|
-
label: "Compound Pointer".freeze,
|
43
|
-
subClassOf: "ptr:Pointer".freeze,
|
44
|
-
type: "rdfs:Class".freeze
|
45
|
-
term :EquivalentPointers,
|
46
|
-
comment: %(Group of equivalent pointers that point to the same places.).freeze,
|
47
|
-
label: "Equivalent Pointers".freeze,
|
48
|
-
subClassOf: "ptr:PointersGroup".freeze,
|
49
|
-
type: "rdfs:Class".freeze
|
50
|
-
term :ExpressionPointer,
|
51
|
-
comment: %(Generic single pointer that make use of an expression language such as xPath, CSS selectors, etc.).freeze,
|
52
|
-
label: "Expression Pointer".freeze,
|
53
|
-
subClassOf: "ptr:SinglePointer".freeze,
|
54
|
-
type: "rdfs:Class".freeze
|
55
|
-
term :LineCharPointer,
|
56
|
-
comment: %(Single pointer using line and char numbers.).freeze,
|
57
|
-
label: "Line-Char Pointer".freeze,
|
58
|
-
subClassOf: "ptr:SinglePointer".freeze,
|
59
|
-
type: "rdfs:Class".freeze
|
60
|
-
term :OffsetPointer,
|
61
|
-
comment: %(Generic single pointer based on an offset.).freeze,
|
62
|
-
label: "Offset Pointer".freeze,
|
63
|
-
subClassOf: "ptr:SinglePointer".freeze,
|
64
|
-
type: "rdfs:Class".freeze
|
65
|
-
term :Pointer,
|
66
|
-
comment: %(Abstract Pointer to be subclassed for extensibility.).freeze,
|
67
|
-
label: "Pointer".freeze,
|
68
|
-
type: "rdfs:Class".freeze
|
69
|
-
term :PointersGroup,
|
70
|
-
comment: %(Generic container for a group of Pointers).freeze,
|
71
|
-
label: "Pointers Group".freeze,
|
72
|
-
subClassOf: "ptr:Pointer".freeze,
|
73
|
-
type: "rdfs:Class".freeze
|
74
|
-
term :RelatedPointers,
|
75
|
-
comment: %(Group of related pointers you use together for some purpose.).freeze,
|
76
|
-
label: "Related Pointers".freeze,
|
77
|
-
subClassOf: "ptr:PointersGroup".freeze,
|
78
|
-
type: "rdfs:Class".freeze
|
79
|
-
term :SinglePointer,
|
80
|
-
comment: %(Abstract pointer to a single point to be subclassed for extensibility.).freeze,
|
81
|
-
label: "Single Pointer".freeze,
|
82
|
-
subClassOf: "ptr:Pointer".freeze,
|
83
|
-
type: "rdfs:Class".freeze
|
84
|
-
term :StartEndPointer,
|
85
|
-
comment: %(Compound pointer to a range with a start and an end point.).freeze,
|
86
|
-
label: "Start-End Pointer".freeze,
|
87
|
-
subClassOf: "ptr:CompoundPointer".freeze,
|
88
|
-
type: "rdfs:Class".freeze
|
89
|
-
term :XMLNamespace,
|
90
|
-
comment: %(An XML Namespace.).freeze,
|
91
|
-
label: "XMLNamespace".freeze,
|
92
|
-
type: "rdfs:Class".freeze
|
93
|
-
term :XPathPointer,
|
94
|
-
comment: %(Single pointer using an XPath expression.).freeze,
|
95
|
-
label: "XPath Pointer".freeze,
|
96
|
-
subClassOf: "ptr:ExpressionPointer".freeze,
|
97
|
-
type: "rdfs:Class".freeze
|
98
|
-
term :XPointerPointer,
|
99
|
-
comment: %(Single pointer using an XPointer expression.).freeze,
|
100
|
-
label: "XPointer Pointer".freeze,
|
101
|
-
subClassOf: "ptr:XPathPointer".freeze,
|
102
|
-
type: "rdfs:Class".freeze
|
103
|
-
|
104
|
-
# Property definitions
|
105
|
-
property :byteOffset,
|
106
|
-
comment: %(Number of bytes counting from the start point.).freeze,
|
107
|
-
domain: "ptr:ByteOffsetCompoundPointer".freeze,
|
108
|
-
label: "byte offset".freeze,
|
109
|
-
range: "xsd:positiveInteger".freeze,
|
110
|
-
type: "rdf:Property".freeze
|
111
|
-
property :charNumber,
|
112
|
-
comment: %(Char number within a line starting at one.
|
113
|
-
).freeze,
|
114
|
-
domain: "ptr:LineCharPointer".freeze,
|
115
|
-
label: "char number".freeze,
|
116
|
-
range: "xsd:positiveInteger".freeze,
|
117
|
-
type: "rdf:Property".freeze
|
118
|
-
property :charOffset,
|
119
|
-
comment: %(Number of characters counting from the start point.).freeze,
|
120
|
-
domain: "ptr:CharOffsetCompoundPointer".freeze,
|
121
|
-
label: "char offset".freeze,
|
122
|
-
range: "xsd:positiveInteger".freeze,
|
123
|
-
type: "rdf:Property".freeze
|
124
|
-
property :endPointer,
|
125
|
-
comment: %(Pointer to the end point of the range.).freeze,
|
126
|
-
domain: "ptr:StartEndPointer".freeze,
|
127
|
-
label: "end pointer".freeze,
|
128
|
-
range: "ptr:SinglePointer".freeze,
|
129
|
-
type: "rdf:Property".freeze
|
130
|
-
property :expression,
|
131
|
-
comment: %(Expressions, such as xPath or CSS selectors, that identify points.).freeze,
|
132
|
-
domain: "ptr:ExpressionPointer".freeze,
|
133
|
-
label: "expression".freeze,
|
134
|
-
range: "rdfs:Literal".freeze,
|
135
|
-
type: "rdf:Property".freeze
|
136
|
-
property :groupPointer,
|
137
|
-
comment: %(A Pointer that is part of a Group).freeze,
|
138
|
-
domain: "ptr:PointersGroup".freeze,
|
139
|
-
label: "groupPointer".freeze,
|
140
|
-
range: "ptr:Pointer".freeze,
|
141
|
-
type: "rdf:Property".freeze
|
142
|
-
property :lineNumber,
|
143
|
-
comment: %(Line number within the reference starting at one.
|
144
|
-
).freeze,
|
145
|
-
domain: "ptr:LineCharPointer".freeze,
|
146
|
-
label: "line number".freeze,
|
147
|
-
range: "xsd:positiveInteger".freeze,
|
148
|
-
type: "rdf:Property".freeze
|
149
|
-
property :namespace,
|
150
|
-
comment: %(The namespace being used for the XPath expression.).freeze,
|
151
|
-
domain: "ptr:XPathPointer".freeze,
|
152
|
-
label: "namespace".freeze,
|
153
|
-
range: "ptr:XMLNamespace".freeze,
|
154
|
-
type: "rdf:Property".freeze
|
155
|
-
property :namespaceName,
|
156
|
-
comment: %(The namespace name being used for an XML Namespace.).freeze,
|
157
|
-
domain: "ptr:XMLNamespace".freeze,
|
158
|
-
label: "namespace name".freeze,
|
159
|
-
type: "rdf:Property".freeze
|
160
|
-
property :offset,
|
161
|
-
comment: %(Offset from the start of the reference.).freeze,
|
162
|
-
domain: "ptr:OffsetPointer".freeze,
|
163
|
-
label: "offset".freeze,
|
164
|
-
range: "xsd:positiveInteger".freeze,
|
165
|
-
type: "rdf:Property".freeze
|
166
|
-
property :prefix,
|
167
|
-
comment: %(The namespace prefix being used for an XML Namespace.).freeze,
|
168
|
-
domain: "ptr:XMLNamespace".freeze,
|
169
|
-
label: "prefix".freeze,
|
170
|
-
type: "rdf:Property".freeze
|
171
|
-
property :reference,
|
172
|
-
comment: %(Scope within which a single pointer operates.).freeze,
|
173
|
-
domain: "ptr:SinglePointer".freeze,
|
174
|
-
label: "reference".freeze,
|
175
|
-
type: "rdf:Property".freeze
|
176
|
-
property :startPointer,
|
177
|
-
comment: %(Pointer to the start point of the range in a compound pointer.).freeze,
|
178
|
-
domain: "ptr:CompoundPointer".freeze,
|
179
|
-
label: "start pointer".freeze,
|
180
|
-
range: "ptr:SinglePointer".freeze,
|
181
|
-
type: "rdf:Property".freeze
|
182
|
-
property :version,
|
183
|
-
comment: %(Version for the expression language being used.).freeze,
|
184
|
-
domain: "ptr:ExpressionPointer".freeze,
|
185
|
-
label: "version".freeze,
|
186
|
-
range: "rdfs:Literal".freeze,
|
187
|
-
type: "rdf:Property".freeze
|
188
|
-
end
|
189
|
-
|
190
3
|
class RDFA < Vocabulary("http://www.w3.org/ns/rdfa#")
|
191
4
|
# Class definitions
|
192
5
|
__property__ :DocumentError,
|
data/lib/rdf/rdfa/writer.rb
CHANGED
@@ -13,10 +13,10 @@ module RDF::RDFa
|
|
13
13
|
# @example Obtaining a RDFa writer class
|
14
14
|
# RDF::Writer.for(:html) => RDF::RDFa::Writer
|
15
15
|
# RDF::Writer.for("etc/test.html")
|
16
|
-
# RDF::Writer.for(:
|
17
|
-
# RDF::Writer.for(:
|
18
|
-
# RDF::Writer.for(:
|
19
|
-
# RDF::Writer.for(:
|
16
|
+
# RDF::Writer.for(file_name: "etc/test.html")
|
17
|
+
# RDF::Writer.for(file_extension: "html")
|
18
|
+
# RDF::Writer.for(content_type: "application/xhtml+xml")
|
19
|
+
# RDF::Writer.for(content_type: "text/html")
|
20
20
|
#
|
21
21
|
# @example Serializing RDF graph into an XHTML+RDFa file
|
22
22
|
# RDF::RDFa::Write.open("etc/test.html") do |writer|
|
@@ -38,8 +38,8 @@ module RDF::RDFa
|
|
38
38
|
# end
|
39
39
|
#
|
40
40
|
# @example Creating @base and @prefix definitions in output
|
41
|
-
# RDF::RDFa::Writer.buffer(:
|
42
|
-
# :
|
41
|
+
# RDF::RDFa::Writer.buffer(base_uri: "http://example.com/", prefixes: {
|
42
|
+
# foaf: "http://xmlns.com/foaf/0.1/"}
|
43
43
|
# ) do |writer|
|
44
44
|
# graph.each_statement do |statement|
|
45
45
|
# writer << statement
|
@@ -63,7 +63,7 @@ module RDF::RDFa
|
|
63
63
|
attr :heading_predicates
|
64
64
|
|
65
65
|
HAML_OPTIONS = {
|
66
|
-
:
|
66
|
+
ugly: false, # to preserve whitespace without using entities
|
67
67
|
}
|
68
68
|
|
69
69
|
# @return [Graph] Graph of statements serialized
|
@@ -93,13 +93,13 @@ module RDF::RDFa
|
|
93
93
|
# Add standard prefixes to _prefixes_, if necessary.
|
94
94
|
# @option options [Array<RDF::URI>] :top_classes ([RDF::RDFS.Class])
|
95
95
|
# Defines rdf:type of subjects to be emitted at the beginning of the document.
|
96
|
-
# @option options [Array<RDF::URI>] :predicate_order ([RDF.type, RDF::RDFS.label, RDF::DC.title])
|
96
|
+
# @option options [Array<RDF::URI>] :predicate_order ([RDF.type, RDF::RDFS.label, RDF::Vocab::DC.title])
|
97
97
|
# Defines order of predicates to to emit at begninning of a resource description..
|
98
|
-
# @option options [Array<RDF::URI>] :heading_predicates ([RDF::RDFS.label, RDF::DC.title])
|
98
|
+
# @option options [Array<RDF::URI>] :heading_predicates ([RDF::RDFS.label, RDF::Vocab::DC.title])
|
99
99
|
# Defines order of predicates to use in heading.
|
100
100
|
# @option options [String, Symbol, Hash{Symbol => String}] :haml (DEFAULT_HAML) HAML templates used for generating code
|
101
101
|
# @option options [Hash] :haml_options (HAML_OPTIONS)
|
102
|
-
# Options to pass to Haml::Engine.new. Default options set
|
102
|
+
# Options to pass to Haml::Engine.new. Default options set `ugly: false` to ensure that whitespace in literals with newlines is properly preserved.
|
103
103
|
# @yield [writer]
|
104
104
|
# @yieldparam [RDF::Writer] writer
|
105
105
|
def initialize(output = $stdout, options = {}, &block)
|
@@ -107,8 +107,8 @@ module RDF::RDFa
|
|
107
107
|
@uri_to_term_or_curie = {}
|
108
108
|
@uri_to_prefix = {}
|
109
109
|
@top_classes = options[:top_classes] || [RDF::RDFS.Class]
|
110
|
-
@predicate_order = options[:predicate_order] || [RDF.type, RDF::RDFS.label, RDF::
|
111
|
-
@heading_predicates = options[:heading_predicates] || [RDF::RDFS.label, RDF::
|
110
|
+
@predicate_order = options[:predicate_order] || [RDF.type, RDF::RDFS.label, RDF::URI("http://purl.org/dc/terms/title")]
|
111
|
+
@heading_predicates = options[:heading_predicates] || [RDF::RDFS.label, RDF::URI("http://purl.org/dc/terms/title")]
|
112
112
|
@graph = RDF::Graph.new
|
113
113
|
|
114
114
|
block.call(self) if block_given?
|
@@ -181,7 +181,7 @@ module RDF::RDFa
|
|
181
181
|
doc_title = nil
|
182
182
|
titles = {}
|
183
183
|
heading_predicates.each do |pred|
|
184
|
-
@graph.query(:
|
184
|
+
@graph.query(predicate: pred) do |statement|
|
185
185
|
titles[statement.subject] ||= statement.object
|
186
186
|
end
|
187
187
|
end
|
@@ -190,10 +190,10 @@ module RDF::RDFa
|
|
190
190
|
|
191
191
|
# Generate document
|
192
192
|
doc = render_document(subjects,
|
193
|
-
:
|
194
|
-
:
|
195
|
-
:
|
196
|
-
:
|
193
|
+
lang: @lang,
|
194
|
+
base: base_uri,
|
195
|
+
title: doc_title,
|
196
|
+
prefix: prefix) do |s|
|
197
197
|
subject(s)
|
198
198
|
end
|
199
199
|
@output.write(doc)
|
@@ -227,9 +227,9 @@ module RDF::RDFa
|
|
227
227
|
def render_document(subjects, options = {})
|
228
228
|
template = options[:haml] || :doc
|
229
229
|
options = {
|
230
|
-
:
|
231
|
-
:
|
232
|
-
:
|
230
|
+
prefix: nil,
|
231
|
+
subjects: subjects,
|
232
|
+
title: nil,
|
233
233
|
}.merge(options)
|
234
234
|
hamlify(template, options) do |subject|
|
235
235
|
yield(subject) if block_given?
|
@@ -272,15 +272,15 @@ module RDF::RDFa
|
|
272
272
|
def render_subject(subject, predicates, options = {})
|
273
273
|
template = options[:haml] || :subject
|
274
274
|
options = {
|
275
|
-
:
|
276
|
-
:
|
277
|
-
:
|
278
|
-
:
|
279
|
-
:
|
280
|
-
:
|
281
|
-
:
|
282
|
-
:
|
283
|
-
:
|
275
|
+
about: (get_curie(subject) unless options[:rel]),
|
276
|
+
base: base_uri,
|
277
|
+
element: nil,
|
278
|
+
predicates: predicates,
|
279
|
+
rel: nil,
|
280
|
+
inlist: nil,
|
281
|
+
resource: (get_curie(subject) if options[:rel]),
|
282
|
+
subject: subject,
|
283
|
+
typeof: nil,
|
284
284
|
}.merge(options)
|
285
285
|
hamlify(template, options) do |predicate|
|
286
286
|
yield(predicate) if block_given?
|
@@ -331,7 +331,7 @@ module RDF::RDFa
|
|
331
331
|
|
332
332
|
add_debug {"list: #{list.inspect} #{list.to_a}"}
|
333
333
|
depth do
|
334
|
-
render_property(predicate, list.to_a, options.merge(:
|
334
|
+
render_property(predicate, list.to_a, options.merge(inlist: "true")) do |object|
|
335
335
|
yield(object, true) if block_given?
|
336
336
|
end
|
337
337
|
end
|
@@ -352,12 +352,12 @@ module RDF::RDFa
|
|
352
352
|
:property_values :
|
353
353
|
:property_value)
|
354
354
|
options = {
|
355
|
-
:
|
356
|
-
:
|
357
|
-
:
|
358
|
-
:
|
359
|
-
:
|
360
|
-
:
|
355
|
+
objects: objects,
|
356
|
+
object: objects.first,
|
357
|
+
predicate: predicate,
|
358
|
+
property: get_curie(predicate),
|
359
|
+
rel: get_curie(predicate),
|
360
|
+
inlist: nil,
|
361
361
|
}.merge(options)
|
362
362
|
hamlify(template, options, &block)
|
363
363
|
end
|
@@ -410,7 +410,7 @@ module RDF::RDFa
|
|
410
410
|
top_classes.
|
411
411
|
select {|s| !seen.include?(s)}.
|
412
412
|
each do |class_uri|
|
413
|
-
graph.query(:
|
413
|
+
graph.query(predicate: RDF.type, object: class_uri).map {|st| st.subject}.sort.uniq.each do |subject|
|
414
414
|
#add_debug {"order_subjects: #{subject.inspect}"}
|
415
415
|
subjects << subject
|
416
416
|
seen[subject] = true
|
@@ -505,7 +505,7 @@ module RDF::RDFa
|
|
505
505
|
|
506
506
|
add_debug {"props: #{prop_list.inspect}"}
|
507
507
|
|
508
|
-
render_opts = {:
|
508
|
+
render_opts = {typeof: typeof, property_values: properties}.merge(options)
|
509
509
|
|
510
510
|
render_subject_template(subject, prop_list, render_opts)
|
511
511
|
end
|
@@ -514,7 +514,7 @@ module RDF::RDFa
|
|
514
514
|
# @return [Hash{String => Object}]
|
515
515
|
def properties_for_subject(subject)
|
516
516
|
properties = {}
|
517
|
-
@graph.query(:
|
517
|
+
@graph.query(subject: subject) do |st|
|
518
518
|
key = st.predicate.to_s.freeze
|
519
519
|
properties[key] ||= []
|
520
520
|
properties[key] << st.object
|
@@ -587,7 +587,7 @@ module RDF::RDFa
|
|
587
587
|
render_property(predicate, objects) do |o, inlist=nil|
|
588
588
|
# Yields each object, for potential recursive definition.
|
589
589
|
# If nil is returned, a leaf is produced
|
590
|
-
depth {subject(o, :
|
590
|
+
depth {subject(o, rel: get_curie(predicate), inlist: inlist, element: (:li if objects.length > 1 || inlist))} if !is_done?(o) && @subjects.include?(o)
|
591
591
|
end
|
592
592
|
end
|
593
593
|
|
@@ -3,18 +3,18 @@ module RDF::RDFa
|
|
3
3
|
class Writer
|
4
4
|
# The default set of HAML templates used for RDFa code generation
|
5
5
|
BASE_HAML = {
|
6
|
-
:
|
6
|
+
identifier: "base",
|
7
7
|
# Document
|
8
8
|
# Locals: language, title, prefix, base, subjects
|
9
9
|
# Yield: subjects.each
|
10
|
-
:
|
10
|
+
doc: %q(
|
11
11
|
!!! XML
|
12
12
|
!!! 5
|
13
|
-
%html{:
|
13
|
+
%html{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}
|
14
14
|
- if base || title
|
15
15
|
%head
|
16
16
|
- if base
|
17
|
-
%base{:
|
17
|
+
%base{href: base}
|
18
18
|
- if title
|
19
19
|
%title= title
|
20
20
|
%body
|
@@ -31,15 +31,15 @@ module RDF::RDFa
|
|
31
31
|
#
|
32
32
|
# Locals: subject, typeof, predicates, rel, element, inlist
|
33
33
|
# Yield: predicates.each
|
34
|
-
:
|
34
|
+
subject: %q(
|
35
35
|
- if element == :li
|
36
|
-
%li{:
|
36
|
+
%li{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
|
37
37
|
- if typeof
|
38
38
|
%span.type!= typeof
|
39
39
|
- predicates.each do |predicate|
|
40
40
|
!= yield(predicate)
|
41
41
|
- else
|
42
|
-
%div{:
|
42
|
+
%div{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
|
43
43
|
- if typeof
|
44
44
|
%span.type!= typeof
|
45
45
|
- predicates.each do |predicate|
|
@@ -51,9 +51,9 @@ module RDF::RDFa
|
|
51
51
|
# Yields: object
|
52
52
|
# If nil is returned, render as a leaf
|
53
53
|
# Otherwise, render result
|
54
|
-
:
|
54
|
+
property_value: %q(
|
55
55
|
- if heading_predicates.include?(predicate) && object.literal?
|
56
|
-
%h1{:
|
56
|
+
%h1{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
|
57
57
|
- else
|
58
58
|
%div.property
|
59
59
|
%span.label
|
@@ -61,21 +61,21 @@ module RDF::RDFa
|
|
61
61
|
- if res = yield(object)
|
62
62
|
!= res
|
63
63
|
- elsif get_curie(object) == 'rdf:nil'
|
64
|
-
%span{:
|
64
|
+
%span{rel: get_curie(predicate), inlist: ''}
|
65
65
|
- elsif object.node?
|
66
|
-
%span{:
|
66
|
+
%span{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
|
67
67
|
- elsif object.uri?
|
68
|
-
%a{:
|
68
|
+
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
|
69
69
|
- elsif object.datatype == RDF.XMLLiteral
|
70
|
-
%span{:
|
70
|
+
%span{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}<!= get_value(object)
|
71
71
|
- else
|
72
|
-
%span{:
|
72
|
+
%span{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
|
73
73
|
),
|
74
74
|
|
75
75
|
# Output for multi-valued properties
|
76
76
|
# Locals: predicate, :objects, :inlist
|
77
77
|
# Yields: object for leaf resource rendering
|
78
|
-
:
|
78
|
+
property_values: %q(
|
79
79
|
%div.property
|
80
80
|
%span.label
|
81
81
|
= get_predicate_name(predicate)
|
@@ -84,14 +84,14 @@ module RDF::RDFa
|
|
84
84
|
- if res = yield(object)
|
85
85
|
!= res
|
86
86
|
- elsif object.node?
|
87
|
-
%li{:
|
87
|
+
%li{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
|
88
88
|
- elsif object.uri?
|
89
89
|
%li
|
90
|
-
%a{:
|
90
|
+
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
|
91
91
|
- elsif object.datatype == RDF.XMLLiteral
|
92
|
-
%li{:
|
92
|
+
%li{property: get_curie(predicate), lang: get_lang(object), datatype: get_curie(object.datatype), inlist: inlist}<!= get_value(object)
|
93
93
|
- else
|
94
|
-
%li{:
|
94
|
+
%li{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
|
95
95
|
),
|
96
96
|
}
|
97
97
|
|
@@ -99,17 +99,17 @@ module RDF::RDFa
|
|
99
99
|
# This version does not perform recursive object generation and does not attempt
|
100
100
|
# to create human readable output.
|
101
101
|
MIN_HAML = {
|
102
|
-
:
|
102
|
+
identifier: "min",
|
103
103
|
# Document
|
104
104
|
# Locals: language, title, prefix, base, subjects
|
105
105
|
# Yield: subjects.each
|
106
|
-
:
|
106
|
+
doc: %q(
|
107
107
|
!!! XML
|
108
108
|
!!! 5
|
109
|
-
%html{:
|
109
|
+
%html{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}
|
110
110
|
- if base
|
111
111
|
%head
|
112
|
-
%base{:
|
112
|
+
%base{href: base}
|
113
113
|
%body
|
114
114
|
- subjects.each do |subject|
|
115
115
|
!= yield(subject)
|
@@ -120,8 +120,8 @@ module RDF::RDFa
|
|
120
120
|
#
|
121
121
|
# Locals: about, typeof, predicates, :inlist
|
122
122
|
# Yield: predicates.each
|
123
|
-
:
|
124
|
-
%div{:
|
123
|
+
subject: %q(
|
124
|
+
%div{rel: rel, resource: (about || resource), typeof: typeof}
|
125
125
|
- predicates.each do |predicate|
|
126
126
|
!= yield(predicate)
|
127
127
|
),
|
@@ -132,40 +132,40 @@ module RDF::RDFa
|
|
132
132
|
# Yields: object
|
133
133
|
# If nil is returned, render as a leaf
|
134
134
|
# Otherwise, render result
|
135
|
-
:
|
135
|
+
property_value: %q(
|
136
136
|
- if res = yield(object)
|
137
137
|
!= res
|
138
138
|
- elsif get_curie(object) == 'rdf:nil'
|
139
|
-
%span{:
|
139
|
+
%span{rel: get_curie(predicate), inlist: ''}
|
140
140
|
- elsif object.node?
|
141
|
-
%span{:
|
141
|
+
%span{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
|
142
142
|
- elsif object.uri?
|
143
|
-
%a{:
|
143
|
+
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
|
144
144
|
- elsif object.datatype == RDF.XMLLiteral
|
145
|
-
%span{:
|
145
|
+
%span{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}<!= get_value(object)
|
146
146
|
- else
|
147
|
-
%span{:
|
147
|
+
%span{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
|
148
148
|
)
|
149
149
|
}
|
150
150
|
|
151
151
|
DISTILLER_HAML = {
|
152
|
-
:
|
152
|
+
identifier: "distiller",
|
153
153
|
# Document
|
154
154
|
# Locals: language, title, prefix, base, subjects
|
155
155
|
# Yield: subjects.each
|
156
|
-
:
|
156
|
+
doc: %q(
|
157
157
|
!!! XML
|
158
158
|
!!! 5
|
159
|
-
%html{:
|
159
|
+
%html{xmlns: "http://www.w3.org/1999/xhtml", lang: lang, prefix: prefix}
|
160
160
|
- if base || title
|
161
161
|
%head
|
162
162
|
- if base
|
163
|
-
%base{:
|
163
|
+
%base{href: base}
|
164
164
|
- if title
|
165
165
|
%title= title
|
166
|
-
%link{:
|
167
|
-
%script{:
|
168
|
-
%script{:
|
166
|
+
%link{rel: "stylesheet", href: "http://rdf.kellogg-assoc.com/css/distiller.css", type: "text/css"}
|
167
|
+
%script{src: "https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js", type: "text/javascript"}
|
168
|
+
%script{src: "http://rdf.kellogg-assoc.com/js/distiller.js", type: "text/javascript"}
|
169
169
|
%body
|
170
170
|
- if base
|
171
171
|
%p= "RDFa serialization URI base: <#{base}>"
|
@@ -187,16 +187,16 @@ module RDF::RDFa
|
|
187
187
|
#
|
188
188
|
# Locals: subject, typeof, predicates, rel, element, inlist
|
189
189
|
# Yield: predicates.each
|
190
|
-
:
|
190
|
+
subject: %q(
|
191
191
|
- if element == :li
|
192
|
-
%li{:
|
192
|
+
%li{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
|
193
193
|
- if typeof
|
194
194
|
%span.type!= typeof
|
195
195
|
%table.properties
|
196
196
|
- predicates.each do |predicate|
|
197
197
|
!= yield(predicate)
|
198
198
|
- else
|
199
|
-
%td{:
|
199
|
+
%td{rel: rel, resource: (about || resource), typeof: typeof, inlist: inlist}
|
200
200
|
- if typeof
|
201
201
|
%span.type!= typeof
|
202
202
|
%table.properties
|
@@ -209,9 +209,9 @@ module RDF::RDFa
|
|
209
209
|
# Yields: object
|
210
210
|
# If nil is returned, render as a leaf
|
211
211
|
# Otherwise, render result
|
212
|
-
:
|
212
|
+
property_value: %q(
|
213
213
|
- if heading_predicates.include?(predicate) && object.literal?
|
214
|
-
%h1{:
|
214
|
+
%h1{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
|
215
215
|
- else
|
216
216
|
%tr.property
|
217
217
|
%td.label
|
@@ -219,22 +219,22 @@ module RDF::RDFa
|
|
219
219
|
- if res = yield(object)
|
220
220
|
!= res
|
221
221
|
- elsif get_curie(object) == 'rdf:nil'
|
222
|
-
%td{:
|
222
|
+
%td{rel: get_curie(predicate), inlist: ''}= "Empty"
|
223
223
|
- elsif object.node?
|
224
|
-
%td{:
|
224
|
+
%td{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
|
225
225
|
- elsif object.uri?
|
226
226
|
%td
|
227
|
-
%a{:
|
227
|
+
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
|
228
228
|
- elsif object.datatype == RDF.XMLLiteral
|
229
|
-
%td{:
|
229
|
+
%td{property: get_curie(predicate), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}<!= get_value(object)
|
230
230
|
- else
|
231
|
-
%td{:
|
231
|
+
%td{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
|
232
232
|
),
|
233
233
|
|
234
234
|
# Output for multi-valued properties
|
235
235
|
# Locals: predicate, objects, inliste
|
236
236
|
# Yields: object for leaf resource rendering
|
237
|
-
:
|
237
|
+
property_values: %q(
|
238
238
|
%tr.property
|
239
239
|
%td.label
|
240
240
|
= get_predicate_name(predicate)
|
@@ -244,17 +244,17 @@ module RDF::RDFa
|
|
244
244
|
- if res = yield(object)
|
245
245
|
!= res
|
246
246
|
- elsif object.node?
|
247
|
-
%li{:
|
247
|
+
%li{property: get_curie(predicate), resource: get_curie(object), inlist: inlist}= get_curie(object)
|
248
248
|
- elsif object.uri?
|
249
249
|
%li
|
250
|
-
%a{:
|
250
|
+
%a{property: get_curie(predicate), href: object.to_s, inlist: inlist}= object.to_s
|
251
251
|
- elsif object.datatype == RDF.XMLLiteral
|
252
|
-
%li{:
|
252
|
+
%li{property: get_curie(predicate), lang: get_lang(object), datatype: get_curie(object.datatype), inlist: inlist}<!= get_value(object)
|
253
253
|
- else
|
254
|
-
%li{:
|
254
|
+
%li{property: get_curie(predicate), content: get_content(object), lang: get_lang(object), datatype: get_dt_curie(object), inlist: inlist}= escape_entities(get_value(object))
|
255
255
|
),
|
256
256
|
}
|
257
|
-
HAML_TEMPLATES = {:
|
257
|
+
HAML_TEMPLATES = {base: BASE_HAML, min: MIN_HAML, distiller: DISTILLER_HAML}
|
258
258
|
DEFAULT_HAML = BASE_HAML
|
259
259
|
end
|
260
260
|
end
|