From ba34ddb3a75d6603a3be07fa176eba59f67da50d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konrad=20H=C3=B6ffner?= Date: Tue, 10 Sep 2024 13:51:33 +0200 Subject: [PATCH] feat: improve blank node display --- data/rickview.css | 1 + src/rdf.rs | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/data/rickview.css b/data/rickview.css index c850679..e560516 100644 --- a/data/rickview.css +++ b/data/rickview.css @@ -259,4 +259,5 @@ div.datatype { p { margin-left: 1em; + margin-top: 0.2em; } diff --git a/src/rdf.rs b/src/rdf.rs index e42a2f2..c4b10b8 100644 --- a/src/rdf.rs +++ b/src/rdf.rs @@ -314,12 +314,20 @@ fn blank_html(props: BTreeMap, depth: usize) -> String { return format!("{} some {}", on_property.target_htmls.join(", "), some.target_htmls.join(", ")); } } - props + let indent = "\n".to_owned() + &"\t".repeat(9 + depth); + let indent2 = indent.clone() + "\t"; + #[allow(clippy::format_collect)] + let rows = props .into_values() .map(|p| { - p.target_htmls.iter().map(|html| "\n".to_owned() + &"\t".repeat(9 + depth) + "

" + &p.prop_html + " " + html + "

").collect::() + format!( + "{indent2}{}{}", + p.prop_html, + p.target_htmls.into_iter().map(|h| format!("{h}")).collect::() + ) }) - .collect::() + .collect::(); + format!("{indent}{rows}{indent}
") } /// For a given resource r, get either all direct properties (p,o) where (r,p,o) is in the graph or indirect ones (s,p) where (s,p,r) is in the graph. @@ -343,7 +351,7 @@ fn properties(conn_type: &PropertyType, source: &SimpleTerm<'_>, depth: usize) - SimpleTerm::Iri(iri) => { let piri = Piri::from(iri.as_ref()); - let title = if let Some(title) = titles().get(&piri.to_string()) { format!("↪ {title}") } else { String::new() }; + let title = if let Some(title) = titles().get(&piri.to_string()) { format!("
↪ {title}") } else { String::new() }; let target = if piri.to_string().starts_with(config().namespace.as_str()) { "" } else { " target='_blank' " }; format!("{}{title}", piri.root_relative(), piri.prefixed_string(false, true)) } @@ -357,7 +365,8 @@ fn properties(conn_type: &PropertyType, source: &SimpleTerm<'_>, depth: usize) - }; let r = IriRef::new_unchecked(SKOLEM_START.to_owned() + id); let iri = config().namespace.resolve(r); - format!("_:{id}

{sub_html}", Piri::new(iri.as_ref()).root_relative()) + //format!("_:{id}

{sub_html}

", Piri::new(iri.as_ref()).root_relative()) + format!("↪ Blank Node {id}{sub_html}", Piri::new(iri.as_ref()).root_relative()) } _ => format!("{target_term:?}"), };