mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-04-29 13:54:10 +02:00
Compare commits
10 commits
063c2a2381
...
e8ae84ae68
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8ae84ae68 | ||
|
|
705240da72 | ||
|
|
4dbe080570 | ||
|
|
7a1eb81c9c | ||
|
|
22c0952003 | ||
|
|
a5afe542c0 | ||
|
|
1baf93caf5 | ||
|
|
ffc8c8edd3 | ||
|
|
35eb6e1d2b | ||
|
|
7f59715369 |
114
assets/js/versions.template.js
Normal file
114
assets/js/versions.template.js
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
/*
|
||||||
|
Copyright 2025 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Determine the current version as defined in hugo.toml. This will either be
|
||||||
|
// "unstable" or "vX.X" and doesn't depend on the current URL.
|
||||||
|
//
|
||||||
|
// The oddity below is an attempt at producing a readable Hugo template while
|
||||||
|
// avoiding JS syntax errors in your IDE.
|
||||||
|
const currentVersion = `{{ if eq .Site.Params.version.status "unstable" }}
|
||||||
|
{{- /**/ -}}
|
||||||
|
unstable
|
||||||
|
{{- /**/ -}}
|
||||||
|
{{ else }}
|
||||||
|
{{- /**/ -}}
|
||||||
|
{{ printf "v%s.%s" .Site.Params.version.major .Site.Params.version.minor }}
|
||||||
|
{{- /**/ -}}
|
||||||
|
{{ end }}`;
|
||||||
|
|
||||||
|
// Determine the current version segment by regex matching the URL. This will either
|
||||||
|
// be "unstable", "latest", "vX.X" (production) or undefined (local & netlify).
|
||||||
|
const href = window.location.href;
|
||||||
|
const segmentMatches = href.match(/(?<=\/)unstable|latest|v\d+.\d+(?=\/)/);
|
||||||
|
const currentSegment = segmentMatches ? segmentMatches[0] : undefined;
|
||||||
|
|
||||||
|
// Determine the selected menu element. If we were able to obtain the version
|
||||||
|
// segment from the URL (production), use that. Otherwise (local & netlify),
|
||||||
|
// fall back to the version as defined in Hugo.
|
||||||
|
const selected = currentSegment ?? currentVersion;
|
||||||
|
|
||||||
|
function appendVersion(parent, name, segment, url) {
|
||||||
|
// The list item
|
||||||
|
const li = document.createElement("li");
|
||||||
|
if (segment === selected) {
|
||||||
|
li.classList.add("selected");
|
||||||
|
}
|
||||||
|
if (segment === "latest") {
|
||||||
|
li.classList.add("latest");
|
||||||
|
}
|
||||||
|
parent.appendChild(li);
|
||||||
|
|
||||||
|
// The link
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.classList.add("dropdown-item");
|
||||||
|
a.setAttribute("href", url);
|
||||||
|
li.appendChild(a);
|
||||||
|
|
||||||
|
// Handle clicks manually to preserve the current path / fragment
|
||||||
|
a.addEventListener("click", (ev) => {
|
||||||
|
// If the URL is a relative link (i.e. the historical versions changelog), just
|
||||||
|
// let the browser load it
|
||||||
|
if (url.startsWith("/")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we couldn't determine the current segment, we cannot safely replace
|
||||||
|
// it and have to let the browser load the (root) URL instead
|
||||||
|
if (!currentSegment) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, stop further event handling and replace the segment
|
||||||
|
ev.preventDefault();
|
||||||
|
ev.stopPropagation();
|
||||||
|
window.location.href = href.replace(`/${currentSegment}/`, `/${segment}/`);
|
||||||
|
});
|
||||||
|
|
||||||
|
// The link text
|
||||||
|
const text = document.createTextNode(name);
|
||||||
|
a.appendChild(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we're in the unstable version, we're the latest thing and can just load
|
||||||
|
// versions.json from our own resources. Otherwise, we fall back to loading it
|
||||||
|
// from /unstable/versions.json, assuming we are on the spec.matrix.org deployment.
|
||||||
|
const url = currentVersion === "unstable"
|
||||||
|
? '{{ .Site.Home.Permalink }}versions.json'
|
||||||
|
: "/unstable/versions.json";
|
||||||
|
|
||||||
|
fetch(url)
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(versions => {
|
||||||
|
// Find the surrounding list element
|
||||||
|
const ul = document.querySelector("ul#version-selector");
|
||||||
|
if (!ul) {
|
||||||
|
console.error("Cannot populate version selector: ul element not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a entries for the unstable version and the "latest" shortcut
|
||||||
|
appendVersion(ul, "unstable", "unstable", "https://spec.matrix.org/unstable");
|
||||||
|
const latestName = versions?.length ? `latest (${versions[0].name})` : "latest";
|
||||||
|
appendVersion(ul, latestName, "latest", "https://spec.matrix.org/latest");
|
||||||
|
|
||||||
|
// Add an entry for each proper version
|
||||||
|
for (const version of versions) {
|
||||||
|
appendVersion(ul, version.name, version.name, `https://spec.matrix.org/${version.name}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// For historical versions, simply link to the changelog
|
||||||
|
appendVersion(ul, "historical", '{{ (site.GetPage "changelog/historical").RelPermalink }}');
|
||||||
|
});
|
||||||
|
|
@ -50,6 +50,25 @@ Custom SCSS for the Matrix spec
|
||||||
a {
|
a {
|
||||||
color: $black;
|
color: $black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Make the version dropdown scroll if it's too large */
|
||||||
|
ul#version-selector {
|
||||||
|
max-height: 80vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* As these styles are only applied by JavaScript, PurgeCSS doesn't see them
|
||||||
|
* in the source code and removes them unless we explicitly tell it not to.
|
||||||
|
*/
|
||||||
|
/* purgecss start ignore */
|
||||||
|
ul#version-selector li.selected a {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul#version-selector li.latest a {
|
||||||
|
color: $secondary;
|
||||||
|
}
|
||||||
|
/* purgecss end ignore */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Styles for the sidebar nav */
|
/* Styles for the sidebar nav */
|
||||||
|
|
|
||||||
1
changelogs/internal/newsfragments/2222.clarification
Normal file
1
changelogs/internal/newsfragments/2222.clarification
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Clarify vendor prefixing requirements.
|
||||||
1
changelogs/internal/newsfragments/2256.clarification
Normal file
1
changelogs/internal/newsfragments/2256.clarification
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add version picker in the navbar.
|
||||||
1
changelogs/internal/newsfragments/2258.clarification
Normal file
1
changelogs/internal/newsfragments/2258.clarification
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add version picker in the navbar.
|
||||||
1
changelogs/internal/newsfragments/2259.clarification
Normal file
1
changelogs/internal/newsfragments/2259.clarification
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add version picker in the navbar.
|
||||||
1
changelogs/internal/newsfragments/2260.clarification
Normal file
1
changelogs/internal/newsfragments/2260.clarification
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add version picker in the navbar.
|
||||||
1
changelogs/internal/newsfragments/2261.clarification
Normal file
1
changelogs/internal/newsfragments/2261.clarification
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add version picker in the navbar.
|
||||||
|
|
@ -78,6 +78,10 @@ current_version_url = "https://spec.matrix.org/latest"
|
||||||
# major = "1"
|
# major = "1"
|
||||||
# minor = "16"
|
# minor = "16"
|
||||||
|
|
||||||
|
[[params.versions]]
|
||||||
|
# We must include this parameter to enable docsy's version picker in the navbar. The picker
|
||||||
|
# is populated automatically in navbar-version-selector.html.
|
||||||
|
|
||||||
# User interface configuration
|
# User interface configuration
|
||||||
[params.ui]
|
[params.ui]
|
||||||
# Collapse HTTP API and event <details> elements
|
# Collapse HTTP API and event <details> elements
|
||||||
|
|
|
||||||
|
|
@ -408,41 +408,9 @@ development or testing data.
|
||||||
that a particular MSC works) do not have to follow this process.
|
that a particular MSC works) do not have to follow this process.
|
||||||
|
|
||||||
1. Have an idea for a feature.
|
1. Have an idea for a feature.
|
||||||
1. Implement the feature using unstable endpoints, vendor prefixes, and
|
1. Implement the feature using [unstable endpoints, vendor prefixes, and
|
||||||
unstable feature flags as appropriate.
|
unstable feature flags](#unstable-endpoints-features-and-vendor-prefixes)
|
||||||
- When using unstable endpoints, they MUST include a vendor
|
as appropriate.
|
||||||
prefix. For example:
|
|
||||||
`/_matrix/client/unstable/com.example/login`. Vendor prefixes
|
|
||||||
throughout Matrix always use the Java package naming convention.
|
|
||||||
The MSC for the feature should identify which preferred vendor
|
|
||||||
prefix is to be used by early adopters.
|
|
||||||
- Note that unstable namespaces do not automatically inherit
|
|
||||||
endpoints from stable namespaces: for example, the fact that
|
|
||||||
`/_matrix/client/r0/sync` exists does not imply that
|
|
||||||
`/_matrix/client/unstable/com.example/sync` exists.
|
|
||||||
- If the client needs to be sure the server supports the feature,
|
|
||||||
an unstable feature flag that MUST be vendor prefixed is to be
|
|
||||||
used. This kind of flag shows up in the `unstable_features`
|
|
||||||
section of `/versions` as, for example, `com.example.new_login`.
|
|
||||||
The MSC for the feature should identify which preferred feature
|
|
||||||
flag is to be used by early adopters.
|
|
||||||
- When using this approach correctly, the implementation can
|
|
||||||
ship/release the feature at any time, so long as the
|
|
||||||
implementation is able to accept the technical debt that results
|
|
||||||
from needing to provide adequate backwards and forwards
|
|
||||||
compatibility. The implementation MUST support the flag (and
|
|
||||||
server-side implementation) disappearing and be generally safe
|
|
||||||
for users. Note that implementations early in the MSC review
|
|
||||||
process may also be required to provide backwards compatibility
|
|
||||||
with earlier editions of the proposal.
|
|
||||||
- If the implementation cannot support the technical debt (or if
|
|
||||||
it's impossible to provide forwards/backwards compatibility -
|
|
||||||
e.g. a user authentication change which can't be safely rolled
|
|
||||||
back), the implementation should not attempt to implement the
|
|
||||||
feature and should instead wait for a spec release.
|
|
||||||
- If at any point after early release, the idea changes in a
|
|
||||||
backwards-incompatible way, the feature flag should also change
|
|
||||||
so that implementations can adapt as needed.
|
|
||||||
1. In parallel, or ahead of implementation, open an MSC and solicit
|
1. In parallel, or ahead of implementation, open an MSC and solicit
|
||||||
review per above.
|
review per above.
|
||||||
1. Before FCP can be called, the Spec Core Team will require evidence
|
1. Before FCP can be called, the Spec Core Team will require evidence
|
||||||
|
|
@ -452,10 +420,7 @@ that a particular MSC works) do not have to follow this process.
|
||||||
forwards/backwards compatibility concerns mentioned here.
|
forwards/backwards compatibility concerns mentioned here.
|
||||||
1. The FCP process is completed, and assuming nothing is flagged the
|
1. The FCP process is completed, and assuming nothing is flagged the
|
||||||
MSC lands.
|
MSC lands.
|
||||||
1. Implementations can now switch to using stable prefixes
|
1. Implementations can now switch to using stable prefixes, assuming that the change
|
||||||
(for example, for an endpoint, moving from
|
|
||||||
`/unstable/org.matrix.mscxxxx/frobnicate`
|
|
||||||
to `/v1/frobnicate`), assuming that the change
|
|
||||||
is backwards compatible with older implementations. In the rare occasion
|
is backwards compatible with older implementations. In the rare occasion
|
||||||
where backwards compatibility is not possible without a new spec release,
|
where backwards compatibility is not possible without a new spec release,
|
||||||
implementations should continue to use unstable prefixes.
|
implementations should continue to use unstable prefixes.
|
||||||
|
|
@ -471,13 +436,6 @@ that a particular MSC works) do not have to follow this process.
|
||||||
started supporting the new spec release, some noise should be raised
|
started supporting the new spec release, some noise should be raised
|
||||||
in the general direction of the implementation.
|
in the general direction of the implementation.
|
||||||
|
|
||||||
{{% boxes/note %}}
|
|
||||||
MSCs MUST still describe what the stable endpoints/feature looks like
|
|
||||||
with a note towards the bottom for what the unstable feature
|
|
||||||
flag/prefixes are. For example, an MSC would propose `/_matrix/client/r0/new/endpoint`, not `/_matrix/client/unstable/
|
|
||||||
com.example/new/endpoint`.
|
|
||||||
{{% /boxes/note %}}
|
|
||||||
|
|
||||||
In summary:
|
In summary:
|
||||||
|
|
||||||
- Implementations MUST NOT use stable endpoints before the MSC has
|
- Implementations MUST NOT use stable endpoints before the MSC has
|
||||||
|
|
@ -489,14 +447,90 @@ In summary:
|
||||||
- Implementations SHOULD be wary of the technical debt they are
|
- Implementations SHOULD be wary of the technical debt they are
|
||||||
incurring by moving faster than the spec.
|
incurring by moving faster than the spec.
|
||||||
- The vendor prefix is chosen by the developer of the feature, using
|
- The vendor prefix is chosen by the developer of the feature, using
|
||||||
the Java package naming convention. The foundation's preferred
|
the Java package naming convention.
|
||||||
vendor prefix is `org.matrix`.
|
|
||||||
- The vendor prefixes, unstable feature flags, and unstable endpoints
|
- The vendor prefixes, unstable feature flags, and unstable endpoints
|
||||||
should be included in the MSC, though the MSC MUST be written in a
|
should be included in the MSC, though the MSC MUST be written in a
|
||||||
way that proposes new stable endpoints. Typically this is solved by
|
way that proposes new stable endpoints. Typically this is solved by
|
||||||
a small table at the bottom mapping the various values from stable
|
a small table at the bottom mapping the various values from stable
|
||||||
to unstable.
|
to unstable.
|
||||||
|
|
||||||
|
#### Unstable endpoints, features and vendor prefixes
|
||||||
|
|
||||||
|
Unstable endpoints MUST use `/unstable` as the endpoint version and a
|
||||||
|
vendor prefix in Java package naming format. For example:
|
||||||
|
`/_matrix/client/unstable/com.example.mscxxxx/login`.
|
||||||
|
|
||||||
|
{{% boxes/note %}}
|
||||||
|
Proposal authors operating with a Matrix.org Foundation mandate SHOULD use
|
||||||
|
a vendor prefix within the `org.matrix` namespace. This namespace is otherwise
|
||||||
|
restricted. Authors who don't own a domain MAY use the `io.github` namespace
|
||||||
|
instead.
|
||||||
|
{{% /boxes/note %}}
|
||||||
|
|
||||||
|
Note that unstable namespaces do not automatically inherit endpoints from
|
||||||
|
stable namespaces: for example, the fact that `/_matrix/client/v3/sync`
|
||||||
|
exists does not imply that `/_matrix/client/unstable/com.example.mscxxxx/sync`
|
||||||
|
exists.
|
||||||
|
|
||||||
|
Vendor prefixes MUST also be used for:
|
||||||
|
|
||||||
|
- New parameters on existing endpoints. For example:
|
||||||
|
`/_matrix/client/v3/publicRooms?com.example.mscxxxx.ordered_by=member_count`.
|
||||||
|
- New properties in existing JSON objects. For example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"avatar_url": "mxc://matrix.org/SDGdghriugerRg",
|
||||||
|
"displayname": "Alice Margatroid",
|
||||||
|
"com.example.mscxxxx.phone": [{
|
||||||
|
"type": "landline",
|
||||||
|
"number": "+1-206-555-7000"
|
||||||
|
}],
|
||||||
|
...
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- New values for existing parameters or properties. For example:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"errcode": "COM.EXAMPLE.MSCXXXX.M_INVALID_EMAIL",
|
||||||
|
"error": "The email address you provided is invalid."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
If the client needs to be sure the server supports the feature, an
|
||||||
|
unstable feature flag that MUST also be vendor prefixed is to be used.
|
||||||
|
This flag shows up in the `unstable_features` section of
|
||||||
|
[`/_matrix/client/versions`](/client-server-api/#get_matrixclientversions)
|
||||||
|
as, for example, `com.example.mscxxxx.new_login`.
|
||||||
|
|
||||||
|
{{% boxes/note %}}
|
||||||
|
MSCs MUST still describe what the stable endpoints/feature looks like
|
||||||
|
with a note towards the bottom for what the unstable feature
|
||||||
|
flag/prefixes are. For example, an MSC would propose `/_matrix/client/v1/new/endpoint`,
|
||||||
|
not `/_matrix/client/unstable/com.example.mscxxxx/new/endpoint`.
|
||||||
|
{{% /boxes/note %}}
|
||||||
|
|
||||||
|
When using this approach correctly, the implementation can release
|
||||||
|
the feature at any time, so long as the implementation is able to
|
||||||
|
accept the technical debt that results from needing to provide
|
||||||
|
adequate backwards and forwards compatibility. The implementation
|
||||||
|
MUST support the flag (and server-side implementation) disappearing
|
||||||
|
and be generally safe for users. Note that implementations early in
|
||||||
|
the MSC review process may also be required to provide backwards
|
||||||
|
compatibility with earlier editions of the proposal.
|
||||||
|
|
||||||
|
If the implementation cannot support the technical debt (or if it's
|
||||||
|
impossible to provide forwards/backwards compatibility - e.g. a user
|
||||||
|
authentication change which can't be safely rolled back), the
|
||||||
|
implementation should not attempt to implement the feature and should
|
||||||
|
instead wait for a spec release.
|
||||||
|
|
||||||
|
If at any point after early release, the idea changes in a
|
||||||
|
backwards-incompatible way, the feature flag should also change so
|
||||||
|
that implementations can adapt as needed.
|
||||||
|
|
||||||
### Placeholder MSCs
|
### Placeholder MSCs
|
||||||
|
|
||||||
Some proposals may contain security-sensitive or private context which can't be
|
Some proposals may contain security-sensitive or private context which can't be
|
||||||
|
|
|
||||||
|
|
@ -8,3 +8,10 @@
|
||||||
*/}}
|
*/}}
|
||||||
{{ $toc := resources.Get "js/toc.js" -}}
|
{{ $toc := resources.Get "js/toc.js" -}}
|
||||||
<script defer src="{{ $toc.RelPermalink }}"></script>
|
<script defer src="{{ $toc.RelPermalink }}"></script>
|
||||||
|
|
||||||
|
{{- /* Load the versions script template, run and publish it */ -}}
|
||||||
|
{{ with resources.Get "js/versions.template.js" }}
|
||||||
|
{{ with resources.ExecuteAsTemplate "js/versions.js" $ . }}
|
||||||
|
<script defer src="{{ .RelPermalink }}"></script>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
|
||||||
18
layouts/_partials/navbar-version-selector.html
Normal file
18
layouts/_partials/navbar-version-selector.html
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{{- /*
|
||||||
|
|
||||||
|
A version of the navbar-version-selector.html partial in Docsy,
|
||||||
|
modified to read the versions from /versions.json.
|
||||||
|
|
||||||
|
*/ -}}
|
||||||
|
|
||||||
|
{{ $changelog := site.GetPage "changelog" }}
|
||||||
|
{{ $pages := $changelog.RegularPages.ByDate.Reverse }}
|
||||||
|
|
||||||
|
<div class="dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
All Versions
|
||||||
|
</a>
|
||||||
|
<ul class="dropdown-menu" id="version-selector">
|
||||||
|
{{- /* The menu is built by versions.template.js */ -}}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
@ -5,6 +5,25 @@
|
||||||
|
|
||||||
*/}}
|
*/}}
|
||||||
|
|
||||||
|
{{/* Generate a static file versions.json that can be used to populate the version picker */}}
|
||||||
|
{{ if .IsHome }}
|
||||||
|
{{- /* Load all changelog subpages, sorted by release date */ -}}
|
||||||
|
{{ $changelog := site.GetPage "changelog" }}
|
||||||
|
{{ $pages := $changelog.RegularPages.ByDate.Reverse }}
|
||||||
|
|
||||||
|
{{- /* Collect proper versions and build metadata dicts */ -}}
|
||||||
|
{{ $versions := slice }}
|
||||||
|
{{ range $pages }}
|
||||||
|
{{ if findRE `^v[0-9]+\.[0-9]+$` .Params.linkTitle }}
|
||||||
|
{{ $versions = $versions | append (dict "name" .Params.linkTitle "date" .Params.date ) }}
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{- /* Generate the JSON */ -}}
|
||||||
|
{{ $json := jsonify $versions }}
|
||||||
|
{{ $noop := (resources.FromString "/versions.json" $json).Permalink }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html itemscope itemtype="http://schema.org/WebPage"
|
<html itemscope itemtype="http://schema.org/WebPage"
|
||||||
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
|
{{- with .Site.Language.LanguageDirection }} dir="{{ . }}" {{- end -}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue