Skip to content

Commit 749fad8

Browse files
committed
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 749fad8

File tree

5 files changed

+767
-6
lines changed

5 files changed

+767
-6
lines changed

src/web/crate_details.rs

Lines changed: 6 additions & 0 deletions
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,10 @@ impl CrateDetails {
225226
None => None,
226227
};
227228

229+
let parsed_license = krate
230+
.license.as_deref()
231+
.map(super::licenses::parse_license);
232+
228233
let mut crate_details = CrateDetails {
229234
name: krate.name,
230235
version: version.clone(),
@@ -250,6 +255,7 @@ impl CrateDetails {
250255
documentation_url,
251256
is_library: krate.is_library,
252257
license: krate.license,
258+
parsed_license,
253259
documented_items: krate.documented_items,
254260
total_items: krate.total_items,
255261
total_items_needing_examples: krate.total_items_needing_examples,

0 commit comments

Comments
 (0)