From 7a9c31b3faf55afdce444cd3460565c68161cd2a Mon Sep 17 00:00:00 2001 From: Lars Francke Date: Wed, 13 Mar 2024 10:52:43 +0100 Subject: [PATCH] Extend the HTML with a title and some links --- .../src/handlers/artifact_tree.rs | 131 ++++++++++-------- 1 file changed, 74 insertions(+), 57 deletions(-) diff --git a/tools/harbor_sbom_browser/src/handlers/artifact_tree.rs b/tools/harbor_sbom_browser/src/handlers/artifact_tree.rs index 98f19d8..4b99a8d 100644 --- a/tools/harbor_sbom_browser/src/handlers/artifact_tree.rs +++ b/tools/harbor_sbom_browser/src/handlers/artifact_tree.rs @@ -49,6 +49,7 @@ lazy_static! { pub async fn render_as_html( State(cached_rendered_artifact_tree): State>>, ) -> Result, ArtifactTreeError> { + // if the artifact tree is already cached, return it if let Some(html) = cached_rendered_artifact_tree.get() { return Ok(html); @@ -57,7 +58,67 @@ pub async fn render_as_html( let artifact_tree = build_artifact_tree().await?; let mut html = String::with_capacity(64 * 1024); // reserve 64KB to avoid reallocations - html.push_str("
    "); + html.push_str( + r#" + + + + + + Stackable :: SBOM Browser + + + +
    + Stackable Data Platform | + Documentation | + Discussions | + Discord +
    +
      "#, + ); + for (release_version, repositories) in artifact_tree { html.push_str(&format!("
    • Release {}
        ", release_version)); for (repository, artifacts) in repositories { @@ -72,68 +133,24 @@ pub async fn render_as_html( } html.push_str("
    • "); } + html.push_str( r#"
    - - - - "#, + }); + + + +"#, ); let html = Html(html); - // cache the rendered artifact tree cached_rendered_artifact_tree.set_to(html.clone()); Ok(html) }