Skip to content

Commit

Permalink
Properly link licenses on crate pages
Browse files Browse the repository at this point in the history
Fixes #2738

I'm not happy with the styling but I simply don't understand the CSS here well enough to do better without putting in significant effort.

I decided to consistently link to SPDX instead of also trying to link to https://choosealicense.com/ likes crates.io, but it's an easy change to make if we want to add that too.
  • Loading branch information
Manishearth authored and GuillaumeGomez committed Feb 20, 2025
1 parent 3597759 commit 02922b1
Show file tree
Hide file tree
Showing 5 changed files with 773 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/web/crate_details.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub(crate) struct CrateDetails {
pub(crate) metadata: MetaData,
is_library: Option<bool>,
pub(crate) license: Option<String>,
pub(crate) parsed_license: Option<Vec<super::licenses::LicenseSegment>>,
pub(crate) documentation_url: Option<String>,
pub(crate) total_items: Option<i32>,
pub(crate) documented_items: Option<i32>,
Expand Down Expand Up @@ -225,6 +226,8 @@ impl CrateDetails {
None => None,
};

let parsed_license = krate.license.as_deref().map(super::licenses::parse_license);

let mut crate_details = CrateDetails {
name: krate.name,
version: version.clone(),
Expand All @@ -250,6 +253,7 @@ impl CrateDetails {
documentation_url,
is_library: krate.is_library,
license: krate.license,
parsed_license,
documented_items: krate.documented_items,
total_items: krate.total_items,
total_items_needing_examples: krate.total_items_needing_examples,
Expand Down
Loading

0 comments on commit 02922b1

Please sign in to comment.