mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-04-27 04:54:08 +02:00
Compare commits
10 commits
fdd2a9abe8
...
e679a00720
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e679a00720 | ||
|
|
7dfd746e06 | ||
|
|
77f7e8104a | ||
|
|
b3d4f9a96e | ||
|
|
22f3cc009b | ||
|
|
ce3aecab38 | ||
|
|
252de984cc | ||
|
|
a6112535bf | ||
|
|
6a001cccb0 | ||
|
|
0b5db68242 |
164
assets/js/offline-search.js
Normal file
164
assets/js/offline-search.js
Normal file
|
|
@ -0,0 +1,164 @@
|
||||||
|
/*
|
||||||
|
Copyright 2026 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
Adapted from [1] to combine Docsy's built-in search UI with the Pagefind
|
||||||
|
search backend.
|
||||||
|
|
||||||
|
[1]: https://github.com/matrix-org/docsy/blob/71d103ebb20ace3d528178c4b6d92b6cc4f7fd53/assets/js/offline-search.js
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
$(document).ready(async function () {
|
||||||
|
const pagefind = await import("/pagefind/pagefind.js");
|
||||||
|
const $searchInput = $('.td-search input');
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lazily initialise Pagefind only when the user is about to start a search.
|
||||||
|
//
|
||||||
|
|
||||||
|
$searchInput.focus(() => {
|
||||||
|
pagefind.init();
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Register handler
|
||||||
|
//
|
||||||
|
|
||||||
|
$searchInput.on('change', (event) => {
|
||||||
|
render($(event.target));
|
||||||
|
|
||||||
|
// Hide keyboard on mobile browser
|
||||||
|
$searchInput.blur();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Prevent reloading page by enter key on sidebar search.
|
||||||
|
$searchInput.closest('form').on('submit', () => {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Pagefind
|
||||||
|
//
|
||||||
|
|
||||||
|
const render = async ($targetSearchInput) => {
|
||||||
|
//
|
||||||
|
// Dispose existing popover
|
||||||
|
//
|
||||||
|
|
||||||
|
{
|
||||||
|
let popover = bootstrap.Popover.getInstance($targetSearchInput[0]);
|
||||||
|
if (popover !== null) {
|
||||||
|
popover.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Search
|
||||||
|
//
|
||||||
|
|
||||||
|
const searchQuery = $targetSearchInput.val();
|
||||||
|
if (searchQuery === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const search = await pagefind.debouncedSearch(searchQuery);
|
||||||
|
if (search === null) {
|
||||||
|
// A more recent search call has been made, nothing to do.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const results = await Promise.all(search.results.slice(0, 20).map(r => r.data()));
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make result html
|
||||||
|
//
|
||||||
|
|
||||||
|
const $html = $('<div>');
|
||||||
|
|
||||||
|
$html.append(
|
||||||
|
$('<div>')
|
||||||
|
.css({
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
marginBottom: '1em',
|
||||||
|
})
|
||||||
|
.append(
|
||||||
|
$('<span>').text('Search results').css({ fontWeight: 'bold' })
|
||||||
|
)
|
||||||
|
.append(
|
||||||
|
$('<span>').addClass('td-offline-search-results__close-button')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const $searchResultBody = $('<div>').css({
|
||||||
|
maxHeight: `calc(100vh - ${
|
||||||
|
$targetSearchInput.offset().top - $(window).scrollTop() + 180
|
||||||
|
}px)`,
|
||||||
|
overflowY: 'auto',
|
||||||
|
});
|
||||||
|
$html.append($searchResultBody);
|
||||||
|
|
||||||
|
if (results.length === 0) {
|
||||||
|
$searchResultBody.append(
|
||||||
|
$('<p>').text(`No results found for query "${searchQuery}"`)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
results.forEach((r) => {
|
||||||
|
r.sub_results.forEach((s) => {
|
||||||
|
const href = s.url;
|
||||||
|
|
||||||
|
const $entry = $('<div>').addClass('mt-4');
|
||||||
|
|
||||||
|
$entry.append(
|
||||||
|
$('<small>').addClass('d-block text-body-secondary').text(r.meta.title)
|
||||||
|
);
|
||||||
|
|
||||||
|
$entry.append(
|
||||||
|
$('<a>')
|
||||||
|
.addClass('d-block')
|
||||||
|
.css({
|
||||||
|
fontSize: '1.2rem',
|
||||||
|
})
|
||||||
|
.attr('href', href)
|
||||||
|
.text(s.title)
|
||||||
|
);
|
||||||
|
|
||||||
|
$entry.append($('<p>').html(s.excerpt));
|
||||||
|
|
||||||
|
$searchResultBody.append($entry);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$targetSearchInput.one('shown.bs.popover', () => {
|
||||||
|
$('.td-offline-search-results__close-button').on('click', () => {
|
||||||
|
$targetSearchInput.val('');
|
||||||
|
$targetSearchInput.trigger('change');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const popover = new bootstrap.Popover($targetSearchInput, {
|
||||||
|
content: $html[0],
|
||||||
|
html: true,
|
||||||
|
customClass: 'td-offline-search-results',
|
||||||
|
placement: 'bottom',
|
||||||
|
});
|
||||||
|
popover.show();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})(jQuery);
|
||||||
|
|
@ -662,8 +662,7 @@ dd {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Style for page search */
|
/* Style for the page search widget */
|
||||||
#search {
|
.td-offline-search-results {
|
||||||
display: none;
|
max-width: 460px;
|
||||||
padding-bottom: 1rem;
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Fix various typos throughout the specification.
|
||||||
1
changelogs/client_server/newsfragments/2315.feature
Normal file
1
changelogs/client_server/newsfragments/2315.feature
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add `M_USER_LIMIT_EXCEEDED` common error code, as per [MSC4335](https://github.com/matrix-org/matrix-spec-proposals/pull/4335).
|
||||||
1
changelogs/client_server/newsfragments/2328.feature
Normal file
1
changelogs/client_server/newsfragments/2328.feature
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add the `is_animated` flag to the `info` object of the `m.image` msgtype and the `m.sticker` event, as per [MSC4230](https://github.com/matrix-org/matrix-spec-proposals/pull/4230).
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Fix various typos throughout the specification.
|
||||||
1
changelogs/client_server/newsfragments/2338.feature
Normal file
1
changelogs/client_server/newsfragments/2338.feature
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add the `is_animated` flag to the `info` object of the `m.image` msgtype and the `m.sticker` event, as per [MSC4230](https://github.com/matrix-org/matrix-spec-proposals/pull/4230).
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Add link to JSON signing algorithm in server-server auth section for clarity. Contributed by @thetayloredman.
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
Fix various typos throughout the specification.
|
||||||
|
|
@ -66,6 +66,7 @@ description = "Home of the Matrix specification for decentralised communication"
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
copyright = "The Matrix.org Foundation C.I.C."
|
copyright = "The Matrix.org Foundation C.I.C."
|
||||||
|
offlineSearch = true
|
||||||
|
|
||||||
[params.version]
|
[params.version]
|
||||||
# must be one of "unstable", "current", "historical"
|
# must be one of "unstable", "current", "historical"
|
||||||
|
|
@ -151,7 +152,8 @@ sidebar_menu_compact = true
|
||||||
[server.headers.values]
|
[server.headers.values]
|
||||||
# `style-src 'unsafe-inline'` is needed to correctly render the maths in the Olm spec:
|
# `style-src 'unsafe-inline'` is needed to correctly render the maths in the Olm spec:
|
||||||
# https://github.com/KaTeX/KaTeX/issues/4096
|
# https://github.com/KaTeX/KaTeX/issues/4096
|
||||||
Content-Security-Policy = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' data:; connect-src 'self'; font-src 'self' data:; media-src 'self'; child-src 'self'; form-action 'self'; object-src 'self'"
|
# TODO: Figure out CSP to allow loading the Pagefind Wasm
|
||||||
|
#Content-Security-Policy = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self'; img-src 'self' data:; connect-src 'self'; font-src 'self' data:; media-src 'self'; child-src 'self'; form-action 'self'; object-src 'self'"
|
||||||
X-XSS-Protection = "1; mode=block"
|
X-XSS-Protection = "1; mode=block"
|
||||||
X-Content-Type-Options = "nosniff"
|
X-Content-Type-Options = "nosniff"
|
||||||
# Strict-Transport-Security = "max-age=31536000; includeSubDomains; preload"
|
# Strict-Transport-Security = "max-age=31536000; includeSubDomains; preload"
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ For the `users` namespace, application services can only register interest in
|
||||||
homeserver). Events affecting users on other homeservers are not sent to an application
|
homeserver). Events affecting users on other homeservers are not sent to an application
|
||||||
service, even if the user happens to match the one of the `users` namespaces (unless,
|
service, even if the user happens to match the one of the `users` namespaces (unless,
|
||||||
of course, the event affects a room that the application service is interested in
|
of course, the event affects a room that the application service is interested in
|
||||||
for another room - for example, because there is another user in the room that the
|
for another reason - for example, because there is another user in the room that the
|
||||||
application service is interested in).
|
application service is interested in).
|
||||||
|
|
||||||
For the `rooms` and `aliases` namespaces, all events in a matching room will be
|
For the `rooms` and `aliases` namespaces, all events in a matching room will be
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,37 @@ state (e.g.: sending messages, account data, etc) and not routes which
|
||||||
only read state (e.g.: [`/sync`](#get_matrixclientv3sync),
|
only read state (e.g.: [`/sync`](#get_matrixclientv3sync),
|
||||||
[`/user/{userId}/account_data/{type}`](#get_matrixclientv3useruseridaccount_datatype), etc).
|
[`/user/{userId}/account_data/{type}`](#get_matrixclientv3useruseridaccount_datatype), etc).
|
||||||
|
|
||||||
|
`M_USER_LIMIT_EXCEEDED`
|
||||||
|
: {{% added-in v="1.18" %}} The request cannot be completed because the user has
|
||||||
|
exceeded (or the request would cause them to exceed) a limit associated with
|
||||||
|
their account. For example, a user may have reached their allocated storage
|
||||||
|
quota, reached a maximum number of allowed rooms, devices, or other
|
||||||
|
account-scoped resources, or exceeded usage limits for specific features.
|
||||||
|
|
||||||
|
: The error response MUST have an `info_uri` field (string), which is a URI
|
||||||
|
that the client can present to the user to provide more context on the
|
||||||
|
encountered limit and, if applicable, guidance on how to increase the limit.
|
||||||
|
The homeserver MAY return different values for `info_uri` depending on the type
|
||||||
|
of limit reached.
|
||||||
|
|
||||||
|
: The error response MAY include a `can_upgrade` field (boolean, default `false`).
|
||||||
|
If `true`, it indicates that the specific limit encountered can be increased,
|
||||||
|
for example by upgrading the user's account tier. If absent or `false`, the
|
||||||
|
limit is a hard limit that cannot be increased.
|
||||||
|
|
||||||
|
: The HTTP status code will depend on depend on the particular endpoint.
|
||||||
|
|
||||||
|
: Example response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"errcode": "M_USER_LIMIT_EXCEEDED",
|
||||||
|
"error": "You have exceeded your storage quota of 10GB",
|
||||||
|
"info_uri": "https://example.com/homeserver/about?limit_type=quota",
|
||||||
|
"can_upgrade": true
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
`M_UNKNOWN`
|
`M_UNKNOWN`
|
||||||
: An unknown error has occurred.
|
: An unknown error has occurred.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,7 @@ request.
|
||||||
|
|
||||||
The prompt for Bob to accept/reject Alice's request (or the unsupported method
|
The prompt for Bob to accept/reject Alice's request (or the unsupported method
|
||||||
prompt) should be automatically dismissed 10 minutes after the `timestamp` (in
|
prompt) should be automatically dismissed 10 minutes after the `timestamp` (in
|
||||||
the case of to-device messages) or `origin_ts` (in the case of in-room
|
the case of to-device messages) or `origin_server_ts` (in the case of in-room
|
||||||
messages) field or 2 minutes after Bob's client receives the message, whichever
|
messages) field or 2 minutes after Bob's client receives the message, whichever
|
||||||
comes first, if Bob does not interact with the prompt. The prompt should
|
comes first, if Bob does not interact with the prompt. The prompt should
|
||||||
additionally be hidden if an appropriate `m.key.verification.cancel` message is
|
additionally be hidden if an appropriate `m.key.verification.cancel` message is
|
||||||
|
|
|
||||||
|
|
@ -277,12 +277,12 @@ queried from multiple servers to mitigate against DNS spoofing.
|
||||||
|
|
||||||
Every HTTP request made by a homeserver is authenticated using public
|
Every HTTP request made by a homeserver is authenticated using public
|
||||||
key digital signatures. The request method, target and body are signed
|
key digital signatures. The request method, target and body are signed
|
||||||
by wrapping them in a JSON object and signing it using the JSON signing
|
by wrapping them in a JSON object and signing it using the [JSON signing
|
||||||
algorithm. The resulting signatures are added as an Authorization header
|
algorithm](/appendices#signing-json). The resulting signatures are added
|
||||||
with an auth scheme of `X-Matrix`. Note that the target field should
|
as an Authorization header with an auth scheme of `X-Matrix`. Note that
|
||||||
include the full path starting with `/_matrix/...`, including the `?`
|
the target field should include the full path starting with `/_matrix/...`,
|
||||||
and any query parameters if present, but should not include the leading
|
including the `?` and any query parameters if present, but should not
|
||||||
`https:`, nor the destination server's hostname.
|
include the leading `https:`, nor the destination server's hostname.
|
||||||
|
|
||||||
Step 1 sign JSON:
|
Step 1 sign JSON:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
"h": 398,
|
"h": 398,
|
||||||
"w": 394,
|
"w": 394,
|
||||||
"mimetype": "image/jpeg",
|
"mimetype": "image/jpeg",
|
||||||
"size": 31037
|
"size": 31037,
|
||||||
|
"is_animated": false
|
||||||
},
|
},
|
||||||
"url": "mxc://example.org/JWEIFJgwEIhweiWJE",
|
"url": "mxc://example.org/JWEIFJgwEIhweiWJE",
|
||||||
"msgtype": "m.image"
|
"msgtype": "m.image"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@
|
||||||
"mimetype": "image/png",
|
"mimetype": "image/png",
|
||||||
"h": 200,
|
"h": 200,
|
||||||
"w": 140,
|
"w": 140,
|
||||||
"size": 73602
|
"size": 73602,
|
||||||
|
"is_animated": true
|
||||||
},
|
},
|
||||||
"h": 200,
|
"h": 200,
|
||||||
"thumbnail_url": "mxc://matrix.org/sHhqkFCvSkFwtmvtETOtKnLP",
|
"thumbnail_url": "mxc://matrix.org/sHhqkFCvSkFwtmvtETOtKnLP",
|
||||||
|
|
|
||||||
|
|
@ -34,5 +34,19 @@ properties:
|
||||||
allOf:
|
allOf:
|
||||||
- $ref: thumbnail_info.yaml
|
- $ref: thumbnail_info.yaml
|
||||||
description: Metadata about the image referred to in `thumbnail_url`.
|
description: Metadata about the image referred to in `thumbnail_url`.
|
||||||
|
is_animated:
|
||||||
|
x-addedInMatrixVersion: "1.18"
|
||||||
|
description: |-
|
||||||
|
If this flag is `true`, the original image SHOULD be assumed to be
|
||||||
|
animated. If this flag is `false`, the original image SHOULD be assumed to
|
||||||
|
NOT be animated.
|
||||||
|
|
||||||
|
If a sending client is unable to determine whether an image is animated,
|
||||||
|
it SHOULD leave the flag unset.
|
||||||
|
|
||||||
|
Receiving clients MAY use this flag to optimize whether to download the
|
||||||
|
original image rather than a thumbnail if it is animated, but they SHOULD
|
||||||
|
NOT trust this flag.
|
||||||
|
type: boolean
|
||||||
title: ImageInfo
|
title: ImageInfo
|
||||||
type: object
|
type: object
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,3 @@
|
||||||
{{ $inter := resources.Get "css/fonts/Inter.css" -}}
|
{{ $inter := resources.Get "css/fonts/Inter.css" -}}
|
||||||
<link rel="preload" href="{{ $inter.RelPermalink }}" as="style">
|
<link rel="preload" href="{{ $inter.RelPermalink }}" as="style">
|
||||||
<link rel="stylesheet" href="{{ $inter.RelPermalink }}">
|
<link rel="stylesheet" href="{{ $inter.RelPermalink }}">
|
||||||
|
|
||||||
{{/* Load Pagefind stuff to power the page search. */}}
|
|
||||||
<link href="/pagefind/pagefind-ui.css" rel="stylesheet">
|
|
||||||
<script src="/pagefind/pagefind-ui.js"></script>
|
|
||||||
|
|
|
||||||
|
|
@ -61,28 +61,6 @@
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
<li class="nav-item" id="search-button">
|
|
||||||
<a class="nav-link" href="#" role="button">Search</a>
|
|
||||||
</li>
|
|
||||||
<script>
|
|
||||||
document.querySelector("#search-button").addEventListener("click", (event) => {
|
|
||||||
const search = document.querySelector("#search");
|
|
||||||
|
|
||||||
if (search.style.display === "block") {
|
|
||||||
// Hide the search widget.
|
|
||||||
search.style.display = "none";
|
|
||||||
} else {
|
|
||||||
// Initialise the search widget if needed.
|
|
||||||
if (!search.innerHTML.length) {
|
|
||||||
new PagefindUI({ element: "#search", showSubResults: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unhide and focus the search widget.
|
|
||||||
search.style.display = "block";
|
|
||||||
search.querySelector("input").focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{{ if .Site.Params.versions -}}
|
{{ if .Site.Params.versions -}}
|
||||||
<li class="nav-item dropdown d-none d-lg-block td-navbar__version-menu">
|
<li class="nav-item dropdown d-none d-lg-block td-navbar__version-menu">
|
||||||
{{ partial "navbar-version-selector.html" . -}}
|
{{ partial "navbar-version-selector.html" . -}}
|
||||||
|
|
|
||||||
10
layouts/_partials/search-input.html
Normal file
10
layouts/_partials/search-input.html
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
<div class="td-search td-search--offline">
|
||||||
|
<div class="td-search__icon"></div>
|
||||||
|
<input
|
||||||
|
type="search"
|
||||||
|
class="td-search__input form-control"
|
||||||
|
placeholder="{{ T "ui_search" }}"
|
||||||
|
aria-label="{{ T "ui_search" }}"
|
||||||
|
autocomplete="off"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
@ -49,7 +49,6 @@
|
||||||
</aside>
|
</aside>
|
||||||
<main class="col-12 col-md-9 col-xl-8 ps-md-5" role="main">
|
<main class="col-12 col-md-9 col-xl-8 ps-md-5" role="main">
|
||||||
{{ partial "version-banner.html" . }}
|
{{ partial "version-banner.html" . }}
|
||||||
<div id="search"></div>
|
|
||||||
{{ if not (.Param "ui.breadcrumb_disable") -}}
|
{{ if not (.Param "ui.breadcrumb_disable") -}}
|
||||||
{{ partial "breadcrumb.html" . -}}
|
{{ partial "breadcrumb.html" . -}}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue