Skip to content

Commit 0378bdf

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 0378bdf

File tree

5 files changed

+769
-6
lines changed

5 files changed

+769
-6
lines changed

src/web/crate_details.rs

Lines changed: 8 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,12 @@ impl CrateDetails {
225226
None => None,
226227
};
227228

229+
let parsed_license = krate
230+
.license
231+
.as_ref()
232+
.map(|x| &**x)
233+
.map(super::licenses::parse_license);
234+
228235
let mut crate_details = CrateDetails {
229236
name: krate.name,
230237
version: version.clone(),
@@ -250,6 +257,7 @@ impl CrateDetails {
250257
documentation_url,
251258
is_library: krate.is_library,
252259
license: krate.license,
260+
parsed_license,
253261
documented_items: krate.documented_items,
254262
total_items: krate.total_items,
255263
total_items_needing_examples: krate.total_items_needing_examples,

0 commit comments

Comments
 (0)