Skip to content

Commit

Permalink
added person support
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Jan 11, 2024
1 parent a1605bd commit a1a2103
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/sparqlunicorn_ontdoc/docgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from export.pages.lexiconpage import LexiconPage
from export.pages.observationpage import ObservationPage
from export.pages.geometryviewpage import GeometryViewPage

from export.pages.personpage import PersonPage

if os.path.exists("ontdocscript"):
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__))+"/ontdocscript/src/sparqlunicorn_ontdoc/")
Expand Down Expand Up @@ -1351,6 +1351,8 @@ def createHTML(self,savepath, predobjs, subject, baseurl, subpreds, graph, searc
for type in curtypes:
if type in DocConfig.lexicontypes:
LexiconPage().generatePageWidget(graph, subject, f, {}, False)
if type in PersonPage.pageWidgetConstraint():
PersonPage().generatePageWidget(graph, subject, templates, f, True)
self.processCollectionPages(collections,graph,subject,f)
if geojsonrep != None and "geocollection" not in collections:
self.geocache = GeometryViewPage().generatePageWidget(graph, templates, subject, f, uritotreeitem,
Expand Down
4 changes: 2 additions & 2 deletions src/sparqlunicorn_ontdoc/export/pages/bibpage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from src.sparqlunicorn_ontdoc.doc.docconfig import DocConfig
from src.sparqlunicorn_ontdoc.doc.docutils import DocUtils
from doc.docconfig import DocConfig
from doc.docutils import DocUtils
from rdflib import URIRef

class BibPage:
Expand Down
2 changes: 1 addition & 1 deletion src/sparqlunicorn_ontdoc/export/pages/pageutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def retrieveCollectionConstraints(self):
for const in self.pageTypes[type].collectionConstraint():
self.collectionConstraints[const]=self.pageTypes[type]
for const in self.pageTypes[type].pageWidgetConstraint():
self.collectionConstraints[const]=self.pageTypes[type]
self.widgetConstraints[const]=self.pageTypes[type]
except:
print("PageType Constraints parsing failed")

Expand Down
30 changes: 21 additions & 9 deletions src/sparqlunicorn_ontdoc/export/pages/personpage.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
from src.sparqlunicorn_ontdoc.doc.docconfig import DocConfig

from doc.docconfig import DocConfig
from doc.docutils import DocUtils

class PersonPage:

vcardprops={
"http://xmlns.com/foaf/0.1/birthday":"BDAY",
"http://xmlns.com/foaf/0.1/family_name":"N",
"http://xmlns.com/foaf/0.1/familyName":"N",
"http://xmlns.com/foaf/0.1/family_name": "N",
"http://xmlns.com/foaf/0.1/firstName": "N",
"http://xmlns.com/foaf/0.1/lastName": "N",
"http://xmlns.com/foaf/0.1/fullName":"FN",
"http://xmlns.com/foaf/0.1/givenname":"N",
"http://xmlns.com/foaf/0.1/givenname": "N",
"http://xmlns.com/foaf/0.1/givenName":"N",
"http://xmlns.com/foaf/0.1/homePage":"URL",
"http://xmlns.com/foaf/0.1/gender": "GENDER",
"http://xmlns.com/foaf/0.1/img":"PHOTO",
"http://xmlns.com/foaf/0.1/logo":"LOGO",
"http://xmlns.com/foaf/0.1/mbox":"EMAIL",
Expand Down Expand Up @@ -71,15 +76,22 @@ def extractPersonMetadata(self,subject,graph):
return thevcard

def vcardToHTML(self,vcard):
result=""

result="<table id=\"person\" border=\"1\"><thead><tr><th>Property</th><th>Value</th></tr></thead><tbody>"
for prop in vcard:
result+="<tr><td><a href=\""+str(prop)+"\">"+str(DocUtils.shortenURI(prop))+"</a></td>"
if "http" in vcard[prop]:
result+="<td><a href=\""+str(vcard[prop])+"\">"+str(DocUtils.shortenURI(vcard[prop]))+"</a></td></tr>"
else:
result += "<td>" + str(vcard[prop]) + "</td></tr>"
result+="</tbody></table><script>$('#person').DataTable();</script>"
return result


def collectionConstraint(self):
@staticmethod
def collectionConstraint():
return DocConfig.collectionclasses

def pageWidgetConstraint(self):
@staticmethod
def pageWidgetConstraint():
return ["http://xmlns.com/foaf/0.1/Person","http://www.w3.org/2006/vcard/ns#Individual","http://schema.org/Person","http://dbpedia.org/ontology/Person","http://www.wikidata.org/entity/Q5"]

def generatePageWidget(self, graph, subject, templates, f=None, pageWidget=False):
Expand Down

0 comments on commit a1a2103

Please sign in to comment.