Skip to content

Commit afc0e6a

Browse files
authored
Add CORP headers to media repo (#1197)
* Add CORP headers to media repo MSC: matrix-org/matrix-spec-proposals#3828 * Write weird CSS rules to make added-in work inline in the CS spec Even though our content doesn't need 2 paragraphs, it's good to have the capability to render it in the future. * Remove test paragraph * Refine prose * spelling is key
1 parent b14759a commit afc0e6a

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

assets/scss/custom.scss

+23
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,29 @@ footer {
260260
border-left-width: 5px;
261261
background: $warning-background;
262262
}
263+
264+
// XXX: See the added-in-paragraph.html shortcode for more information on these styles.
265+
&.added-in-paragraph {
266+
// Remove the padding and margin to remove the box look
267+
margin: 0 !important; // !important on both to override table-related rules
268+
padding: 0 !important;
269+
270+
// Make pairs of "added-in" and content inline to each other. We do pairs so authors can
271+
// describe two paragraphs with added-in prefixes within a single box, reducing DOM
272+
// complexity. Each paragraph is expected to be prefixed with an added-in, however.
273+
//
274+
// XXX: We assume the added-in and text will be rendered as paragraph elements.
275+
> p {
276+
display: inline;
277+
}
278+
> p:nth-child(2n) { // "even" rule to target just the content paragraphs
279+
// Force a paragraph break after the content (insert a couple <br /> tags)
280+
&::after {
281+
content: '\A\A';
282+
white-space: pre;
283+
}
284+
}
285+
}
263286
}
264287

265288
/* Styles for sections that are rendered from data, such as HTTP APIs and event schemas */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add `Cross-Origin-Resource-Policy` (CORP) headers to media repository, as per [MSC3828](https://github.com/matrix-org/matrix-spec-proposals/pull/3828).

content/client-server-api/modules/content_repo.md

+7
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ When serving content, the server SHOULD provide a
1919
`Content-Security-Policy` header. The recommended policy is
2020
`sandbox; default-src 'none'; script-src 'none'; plugin-types application/pdf; style-src 'unsafe-inline'; object-src 'self';`.
2121

22+
{{% boxes/added-in-paragraph %}}
23+
{{< added-in v="1.4" >}} The server SHOULD additionally provide
24+
`Cross-Origin-Resource-Policy: cross-origin` when serving content to allow
25+
(web) clients to access restricted APIs such as `SharedArrayBuffer` when
26+
interacting with the media repository.
27+
{{% /boxes/added-in-paragraph %}}
28+
2229
#### Matrix Content (MXC) URIs
2330

2431
Content locations are represented as Matrix Content (MXC) URIs. They
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{/*
2+
3+
"Temporary" shortcode for rendering paragraphs which want/need inline added-in tags. It is
4+
assumed that your content is described as follows:
5+
6+
{{% boxes/added-in-paragraph %}}
7+
{{< added-in v="1.4" >}} Your text here
8+
9+
{{< added-in v="1.4" >}} Your other text here
10+
{{% /boxes/added-in-paragraph %}}
11+
12+
The assumption is that at a later date this added-in-paragraph shortcode can be removed, making
13+
the angle bracket-defined added-in shortcodes *just work*.
14+
15+
It is important that each new "content" paragraph (the bit after added-in) is preceded with
16+
and added-in, otherwise you might find your text being weirdly merged.
17+
18+
This exists while the added-in shortcode cannot be inline in the client-server spec.
19+
See https://github.com/matrix-org/matrix-spec/issues/1204
20+
21+
*/}}
22+
{{ partial "alert" (dict "type" "added-in-paragraph" "content" .Inner) }}

0 commit comments

Comments
 (0)