From ec221ab0f86b976926c0dee16a0d933153ca676d Mon Sep 17 00:00:00 2001 From: Sirko Schindler Date: Thu, 4 Apr 2024 18:06:31 +0200 Subject: [PATCH 1/2] more compact metadata list --- pylode/pylode.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pylode/pylode.css b/pylode/pylode.css index bfb598b0..f13a8b56 100644 --- a/pylode/pylode.css +++ b/pylode/pylode.css @@ -60,6 +60,9 @@ #classes ul li { margin-left: -40px; } + #metadata dd p { + margin: 0; + } ul.hlist { list-style-type: none; From 06274a6a992dcb1176e1e186145a5eb086409d28 Mon Sep 17 00:00:00 2001 From: Sirko Schindler Date: Thu, 4 Apr 2024 18:07:01 +0200 Subject: [PATCH 2/2] rework agent display * use canonical title as a name * use orcid URL as title attribute in logo * show affiliation if given as string --- pylode/profiles/ontpub.py | 4 ++-- pylode/rdf_elements.py | 2 +- pylode/utils.py | 31 ++++++++++++++++++------------- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pylode/profiles/ontpub.py b/pylode/profiles/ontpub.py index 3109a010..9d2cece0 100644 --- a/pylode/profiles/ontpub.py +++ b/pylode/profiles/ontpub.py @@ -276,7 +276,7 @@ def _ontdoc_inference(self, g): def _make_head( self, schema_org: Graph, include_css: bool = True, destination: Path = None ): - """Healper function for make_html(). Makes ??? content""" + """Helper function for make_html(). Makes ??? content""" with self.doc.head: # use standard pyLODE stylesheet if include_css: @@ -313,7 +313,7 @@ def _make_head( ) def _make_body(self): - """Healper function for make_html(). Makes ??? content. + """Helper function for make_html(). Makes ??? content. Just calls other helper functions in order""" make_pylode_logo( diff --git a/pylode/rdf_elements.py b/pylode/rdf_elements.py index 9241ef8a..ade6775e 100644 --- a/pylode/rdf_elements.py +++ b/pylode/rdf_elements.py @@ -82,7 +82,7 @@ # properties for Agents AGENT_PROPS = [ - SDO.name, + DCTERMS.title, SDO.affiliation, SDO.identifier, SDO.email, diff --git a/pylode/utils.py b/pylode/utils.py index 914266f2..08297a1f 100644 --- a/pylode/utils.py +++ b/pylode/utils.py @@ -493,7 +493,7 @@ def _affiliation_html(ont___, obj___): for p_, o_ in ont___.predicate_objects(obj___): if p_ in AGENT_PROPS: - if p_ == SDO.name: + if p_ == DCTERMS.title: name_ = str(o_) elif p_ == SDO.url: url_ = str(o_) @@ -507,19 +507,17 @@ def _affiliation_html(ont___, obj___): else: if "http" in obj___: sp_.appendChild(em(" of ", a(obj___, href=obj___))) + else: + sp_.appendChild(em(" of ", obj___)) return sp_ - if isinstance(obj__, Literal): - return span(str(obj__)) - honorific_prefix = None - name = None - identifier = None - orcid = None - orcid_logo = """ + def _orcid_logo_svg( id ): + id = id if ('http' in id) else f"https://orcid.org/{id}" + return f""" - Orcid logo + {id} @@ -535,6 +533,13 @@ def _affiliation_html(ont___, obj___): """ + + if isinstance(obj__, Literal): + return span(str(obj__)) + honorific_prefix = None + name = None + identifier = None + orcid = None url = None email = None affiliation = None @@ -544,7 +549,7 @@ def _affiliation_html(ont___, obj___): for px, o in ont__.predicate_objects(obj__): if px in AGENT_PROPS: - if px == SDO.name: + if px == DCTERMS.title: name = str(o) elif px == SDO.honorificPrefix: honorific_prefix = str(o) @@ -572,15 +577,14 @@ def _affiliation_html(ont___, obj___): if orcid: if "orcid.org" in obj__: - sp.appendChild(a(raw(orcid_logo), href=obj__)) + sp.appendChild(a(raw(_orcid_logo_svg(obj__)), href=obj__)) else: - sp.appendChild(a(raw(orcid_logo), href=identifier)) + sp.appendChild(a(raw(_orcid_logo_svg(identifier)), href=identifier)) elif identifier is not None: sp.appendChild(a(identifier, href=identifier)) if email is not None: email = email.replace("mailto:", "") sp.appendChild(span("(", a(email, href="mailto:" + email), " )")) - if affiliation is not None: sp.appendChild(_affiliation_html(ont__, affiliation)) else: @@ -685,6 +689,7 @@ def _bn_html(ont__, back_onts__, ns__, fids__, obj__: BNode): else: # (obj, RDF.type, OWL.Class) in ont: # Set Class return _setclass_html(ont__, obj__, back_onts__, ns__, fids__) + if isinstance(obj_, Tuple) or isinstance(obj_, URIRef): ret = _hyperlink_html( ont_, back_onts_, ns_, obj_, fids_, rdf_type__=rdf_type_