Skip to content

Commit 9eed777

Browse files
committed
sponsors: use svg logos
1 parent 95541b2 commit 9eed777

File tree

11 files changed

+20
-7
lines changed

11 files changed

+20
-7
lines changed

src/data/sponsors.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# The name of the sponsor is defined here and left untranslated in the page.
66
# The other parts of the page are derived from the sponsor's ID:
7-
# - The logo is located in static/images/sponsor-logos/<id>.png
7+
# - The logo is located in static/images/sponsor-logos/<id>.svg
88
# - The alt of the image is the Fluent translation "sponsors-<id>-alt"
99
# - The description paragraph is the Fluent translation "sponsors-<id>"
1010

src/headers.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rocket::fairing::{Fairing, Info, Kind};
2-
use rocket::http::Header;
2+
use rocket::http::{Header, ContentType};
33
use rocket::{Request, Response};
44

55
static HEADERS: &[(&str, &str)] = &[
@@ -13,6 +13,7 @@ static HEADERS: &[(&str, &str)] = &[
1313
];
1414

1515
static HEADER_CSP_NORMAL: &str = "default-src 'self'; frame-ancestors 'self'; img-src 'self' avatars.githubusercontent.com; frame-src 'self' player.vimeo.com";
16+
static HEADER_CSP_SVG: &str = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'none'";
1617
static HEADER_CSP_PONTOON: &str = "default-src 'self' pontoon.rust-lang.org pontoon.mozilla.org; frame-ancestors 'self' pontoon.rust-lang.org; img-src 'self' avatars.githubusercontent.com pontoon.rust-lang.org pontoon.mozilla.org; frame-src 'self' pontoon.rust-lang.org player.vimeo.com";
1718

1819
pub(crate) struct InjectHeaders;
@@ -29,7 +30,11 @@ impl Fairing for InjectHeaders {
2930
for (key, value) in HEADERS {
3031
response.set_header(Header::new(*key, *value));
3132
}
32-
let csp = if *super::PONTOON_ENABLED {
33+
let csp = if response.content_type() == Some(ContentType::SVG) {
34+
// SVGs adhere to Content Security Policy, and they often include inline styles.
35+
// This uses a custom CSP when the Content-Type is SVG.
36+
HEADER_CSP_SVG
37+
} else if *super::PONTOON_ENABLED {
3338
HEADER_CSP_PONTOON
3439
} else {
3540
HEADER_CSP_NORMAL

src/sponsors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub(crate) fn render_data(lang: &str) -> Vec<RenderSponsor> {
3535
.map(|s| RenderSponsor {
3636
name: &s.name,
3737
is_not_first: true, // Will be changed later
38-
logo_path: format!("/static/images/sponsor-logos/{}.png", s.id),
38+
logo_path: format!("/static/images/sponsor-logos/{}.svg", s.id),
3939
logo_alt_i18n: i18n.lookup(lang, &format!("sponsors-{}-alt", s.id), None),
4040
description_i18n: i18n.lookup(lang, &format!("sponsors-{}", s.id), None),
4141
})

src/styles/app.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,3 +746,8 @@ blockquote::before {
746746
#pb4 {
747747
padding-bottom: 3.8em;
748748
}
749+
750+
.max-height-5rem {
751+
/* Tachyons is missing this class */
752+
max-height: 5rem;
753+
}

static/images/sponsor-logos/aws.png

-38.6 KB
Binary file not shown.

static/images/sponsor-logos/aws.svg

Lines changed: 1 addition & 0 deletions
Loading
-26.6 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Loading
-14.4 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Loading

templates/sponsors/index.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
{{#each data as |sponsor|}}
2121
{{#if sponsor.is_not_first}}
22-
<hr size="1" noshade>
22+
<hr size="1" noshade class="mv4">
2323
{{/if}}
2424
<div class="flex-none flex-l mt5-l">
25-
<div class="w-100 w-30-l tc">
26-
<img alt="{{sponsor.logo_alt_i18n}}" src="{{sponsor.logo_path}}" />
25+
<div class="mv3 mv0-ns w-100 w-30-l tc flex items-center justify-center">
26+
<img class="ph5 max-height-5rem" alt="{{sponsor.logo_alt_i18n}}" src="{{sponsor.logo_path}}" />
2727
</div>
2828
<div class="w-100 w-70-l">
2929
<h3>{{sponsor.name}}</h3>

0 commit comments

Comments
 (0)