Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix wrong code-branch icon variant in crate-details #2615

Merged
merged 2 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down
22 changes: 11 additions & 11 deletions src/web/page/templates.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion templates/crate/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
Loading