AKSW / jekyll-rdf

📃 A Jekyll plugin to include RDF data in your static site or build a complete site for your RDF graph
http://aksw.org/Projects/JekyllRDF
Other
57 stars 10 forks source link

Collections can't be rendered using a property to reference #66

Closed white-gecko closed 7 years ago

white-gecko commented 7 years ago

If I try to reference a collection using a property I get an exception. I'm on the feature branch from the pullrequest #62 .

My data:

<http://example.org/Sebastian>
    a <http://xmlns.com/foaf/0.1/Agent>, <http://xmlns.com/foaf/0.1/Person> ;
    <http://xmlns.com/foaf/0.1/firstName> "Sebastian" ;
    <http://xmlns.com/foaf/0.1/gender> "male" ;
    _:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "shinobu" .
_:genid4 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "Ruby" .
_:genid5 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:genid4 .
_:genid6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "Jekyll-RDF" .
_:genid6 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:genid5 .
_:genid7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "Informatik" .
_:genid7 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:genid6 .
<http://example.org/knows> <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> "BSV" .
<http://example.org/knows> <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:genid7 .
<http://example.org/Sebastian> <http://xmlns.com/foaf/0.1/knows> <http://example.org/knows> .

The template:

---
---
<h1 class="page-heading">{{ page.rdf | rdf_property: '<http://xmlns.com/foaf/0.1/name>' }}</h1>

<dl>
    {% assign firstname = page.rdf | rdf_property: '<http://xmlns.com/foaf/0.1/firstName>' %}
    {% assign lastname = page.rdf | rdf_property: '<http://xmlns.com/foaf/0.1/lastName>' %}
    {% assign gender = page.rdf | rdf_property: '<http://xmlns.com/foaf/0.1/gender>' %}
    {% if firstname %}
    <dt>Vorname:</dt>
    <dd>{{ firstname }}</dd>
    {% endif %}
    {% if lastname %}
    <dt>Nachname:</dt>
    <dd>{{ lastname }}</dd>
    {% endif %}
    {% if lastname %}
    <dt>Geschlecht:</dt>
    <dd>{{ gender }}</dd>
    {% endif %}
</dl>

<ul>
    {% assign coll = page.rdf | rdf_property: '<http://xmlns.com/foaf/0.1/knows>'  %}
    <span>{{ coll }}</span>
    {% assign array = coll | rdf_collection %}
    {% for know in array %}
    <li>{{ know }}</li>
    {% endfor %}
</ul>

Exception:

  Liquid Exception: undefined method `statements_as_subject' for nil:NilClass in rdfsites/http/xmlns.com/foaf/0.1/Agent/index.html
Simaris commented 7 years ago

I made a small fix in #62, but also discovered that the current implementation is unfit to handle blanknodes (see commit message ebbd27efd99f29a55d154c914f4ddbd4c00bc801). We might have to wait until #63 is through to get to a better solution.

Simaris commented 7 years ago

69 might have solvedc the problem