diff --git a/ShacShifter/JekyllRDFSerializer.py b/ShacShifter/JekyllRDFSerializer.py
index 94f937a..6d524a5 100644
--- a/ShacShifter/JekyllRDFSerializer.py
+++ b/ShacShifter/JekyllRDFSerializer.py
@@ -1,7 +1,7 @@
import logging
+import uuid
-
-# example class for
+# example class for Jekyll-RDF
class JekyllRDFSerializer:
"""A Serializer that writes Template for JekyllRDF"""
@@ -21,8 +21,9 @@ def __init__(self, shapes, outputfile):
\n")
+ self.content.append("""{% assign type = page.rdf | rdf_property: "" %}\n""")
nodeShapes = shapes[0]
for nodeShape in nodeShapes:
@@ -46,34 +47,28 @@ def nodeShapeEvaluation(self, nodeShape, fp):
args: nodeShape a nodeShape object
fp
"""
- self.logger.debug(
- 'This Resource needs to be in the following classes'
- + '(can be used through rdfa annotation?):'
- )
if len(nodeShape.targetClass) > 1:
self.content.append("Uebersicht")
for tClass in nodeShape.targetClass:
self.content.append(
- '
\n\n".format(
resource=nodeShape.targetClass[0].rsplit('/', 1)[-1], type=nodeShape.targetClass[0]))
- self.content.append(
- '{{% assign {resource} = page.rdf | rdf_property: "<{type}>" %}} '.format(
- type=nodeShape.targetClass[0], resource=nodeShape.targetClass[0].rsplit('/', 1)[-1]))
for nodes in nodeShape.targetNode:
self.logger.debug(nodes)
self.logger.debug(
'The following ressources need to be Objects of those predicates'
- + '(can be used through rdfa annotation?):'
)
-
+
for nodes in nodeShape.targetObjectsOf:
self.logger.debug(nodes)
@@ -83,10 +78,21 @@ def nodeShapeEvaluation(self, nodeShape, fp):
for property in nodeShape.properties:
shapeName = nodeShape.targetClass[0].rsplit('/', 1)[-1]
content = self.propertyShapeEvaluation(property, fp, shapeName)
+
self.content.append(content)
+ resource_hack = nodeShape.targetClass[0].rsplit('/', 1)[-1]
+ self.content.append(
+ '{{% assign {resource} = page.rdf | rdf_property: "<{type}/{resource}>", nil, true %}} \n'.format(
+ type=nodeShape.targetClass[0].rsplit('/', 1)[-2], resource=resource_hack.lower()))
+ self.content.append('\n{{% for {instance}_instance in {resource} %}}\n
{{{{ {instance}_instance.iri }}}}
\n'.format(
+ instance=nodeShape.targetClass[0].rsplit('/', 1)[-1].lower(), resource=resource_hack.lower()))
+
+ if len(nodeShape.targetClass) == 1:
+ self.content.append("\n{% endfor %}\n{% endif %}\n")
+
def propertyShapeEvaluation(self, propertyShape, fp, shapeName):
- """Evaluate a propertyShape and return HTML.
+ """Evaluate propertyShape and return HTML.
args: propertyShape a propertyShape object
fp
@@ -102,38 +108,27 @@ def propertyShapeEvaluation(self, propertyShape, fp, shapeName):
self.logger.info('Sequence path not supported, yet')
else:
uri = propertyShape.path
- label = propertyShape.name \
- if propertyShape.isSet['name'] else propertyShape.path.rsplit('/', 1)[-1]
+ lowercase_str = uuid.uuid4().hex[:4]
+ label_jekyll = propertyShape.name.lower() \
+ if propertyShape.isSet['name'] else propertyShape.path.lower().rsplit('/', 1)[-1]
+ label_jekyll += "_"+ lowercase_str
+ label = propertyShape.name.lower() \
+ if propertyShape.isSet['name'] else propertyShape.path.lower().rsplit('/', 1)[-1]
+
+ html += """{{% assign {label} = page.rdf | rdf_property: "<{uri}>", nil, true %}}\n""".format(
+ uri=uri, label=label_jekyll, type=shapeName.lower())
+
+ html += """{{% if {label} %}}\n""".format(label=label_jekyll)
html += """
"""
+ html += """
{label}
""".format(label=label)
+ html += """{{% for each_{label} in {label} %}}\n""".format(label=label_jekyll)
+ html += """{{% if each_{label}.iri %}}\n""".format(label=label_jekyll)
+ html += """
{{{{ {type} | rdf_property: "<{uri}>" }}}}""".format(
- uri=uri, label=label, type=shapeName)
- '''
- if propertyShape.isSet['minCount']:
- for i in range(0, propertyShape.minCount):
- html += """ (min: {counter})
\n""".format(counter=str(i+1))
-
- if propertyShape.isSet['maxCount']:
- for i in range(max(propertyShape.minCount, 0), propertyShape.maxCount):
- html += """ (max: {counter})\n""".format(
- counter=str(propertyShape.minCount + i-1)) '''
- html += """"""
-
return html
-'''
- html+= '