Skip to content

Commit 02922b1

Browse files
ManishearthGuillaumeGomez
authored andcommitted
Properly link licenses on crate pages
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.
1 parent 3597759 commit 02922b1

File tree

5 files changed

+773
-6
lines changed

5 files changed

+773
-6
lines changed

src/web/crate_details.rs

+4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub(crate) struct CrateDetails {
5757
pub(crate) metadata: MetaData,
5858
is_library: Option<bool>,
5959
pub(crate) license: Option<String>,
60+
pub(crate) parsed_license: Option<Vec<super::licenses::LicenseSegment>>,
6061
pub(crate) documentation_url: Option<String>,
6162
pub(crate) total_items: Option<i32>,
6263
pub(crate) documented_items: Option<i32>,
@@ -225,6 +226,8 @@ impl CrateDetails {
225226
None => None,
226227
};
227228

229+
let parsed_license = krate.license.as_deref().map(super::licenses::parse_license);
230+
228231
let mut crate_details = CrateDetails {
229232
name: krate.name,
230233
version: version.clone(),
@@ -250,6 +253,7 @@ impl CrateDetails {
250253
documentation_url,
251254
is_library: krate.is_library,
252255
license: krate.license,
256+
parsed_license,
253257
documented_items: krate.documented_items,
254258
total_items: krate.total_items,
255259
total_items_needing_examples: krate.total_items_needing_examples,

0 commit comments

Comments
 (0)