diff --git a/src/web/crate_details.rs b/src/web/crate_details.rs index 0eaecb889..e5ce5c3ce 100644 --- a/src/web/crate_details.rs +++ b/src/web/crate_details.rs @@ -1583,6 +1583,44 @@ mod tests { }); } + #[test] + fn details_with_repository_and_stats_can_render_icon() { + wrapper(|env| { + env.fake_release() + .name("library") + .version("0.1.0") + .repo("https://github.com/org/repo") + .github_stats("org/repo", 10, 10, 10) + .create()?; + + let page = kuchikiki::parse_html().one( + env.frontend() + .get("/crate/library/0.1.0/") + .send()? + .error_for_status()? + .text()?, + ); + + let link = page + .select_first("a.pure-menu-link[href='https://github.com/org/repo']") + .unwrap(); + + let icon_node = link.as_node().children().nth(1).unwrap(); + assert_eq!( + icon_node + .as_element() + .unwrap() + .attributes + .borrow() + .get("class") + .unwrap(), + "fa-svg" + ); + + Ok(()) + }); + } + #[test] fn feature_flags_report_null() { wrapper(|env| { diff --git a/src/web/page/templates.rs b/src/web/page/templates.rs index 60f835a8b..c3bfb4193 100644 --- a/src/web/page/templates.rs +++ b/src/web/page/templates.rs @@ -1,5 +1,5 @@ use crate::error::Result; -use crate::web::{report_error, rustdoc::RustdocPage}; +use crate::web::rustdoc::RustdocPage; use anyhow::{anyhow, Context}; use rinja::Template; use std::{fmt, sync::Arc}; @@ -267,16 +267,16 @@ impl IconType { IconType::Brand => font_awesome_as_a_crate::Type::Brands, }; - let icon_file_string = match font_awesome_as_a_crate::svg(type_, icon_name) { - Ok(s) => s, - Err(err) => { - report_error(&anyhow!(err).context(format!( - "error trying to render icon with name \"{}\"", - icon_name - ))); - "" - } - }; + let icon_file_string = font_awesome_as_a_crate::svg(type_, icon_name).map_err(|err| { + rinja::Error::Custom( + anyhow!(err) + .context(format!( + "error trying to render icon with name \"{}\" and type \"{}\"", + icon_name, type_, + )) + .into(), + ) + })?; let mut classes = vec!["fa-svg"]; if fw { diff --git a/templates/crate/details.html b/templates/crate/details.html index 6d4e023db..28c568145 100644 --- a/templates/crate/details.html +++ b/templates/crate/details.html @@ -64,7 +64,7 @@ {# If the repo link is for github or gitlab, show some stats #} {# TODO: add support for hosts besides github and gitlab (#35) #} {%- if let Some(repository_metadata) = repository_metadata -%} - {{ "code-branch"|fab(false, false, "") }} + {{ "code-branch"|fas(false, false, "") }} {% if let Some(name) = repository_metadata.name %} {{name}} {% else %}