@@ -31,9 +31,6 @@ use serde_json::Value;
31
31
use std:: sync:: Arc ;
32
32
33
33
// TODO: Add target name and versions
34
-
35
- #[ derive( Template ) ]
36
- #[ template( path = "crate/details.html" ) ]
37
34
#[ derive( Debug , Clone , PartialEq ) ]
38
35
pub ( crate ) struct CrateDetails {
39
36
pub ( crate ) name : String ,
@@ -68,12 +65,6 @@ pub(crate) struct CrateDetails {
68
65
pub ( crate ) crate_id : i32 ,
69
66
/// Database id for this release
70
67
pub ( crate ) release_id : i32 ,
71
- pub ( crate ) csp_nonce : String ,
72
- }
73
-
74
- impl_axum_webpage ! {
75
- CrateDetails ,
76
- cpu_intensive_rendering = true ,
77
68
}
78
69
79
70
#[ derive( Debug , Clone , PartialEq ) ]
@@ -259,7 +250,6 @@ impl CrateDetails {
259
250
items_with_examples : krate. items_with_examples ,
260
251
crate_id : krate. crate_id ,
261
252
release_id : krate. release_id ,
262
- csp_nonce : String :: new ( ) ,
263
253
} ;
264
254
265
255
// get owners
@@ -351,11 +341,6 @@ impl CrateDetails {
351
341
pub fn latest_release ( & self ) -> Result < & Release > {
352
342
latest_release ( & self . releases ) . ok_or_else ( || anyhow ! ( "crate without releases" ) )
353
343
}
354
-
355
- // Used by templates.
356
- pub ( crate ) fn use_direct_platform_links ( & self ) -> bool {
357
- true
358
- }
359
344
}
360
345
361
346
pub ( crate ) fn latest_release ( releases : & [ Release ] ) -> Option < & Release > {
@@ -425,6 +410,45 @@ pub(crate) async fn releases_for_crate(
425
410
Ok ( releases)
426
411
}
427
412
413
+ #[ derive( Template ) ]
414
+ #[ template( path = "crate/details.html" ) ]
415
+ #[ derive( Debug , Clone , PartialEq ) ]
416
+ struct CrateDetailsPage {
417
+ version : Version ,
418
+ name : String ,
419
+ owners : Vec < ( String , String , OwnerKind ) > ,
420
+ metadata : MetaData ,
421
+ documented_items : Option < i32 > ,
422
+ total_items : Option < i32 > ,
423
+ total_items_needing_examples : Option < i32 > ,
424
+ items_with_examples : Option < i32 > ,
425
+ homepage_url : Option < String > ,
426
+ documentation_url : Option < String > ,
427
+ repository_url : Option < String > ,
428
+ repository_metadata : Option < RepositoryMetadata > ,
429
+ dependencies : Option < Value > ,
430
+ releases : Vec < Release > ,
431
+ readme : Option < String > ,
432
+ build_status : BuildStatus ,
433
+ rustdoc_status : Option < bool > ,
434
+ is_library : Option < bool > ,
435
+ last_successful_build : Option < String > ,
436
+ rustdoc : Option < String > , // this is description_long in database
437
+ csp_nonce : String ,
438
+ }
439
+
440
+ impl CrateDetailsPage {
441
+ // Used by templates.
442
+ pub ( crate ) fn use_direct_platform_links ( & self ) -> bool {
443
+ true
444
+ }
445
+ }
446
+
447
+ impl_axum_webpage ! {
448
+ CrateDetailsPage ,
449
+ cpu_intensive_rendering = true ,
450
+ }
451
+
428
452
#[ derive( Deserialize , Clone , Debug ) ]
429
453
pub ( crate ) struct CrateDetailHandlerParams {
430
454
name : String ,
@@ -461,7 +485,54 @@ pub(crate) async fn crate_details_handler(
461
485
Err ( e) => warn ! ( "error fetching readme: {:?}" , & e) ,
462
486
}
463
487
464
- let mut res = details. into_response ( ) ;
488
+ let CrateDetails {
489
+ version,
490
+ name,
491
+ owners,
492
+ metadata,
493
+ documented_items,
494
+ total_items,
495
+ total_items_needing_examples,
496
+ items_with_examples,
497
+ homepage_url,
498
+ documentation_url,
499
+ repository_url,
500
+ repository_metadata,
501
+ dependencies,
502
+ releases,
503
+ readme,
504
+ build_status,
505
+ rustdoc_status,
506
+ is_library,
507
+ last_successful_build,
508
+ rustdoc,
509
+ ..
510
+ } = details;
511
+
512
+ let mut res = CrateDetailsPage {
513
+ version,
514
+ name,
515
+ owners,
516
+ metadata,
517
+ documented_items,
518
+ total_items,
519
+ total_items_needing_examples,
520
+ items_with_examples,
521
+ homepage_url,
522
+ documentation_url,
523
+ repository_url,
524
+ repository_metadata,
525
+ dependencies,
526
+ releases,
527
+ readme,
528
+ build_status,
529
+ rustdoc_status,
530
+ is_library,
531
+ last_successful_build,
532
+ rustdoc,
533
+ csp_nonce : String :: new ( ) ,
534
+ }
535
+ . into_response ( ) ;
465
536
res. extensions_mut ( )
466
537
. insert :: < CachePolicy > ( if req_version. is_latest ( ) {
467
538
CachePolicy :: ForeverInCdn
0 commit comments