Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed May 23, 2024
1 parent d8a6f8d commit a3c2760
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
23 changes: 12 additions & 11 deletions trove/render/html_browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,8 @@ def __mediatype_link(self, mediatype: str):
_link.text = 'documented use'
_link.tail = ')'

def __render_subj(self, subj_iri: str, twopledict=None, start_collapsed=False):
_twopledict = (
self.data.get(subj_iri, {})
if twopledict is None
else twopledict
)
def __render_subj(self, subj_iri: str, start_collapsed=False):
_twopledict = self.data.get(subj_iri, {})
with self.__visiting(subj_iri):
with self.__h_tag() as _h_tag:
with self.__nest(
Expand Down Expand Up @@ -169,13 +165,15 @@ def __literal(self, literal: primitive_rdf.Literal):
for _datatype in literal.datatype_iris
)
# TODO: checksum_iri, literal_iri
with self.__nest('article'):
with self.__nest('article', attrs={'class': 'Browse__literal'}):
if _is_markdown:
# TODO: tests for safe_mode
_html = markdown2.markdown(literal.unicode_value, safe_mode='escape')
self.__current_element.append(etree_fromstring(f'<q>{_html}</q>'))
else:
self.__leaf('q', text=literal.unicode_value)
for _datatype_iri in literal.datatype_iris:
self.__leaf_link(_datatype_iri, attrs={'class': 'Browse__datatype'})

def __sequence(self, sequence_twoples: frozenset):
_obj_in_order = list(primitive_rdf.sequence_objects_in_order(sequence_twoples))
Expand Down Expand Up @@ -262,11 +260,14 @@ def __leaf(self, tag_name, *, text=None, attrs=None):
if text is not None:
_leaf_element.text = text

def __nest_link(self, iri: str):
return self.__nest('a', attrs={'href': self.__href_for_iri(iri)})
def __nest_link(self, iri: str, *, attrs=None):
return self.__nest('a', attrs={
**(attrs or {}),
'href': self.__href_for_iri(iri),
})

def __leaf_link(self, iri: str):
with self.__nest_link(iri) as _link:
def __leaf_link(self, iri: str, *, attrs=None):
with self.__nest_link(iri, attrs=attrs) as _link:
_link.text = self.iri_shorthand.compact_iri(iri)

def __href_for_iri(self, iri: str):
Expand Down
10 changes: 10 additions & 0 deletions trove/static/css/browse.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@
gap: 0.382rem;
}

.Browse__literal {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 0.191rem;
}

.Browse__datatype {
}

/*
.Browse :focus-within {
backdrop-filter: hue-rotate(var(--hue-rotate-step));
Expand Down
4 changes: 4 additions & 0 deletions trove/trovesearch_gathering.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ def gather_card(focus, *, use_osfmap_json, **kwargs):
yield (TROVE.focusIdentifier, literal(_iri))
for _triple in iter_tripleset(_indexcard_rdf.as_rdf_tripledict()):
yield (TROVE.resourceMetadata, QuotedTriple(*_triple))
yield (
TROVE.resourceMetadata,
QuotedTriple(_indexcard_rdf.focus_iri, FOAF.primaryTopicOf, _indexcard_iri)
)


###
Expand Down

0 comments on commit a3c2760

Please sign in to comment.