File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,9 +66,14 @@ pub async fn status_badge(
6666 "shields/mod_downloads.svg" ,
6767 ) ,
6868 } ;
69- let svg_url = data. static_storage ( ) . asset_url ( svg_path) ;
69+ let svg = data
70+ . static_storage ( )
71+ . read ( svg_path)
72+ . await
73+ . map_err ( |_| ApiError :: InternalError ( "Failed to read status badge file" . into ( ) ) ) ?;
7074 let api_url = format ! ( "{}/v1/mods/{}?abbreviate=true" , data. app_url( ) , id) ;
7175 let mod_link = format ! ( "{}/mods/{}" , data. front_url( ) , id) ;
76+ let svg_data_url = format ! ( "data:image/svg+xml;utf8,{}" , urlencoding:: encode_binary( & svg) ) ;
7277 let shields_url = format ! (
7378 "https://img.shields.io/badge/dynamic/json?url={}&query={}&label={}&labelColor={}&color={}&link={}&style=plastic&logo={}" ,
7479 urlencoding:: encode( & api_url) ,
@@ -77,7 +82,7 @@ pub async fn status_badge(
7782 urlencoding:: encode( LABEL_COLOR ) ,
7883 urlencoding:: encode( STAT_COLOR ) ,
7984 urlencoding:: encode( & mod_link) ,
80- urlencoding:: encode( & svg_url )
85+ urlencoding:: encode( & svg_data_url )
8186 ) ;
8287 Ok ( HttpResponse :: Found ( )
8388 . append_header ( ( "Location" , shields_url) )
You can’t perform that action at this time.
0 commit comments