diff --git a/src/sparqlunicorn_ontdoc/export/api/carddavexporter.py b/src/sparqlunicorn_ontdoc/export/api/carddavexporter.py index 42b5b4f7..1adcf449 100644 --- a/src/sparqlunicorn_ontdoc/export/api/carddavexporter.py +++ b/src/sparqlunicorn_ontdoc/export/api/carddavexporter.py @@ -14,7 +14,6 @@ def vcardJSONToFile(self,vcard,path): f.close() - def generateCardDAVCollection(self, outpath, deploypath, graph,subject,license="",version="3"): if not os.path.exists(outpath + "/addressbook/"): os.makedirs(outpath + "/addressbook/") diff --git a/src/sparqlunicorn_ontdoc/export/pages/personpage.py b/src/sparqlunicorn_ontdoc/export/pages/personpage.py index b5115600..751239f8 100644 --- a/src/sparqlunicorn_ontdoc/export/pages/personpage.py +++ b/src/sparqlunicorn_ontdoc/export/pages/personpage.py @@ -140,28 +140,39 @@ def createNameProperty(self,vcard): def extractPersonMetadata(self,subject,graph): thevcard={} + thehcard={} for pprop in graph.predicate_objects(subject, True): + if str(pprop[0]) in self.vcardTohCard: + thehcard[str(self.vcardTohCard[str(pprop[0])])]={"value":str(pprop[1]),"prop":str(pprop[0])} if str(pprop[0]) in self.vcardprops: if self.vcardprops[str(pprop[0])] in thevcard: thevcard[self.vcardprops[str(pprop[0])]]["value"]+=" "+str(pprop[1]) else: thevcard[self.vcardprops[str(pprop[0])]]={"value":str(pprop[1]),"prop":str(pprop[0])} - return thevcard + return {"vcard":thevcard,"hcard":thehcard} - def vcardToHTML(self,vcard): + def hcardToHTML(self,vcard,hcard): result="" - for prop in vcard: - result+="" - if "http" in vcard[prop]: - result+="" + for prop in hcard: + result+="" + if "http" in hcard[prop]: + result+="" else: - if vcard[prop]["prop"] in self.vcardTohCard: - result += "" + if hcard[prop]["prop"] in self.vcardTohCard: + result += "" else: - result += "" - result+="
PropertyValue
"+str(DocUtils.shortenURI(prop))+""+str(DocUtils.shortenURI(vcard[prop]["value"]))+"
"+str(DocUtils.shortenURI(hcard[prop]["prop"]))+""+str(DocUtils.shortenURI(hcard[prop]["value"]))+"
" + str(vcard[prop]["value"]) + "
" + str(hcard[prop]["value"]) + "
" + str(vcard[prop]["value"]) + "
" + result += "" + str(hcard[prop]["value"]) + "" + result+="" return result + @staticmethod + def vcardJSONToString(vcard): + res="BEGIN:VCARD\nVERSION:4.0\n" + res+="PROFILE:VCARD\n" + for key in vcard: + res+=str(key).upper()+":"+str(vcard[key])+"\n" + res+="END:VCARD\n" + return res @staticmethod def collectionConstraint(): @@ -173,10 +184,10 @@ def pageWidgetConstraint(): def generatePageWidget(self, graph, subject, templates, f=None, pageWidget=False): print("PageWidget") - vcard=self.extractPersonMetadata(subject,graph) + vcardres=self.extractPersonMetadata(subject,graph) if pageWidget and f!=None: - f.write(self.vcardToHTML(vcard)) - return vcard + f.write(self.hcardToHTML(vcardres["vcard"],vcardres["hcard"])) + return vcardres["vcard"] def generateCollectionWidget(self, graph, templates, subject, f=None): print("CollectionWidget")