diff --git a/index.html b/index.html index 4a0b864..342bd1b 100644 --- a/index.html +++ b/index.html @@ -198,15 +198,18 @@ text-decoration: underline #770000 0.2em; background-color: #ffbbbb; } - .explanation-icon.verified { color: #007700; } - .explanation-icon.ok { color: #002266; } - .explanation-icon.valid { color: #777700; } - .explanation-icon.invalid { color: #770000; } + .explanation-box-wrapper { + align-self: start; + justify-self: center; + display: flex; + flex-flow: column; + align-items: center; + justify-items: center; + gap: 0.5em; + } .explanation-box { padding: 1em; border-radius: 0.5em; - align-self: start; - justify-self: center; width: 20em; display: grid; column-gap: 0.5em; @@ -215,6 +218,10 @@ grid-template-areas: "icon headline" "icon explanation" } + .explanation-icon.verified { color: #007700; } + .explanation-icon.ok { color: #002266; } + .explanation-icon.valid { color: #777700; } + .explanation-icon.invalid { color: #770000; } .explanation-box.verified { background-color: #bbffbb; } .explanation-box.ok { background-color: #aaddff; } .explanation-box.valid { background-color: #ffffbb; } diff --git a/src/main.rs b/src/main.rs index fd49266..db063bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -140,8 +140,10 @@ fn MainContent() -> impl IntoView { } }); - let get_explanation_box_class = + let get_type_explanation_box_class = move || format!("explanation-box {result}", result = eval_type_result()); + let get_namespace_explanation_box_class = + move || format!("explanation-box {result}", result = eval_namespace_result()); view! {
@@ -223,16 +225,29 @@ fn MainContent() -> impl IntoView { subpath={subpath} /> -
- {move || match eval_type_result().as_str() { - "verified" => view!{}, - "ok" => view!{} , - "valid" => view!{} , - "invalid" => view!{}, - _ => view!{}, - }} - {eval_type_result} - {eval_type_result_explanation} +
+
+ {move || match eval_type_result().as_str() { + "verified" => view!{}, + "ok" => view!{} , + "valid" => view!{} , + "invalid" => view!{}, + _ => view!{}, + }} + {eval_type_result} + {eval_type_result_explanation} +
+
+ {move || match eval_namespace_result().as_str() { + "verified" => view!{}, + "ok" => view!{} , + "valid" => view!{} , + "invalid" => view!{}, + _ => view!{}, + }} + {eval_namespace_result} + {eval_namespace_result_explanation} +
} } diff --git a/src/purl_data.rs b/src/purl_data.rs index 0e0747e..3c532ad 100644 --- a/src/purl_data.rs +++ b/src/purl_data.rs @@ -440,6 +440,9 @@ pub trait PurlComponent { impl PurlComponent for PurlNamespace { fn new_naive(s: &str) -> Self { + if s.is_empty() { + return vec![]; + } s.split('/').map(|s| s.to_string()).collect() } diff --git a/src/purl_eval.rs b/src/purl_eval.rs index a41f0fd..dccaae7 100644 --- a/src/purl_eval.rs +++ b/src/purl_eval.rs @@ -1,4 +1,4 @@ -use crate::purl_data::{PurlType, PurlTypeStatus}; +use crate::purl_data::{self, PurlComponent, PurlType, PurlTypeStatus}; lazy_static! { pub static ref TYPE_REGEX: regex::Regex = @@ -51,6 +51,14 @@ pub fn eval_purl_type(purl_type: PurlType) -> EvalResult { } } -pub fn eval_purl_namespace(purl_namespace: Vec) -> EvalResult { - EvalResult::Verified("fake".to_string()) +pub fn eval_purl_namespace(purl_namespace: purl_data::PurlNamespace) -> EvalResult { + // TODO: regex check + + if purl_namespace.len() != purl_namespace.as_canonical().len() { + return EvalResult::AtLeastValid( + "had to remove leading or trailing empty segments from namespace".to_string(), + ); + } + + EvalResult::ProbablyOk("I see no issue...".to_string()) }