Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring Agent display #216

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pylode/profiles/ontpub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <head>???</head> content"""
"""Helper function for make_html(). Makes <head>???</head> content"""
with self.doc.head:
# use standard pyLODE stylesheet
if include_css:
Expand Down Expand Up @@ -313,7 +313,7 @@ def _make_head(
)

def _make_body(self):
"""Healper function for make_html(). Makes <body>???</body> content.
"""Helper function for make_html(). Makes <body>???</body> content.

Just calls other helper functions in order"""
make_pylode_logo(
Expand Down
3 changes: 3 additions & 0 deletions pylode/pylode.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
#classes ul li {
margin-left: -40px;
}
#metadata dd p {
margin: 0;
}

ul.hlist {
list-style-type: none;
Expand Down
2 changes: 1 addition & 1 deletion pylode/rdf_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

# properties for Agents
AGENT_PROPS = [
SDO.name,
DCTERMS.title,
SDO.affiliation,
SDO.identifier,
SDO.email,
Expand Down
31 changes: 18 additions & 13 deletions pylode/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_)
Expand All @@ -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"""
<svg width="15px" height="15px" viewBox="0 0 72 72" version="1.1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Orcid logo</title>
<title>{id}</title>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="hero" transform="translate(-924.000000, -72.000000)" fill-rule="nonzero">
<g id="Group-4">
Expand All @@ -535,6 +533,13 @@ def _affiliation_html(ont___, obj___):
</g>
</g>
</svg>"""

if isinstance(obj__, Literal):
return span(str(obj__))
honorific_prefix = None
name = None
identifier = None
orcid = None
url = None
email = None
affiliation = None
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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_
Expand Down