From ee37039031de3fecfff04d61e021961ac05e8124 Mon Sep 17 00:00:00 2001 From: Action Bot Date: Mon, 11 Dec 2023 14:51:26 +0000 Subject: [PATCH 1/3] Version picker added for v1.98 docs --- book.toml | 7 +- docs/website_files/README.md | 5 + docs/website_files/theme/index.hbs | 14 ++- docs/website_files/version-picker.css | 78 ++++++++++++++++ docs/website_files/version-picker.js | 127 ++++++++++++++++++++++++++ docs/website_files/version.js | 1 + 6 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 docs/website_files/version-picker.css create mode 100644 docs/website_files/version-picker.js create mode 100644 docs/website_files/version.js diff --git a/book.toml b/book.toml index ed3f6151e06a..977a8450bc3a 100644 --- a/book.toml +++ b/book.toml @@ -34,8 +34,13 @@ additional-css = [ "docs/website_files/table-of-contents.css", "docs/website_files/remove-nav-buttons.css", "docs/website_files/indent-section-headers.css", + "docs/website_files/version-picker.css", +] +additional-js = [ + "docs/website_files/table-of-contents.js", + "docs/website_files/version-picker.js", + "docs/website_files/version.js", ] -additional-js = ["docs/website_files/table-of-contents.js"] theme = "docs/website_files/theme" [preprocessor.schema_versions] diff --git a/docs/website_files/README.md b/docs/website_files/README.md index 04d191479bfe..bc51c4865eab 100644 --- a/docs/website_files/README.md +++ b/docs/website_files/README.md @@ -24,6 +24,11 @@ Finally, we also stylise the chapter titles in the left sidebar by indenting the slightly so that they are more visually distinguishable from the section headers (the bold titles). This is done through the `indent-section-headers.css` file. +In addition to these modifications, we have added a version picker to the documentation. +Users can switch between documentations for different versions of Synapse. +This functionality was implemented through the `version-picker.js` and +`version-picker.css` files. + More information can be found in mdbook's official documentation for [injecting page JS/CSS](https://rust-lang.github.io/mdBook/format/config.html) and diff --git a/docs/website_files/theme/index.hbs b/docs/website_files/theme/index.hbs index 3b7a5b616353..b169323a43fc 100644 --- a/docs/website_files/theme/index.hbs +++ b/docs/website_files/theme/index.hbs @@ -131,6 +131,18 @@ {{/if}} +
+ +

{{ book_title }}

@@ -309,4 +321,4 @@ {{/if}} - \ No newline at end of file + diff --git a/docs/website_files/version-picker.css b/docs/website_files/version-picker.css new file mode 100644 index 000000000000..28e5d5219aa1 --- /dev/null +++ b/docs/website_files/version-picker.css @@ -0,0 +1,78 @@ +.version-picker { + display: flex; + align-items: center; +} + +.version-picker .dropdown { + width: 130px; + max-height: 29px; + margin-left: 10px; + display: inline-block; + border-radius: 4px; + border: 1px solid var(--theme-popup-border); + position: relative; + font-size: 13px; + color: var(--fg); + height: 100%; + text-align: left; +} +.version-picker .dropdown .select { + cursor: pointer; + display: block; + padding: 5px 2px 5px 15px; +} +.version-picker .dropdown .select > i { + font-size: 10px; + color: var(--fg); + cursor: pointer; + float: right; + line-height: 20px !important; +} +.version-picker .dropdown:hover { + border: 1px solid var(--theme-popup-border); +} +.version-picker .dropdown:active { + background-color: var(--theme-popup-bg); +} +.version-picker .dropdown.active:hover, +.version-picker .dropdown.active { + border: 1px solid var(--theme-popup-border); + border-radius: 2px 2px 0 0; + background-color: var(--theme-popup-bg); +} +.version-picker .dropdown.active .select > i { + transform: rotate(-180deg); +} +.version-picker .dropdown .dropdown-menu { + position: absolute; + background-color: var(--theme-popup-bg); + width: 100%; + left: -1px; + right: 1px; + margin-top: 1px; + border: 1px solid var(--theme-popup-border); + border-radius: 0 0 4px 4px; + overflow: hidden; + display: none; + max-height: 300px; + overflow-y: auto; + z-index: 9; +} +.version-picker .dropdown .dropdown-menu li { + font-size: 12px; + padding: 6px 20px; + cursor: pointer; +} +.version-picker .dropdown .dropdown-menu { + padding: 0; + list-style: none; +} +.version-picker .dropdown .dropdown-menu li:hover { + background-color: var(--theme-hover); +} +.version-picker .dropdown .dropdown-menu li.active::before { + display: inline-block; + content: "✓"; + margin-inline-start: -14px; + width: 14px; +} \ No newline at end of file diff --git a/docs/website_files/version-picker.js b/docs/website_files/version-picker.js new file mode 100644 index 000000000000..bb35a7d8961e --- /dev/null +++ b/docs/website_files/version-picker.js @@ -0,0 +1,127 @@ + +const dropdown = document.querySelector('.version-picker .dropdown'); +const dropdownMenu = dropdown.querySelector('.dropdown-menu'); + +fetchVersions(dropdown, dropdownMenu).then(() => { + initializeVersionDropdown(dropdown, dropdownMenu); +}); + +/** + * Initialize the dropdown functionality for version selection. + * + * @param {Element} dropdown - The dropdown element. + * @param {Element} dropdownMenu - The dropdown menu element. + */ +function initializeVersionDropdown(dropdown, dropdownMenu) { + // Toggle the dropdown menu on click + dropdown.addEventListener('click', function () { + this.setAttribute('tabindex', 1); + this.classList.toggle('active'); + dropdownMenu.style.display = (dropdownMenu.style.display === 'block') ? 'none' : 'block'; + }); + + // Remove the 'active' class and hide the dropdown menu on focusout + dropdown.addEventListener('focusout', function () { + this.classList.remove('active'); + dropdownMenu.style.display = 'none'; + }); + + // Handle item selection within the dropdown menu + const dropdownMenuItems = dropdownMenu.querySelectorAll('li'); + dropdownMenuItems.forEach(function (item) { + item.addEventListener('click', function () { + dropdownMenuItems.forEach(function (item) { + item.classList.remove('active'); + }); + this.classList.add('active'); + dropdown.querySelector('span').textContent = this.textContent; + dropdown.querySelector('input').value = this.getAttribute('id'); + + window.location.href = changeVersion(window.location.href, this.textContent); + }); + }); +}; + +/** + * This function fetches the available versions from a GitHub repository + * and inserts them into the version picker. + * + * @param {Element} dropdown - The dropdown element. + * @param {Element} dropdownMenu - The dropdown menu element. + * @returns {Promise>} A promise that resolves with an array of available versions. + */ +function fetchVersions(dropdown, dropdownMenu) { + return new Promise((resolve, reject) => { + window.addEventListener("load", () => { + + fetch("https://api.github.com/repos/matrix-org/synapse/git/trees/gh-pages", { + cache: "force-cache", + }).then(res => + res.json() + ).then(resObject => { + const excluded = ['dev-docs', 'v1.91.0', 'v1.80.0', 'v1.69.0']; + const tree = resObject.tree.filter(item => item.type === "tree" && !excluded.includes(item.path)); + const versions = tree.map(item => item.path).sort(sortVersions); + + // Create a list of
  • items for versions + versions.forEach((version) => { + const li = document.createElement("li"); + li.textContent = version; + li.id = version; + + if (window.SYNAPSE_VERSION === version) { + li.classList.add('active'); + dropdown.querySelector('span').textContent = version; + dropdown.querySelector('input').value = version; + } + + dropdownMenu.appendChild(li); + }); + + resolve(versions); + + }).catch(ex => { + console.error("Failed to fetch version data", ex); + reject(ex); + }) + }); + }); +} + +/** + * Custom sorting function to sort an array of version strings. + * + * @param {string} a - The first version string to compare. + * @param {string} b - The second version string to compare. + * @returns {number} - A negative number if a should come before b, a positive number if b should come before a, or 0 if they are equal. + */ +function sortVersions(a, b) { + // Put 'develop' and 'latest' at the top + if (a === 'develop' || a === 'latest') return -1; + if (b === 'develop' || b === 'latest') return 1; + + const versionA = (a.match(/v\d+(\.\d+)+/) || [])[0]; + const versionB = (b.match(/v\d+(\.\d+)+/) || [])[0]; + + return versionB.localeCompare(versionA); +} + +/** + * Change the version in a URL path. + * + * @param {string} url - The original URL to be modified. + * @param {string} newVersion - The new version to replace the existing version in the URL. + * @returns {string} The updated URL with the new version. + */ +function changeVersion(url, newVersion) { + const parsedURL = new URL(url); + const pathSegments = parsedURL.pathname.split('/'); + + // Modify the version + pathSegments[2] = newVersion; + + // Reconstruct the URL + parsedURL.pathname = pathSegments.join('/'); + + return parsedURL.href; +} \ No newline at end of file diff --git a/docs/website_files/version.js b/docs/website_files/version.js new file mode 100644 index 000000000000..804891637245 --- /dev/null +++ b/docs/website_files/version.js @@ -0,0 +1 @@ +window.SYNAPSE_VERSION = 'v1.98'; From 128aad4fe3f4c5c11286512b64e2480febf4567c Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 12 Dec 2023 15:10:16 +0000 Subject: [PATCH 2/3] 1.98.0 --- CHANGES.md | 9 ++++++++- debian/changelog | 6 ++++++ pyproject.toml | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a52173609da2..8b33a1c9ec5f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,4 @@ -# Synapse 1.98.0rc1 (2023-12-05) +# Synapse 1.98.0 (2023-12-12) Synapse 1.98.0 will be the last Synapse release in 2023; the regular release cadence will resume in January 2024. @@ -12,6 +12,13 @@ The Matrix.org Foundation copy of the project will be archived. Any changes need by server administrators will be communicated via our usual announcements channels, but we are striving to make this as seamless as possible. + +No significant changes since 1.98.0rc1. + + + +# Synapse 1.98.0rc1 (2023-12-05) + ### Features - Synapse now declares support for Matrix v1.7, v1.8, and v1.9. ([\#16707](https://github.com/matrix-org/synapse/issues/16707)) diff --git a/debian/changelog b/debian/changelog index b4626f741e04..abcfedf6d656 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +matrix-synapse-py3 (1.98.0) stable; urgency=medium + + * New Synapse release 1.98.0. + + -- Synapse Packaging team Tue, 12 Dec 2023 15:04:31 +0000 + matrix-synapse-py3 (1.98.0~rc1) stable; urgency=medium * New Synapse release 1.98.0rc1. diff --git a/pyproject.toml b/pyproject.toml index a3eb6111e023..7257adc5bee5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,7 +96,7 @@ module-name = "synapse.synapse_rust" [tool.poetry] name = "matrix-synapse" -version = "1.98.0rc1" +version = "1.98.0" description = "Homeserver for the Matrix decentralised comms protocol" authors = ["Matrix.org Team and Contributors "] license = "Apache-2.0" From 15733b0931ceaa72cf4175c44fe58128fa273bac Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 12 Dec 2023 15:51:28 +0000 Subject: [PATCH 3/3] Update changelog --- CHANGES.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8b33a1c9ec5f..cac80ca97215 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,7 +9,7 @@ proprietary dual licensing). You can read more about this here: - https://element.io/blog/element-to-adopt-agplv3/ The Matrix.org Foundation copy of the project will be archived. Any changes needed -by server administrators will be communicated via our usual announcements channels, +by server administrators will be communicated via our usual announcements channels, but we are striving to make this as seamless as possible. @@ -22,7 +22,7 @@ No significant changes since 1.98.0rc1. ### Features - Synapse now declares support for Matrix v1.7, v1.8, and v1.9. ([\#16707](https://github.com/matrix-org/synapse/issues/16707)) -- Add `on_user_login` [module API](https://matrix-org.github.io/synapse/latest/modules/writing_a_module.html) callback allowing to execute custom code after (on) Auth. ([\#15207](https://github.com/matrix-org/synapse/issues/15207)) +- Add `on_user_login` [module API](https://matrix-org.github.io/synapse/latest/modules/writing_a_module.html) callback for when a user logs in. ([\#15207](https://github.com/matrix-org/synapse/issues/15207)) - Support [MSC4069: Inhibit profile propagation](https://github.com/matrix-org/matrix-spec-proposals/pull/4069). ([\#16636](https://github.com/matrix-org/synapse/issues/16636)) - Restore tracking of requests and monthly active users when delegating authentication via [MSC3861](https://github.com/matrix-org/synapse/pull/16672) to an OIDC provider. ([\#16672](https://github.com/matrix-org/synapse/issues/16672)) - Add an autojoin setting for server notices rooms, so users may be joined directly instead of receiving an invite. ([\#16699](https://github.com/matrix-org/synapse/issues/16699)) @@ -87,7 +87,7 @@ proprietary dual licensing). You can read more about this here: - https://element.io/blog/element-to-adopt-agplv3/ The Matrix.org Foundation copy of the project will be archived. Any changes needed -by server administrators will be communicated via our usual announcements channels, +by server administrators will be communicated via our usual announcements channels, but we are striving to make this as seamless as possible.