From 9da04adfd7343c0d36bd95a34a2b4aeb771ecc74 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Thu, 9 Apr 2026 23:37:33 +0530 Subject: [PATCH 1/5] feat: add copy button on install link to improve Accessibility --- src/styles/app.scss | 68 ++++ static/scripts/tools-install.js | 391 +++++++++++++-------- templates/components/tools/rustup.html.hbs | 42 ++- 3 files changed, 354 insertions(+), 147 deletions(-) diff --git a/src/styles/app.scss b/src/styles/app.scss index 5265df2c8..f79da66fe 100644 --- a/src/styles/app.scss +++ b/src/styles/app.scss @@ -119,6 +119,74 @@ code.copyable { user-select: all; } +.pre-copy-wrap { + display: flex; + align-items: stretch; + + pre { + flex: 1; + min-width: 0; + margin: 0; + } + + // Square off the right edge of the code block so it meets the button flush + pre > code { + margin: 0; + border-right: none; + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } + + .copy-code-btn { + display: inline-flex; + align-items: center; + gap: 6px; + flex-shrink: 0; + padding: 0 14px; + // Match the a11y-dark highlight.js theme used on the code block + background: #2b2b2b; + border: 1px solid #e1e1e1; + border-left: 1px solid rgba(248, 248, 242, 0.15); + border-radius: 0 $border-radius $border-radius 0; + color: #d4d0ab; + font-family: $body-font; + font-size: 0.75em; + font-weight: 600; + letter-spacing: 0.08em; + text-transform: uppercase; + cursor: pointer; + white-space: nowrap; + transition: background 0.15s ease, color 0.15s ease; + + // Checkmark icon only shown in .copied state + .check-icon { + display: none; + } + + &:hover { + background: #3c3c3c; + color: #f8f8f2; + } + + &:focus-visible { + outline: 2px solid white; + outline-offset: 2px; + } + + &.copied { + color: #7ee787; + + .copy-icon { + display: none; + } + + .check-icon { + display: inline-block; + } + } + } +} + header h1, section h2 { z-index: 999999; diff --git a/static/scripts/tools-install.js b/static/scripts/tools-install.js index 8f3c78ff5..9b87ca75e 100644 --- a/static/scripts/tools-install.js +++ b/static/scripts/tools-install.js @@ -1,184 +1,287 @@ var platform_override = null; function vis(elem, apply) { - ["db", "di", "dn"].forEach(c => { - if (c === apply) { - elem.classList.add(c); - } else { - elem.classList.remove(c); - } - }); + ["db", "di", "dn"].forEach((c) => { + if (c === apply) { + elem.classList.add(c); + } else { + elem.classList.remove(c); + } + }); } function detect_platform() { - "use strict"; + "use strict"; - if (platform_override) { - return platform_override; - } + if (platform_override) { + return platform_override; + } - var os = "unknown"; - - if (navigator.platform == "Linux x86_64") {os = "unix";} - if (navigator.platform == "Linux i686") {os = "unix";} - if (navigator.platform == "Linux i686 on x86_64") {os = "unix";} - if (navigator.platform == "Linux aarch64") {os = "unix";} - if (navigator.platform == "Linux armv6l") {os = "unix";} - if (navigator.platform == "Linux armv7l") {os = "unix";} - if (navigator.platform == "Linux armv8l") {os = "unix";} - if (navigator.platform == "Linux ppc64") {os = "unix";} - if (navigator.platform == "Linux mips") {os = "unix";} - if (navigator.platform == "Linux mips64") {os = "unix";} - if (navigator.platform == "Linux riscv64") {os = "unix";} - if (navigator.platform == "Mac") {os = "unix";} - if (navigator.platform == "Win32") {os = "win";} - if (navigator.platform == "FreeBSD x86_64") {os = "unix";} - if (navigator.platform == "FreeBSD amd64") {os = "unix";} - if (navigator.platform == "NetBSD x86_64") {os = "unix";} - if (navigator.platform == "NetBSD amd64") {os = "unix";} - - // I wish I knew by now, but I don't. Try harder. - if (os == "unknown") { - if (navigator.appVersion.indexOf("Win")!=-1) {os = "win";} - if (navigator.appVersion.indexOf("Mac")!=-1) {os = "unix";} - // rust-www/#692 - FreeBSD epiphany! - if (navigator.appVersion.indexOf("FreeBSD")!=-1) {os = "unix";} + var os = "unknown"; + + if (navigator.platform == "Linux x86_64") { + os = "unix"; + } + if (navigator.platform == "Linux i686") { + os = "unix"; + } + if (navigator.platform == "Linux i686 on x86_64") { + os = "unix"; + } + if (navigator.platform == "Linux aarch64") { + os = "unix"; + } + if (navigator.platform == "Linux armv6l") { + os = "unix"; + } + if (navigator.platform == "Linux armv7l") { + os = "unix"; + } + if (navigator.platform == "Linux armv8l") { + os = "unix"; + } + if (navigator.platform == "Linux ppc64") { + os = "unix"; + } + if (navigator.platform == "Linux mips") { + os = "unix"; + } + if (navigator.platform == "Linux mips64") { + os = "unix"; + } + if (navigator.platform == "Linux riscv64") { + os = "unix"; + } + if (navigator.platform == "Mac") { + os = "unix"; + } + if (navigator.platform == "Win32") { + os = "win"; + } + if (navigator.platform == "FreeBSD x86_64") { + os = "unix"; + } + if (navigator.platform == "FreeBSD amd64") { + os = "unix"; + } + if (navigator.platform == "NetBSD x86_64") { + os = "unix"; + } + if (navigator.platform == "NetBSD amd64") { + os = "unix"; + } + + // I wish I knew by now, but I don't. Try harder. + if (os == "unknown") { + if (navigator.appVersion.indexOf("Win") != -1) { + os = "win"; + } + if (navigator.appVersion.indexOf("Mac") != -1) { + os = "unix"; + } + // rust-www/#692 - FreeBSD epiphany! + if (navigator.appVersion.indexOf("FreeBSD") != -1) { + os = "unix"; } + } - // Firefox Quantum likes to hide platform and appVersion but oscpu works - if (navigator.oscpu) { - if (navigator.oscpu.indexOf("Windows")!=-1) {os = "win";} - if (navigator.oscpu.indexOf("Mac")!=-1) {os = "unix";} - if (navigator.oscpu.indexOf("Linux")!=-1) {os = "unix";} - if (navigator.oscpu.indexOf("FreeBSD")!=-1) {os = "unix";} - if (navigator.oscpu.indexOf("NetBSD")!=-1) {os = "unix";} + // Firefox Quantum likes to hide platform and appVersion but oscpu works + if (navigator.oscpu) { + if (navigator.oscpu.indexOf("Windows") != -1) { + os = "win"; } + if (navigator.oscpu.indexOf("Mac") != -1) { + os = "unix"; + } + if (navigator.oscpu.indexOf("Linux") != -1) { + os = "unix"; + } + if (navigator.oscpu.indexOf("FreeBSD") != -1) { + os = "unix"; + } + if (navigator.oscpu.indexOf("NetBSD") != -1) { + os = "unix"; + } + } - return os; + return os; } function adjust_for_platform() { - "use strict"; + "use strict"; - var platform = detect_platform(); + var platform = detect_platform(); - var unix_div = document.getElementById("platform-instructions-unix"); - var win_div = document.getElementById("platform-instructions-win"); - var default_div = document.getElementById("platform-instructions-default"); + var unix_div = document.getElementById("platform-instructions-unix"); + var win_div = document.getElementById("platform-instructions-win"); + var default_div = document.getElementById("platform-instructions-default"); - vis(unix_div, "dn"); - vis(win_div, "dn"); - vis(default_div, "dn"); + vis(unix_div, "dn"); + vis(win_div, "dn"); + vis(default_div, "dn"); - if (platform == "unix") { - vis(unix_div, "db"); - } else if (platform == "win") { - vis(win_div, "db"); - } else { - vis(default_div, "db"); - } + if (platform == "unix") { + vis(unix_div, "db"); + } else if (platform == "win") { + vis(win_div, "db"); + } else { + vis(default_div, "db"); + } - var platform_specific = document.getElementsByClassName("platform-specific"); - for (var el of platform_specific) { - var el_is_not_win = el.className.indexOf("not-win") !== -1; - var el_is_inline = el.tagName.toLowerCase() == "span"; - var el_visible_class = "db"; - if (el_is_inline) { - el_visible_class = "di"; - } - if (platform == "win") { - if (el_is_not_win) { - vis(el, "dn"); - } else { - vis(el, el_visible_class); - } - } else { - if (el_is_not_win) { - vis(el, el_visible_class); - } else { - vis(el, "dn"); - } - } + var platform_specific = document.getElementsByClassName("platform-specific"); + for (var el of platform_specific) { + var el_is_not_win = el.className.indexOf("not-win") !== -1; + var el_is_inline = el.tagName.toLowerCase() == "span"; + var el_visible_class = "db"; + if (el_is_inline) { + el_visible_class = "di"; + } + if (platform == "win") { + if (el_is_not_win) { + vis(el, "dn"); + } else { + vis(el, el_visible_class); + } + } else { + if (el_is_not_win) { + vis(el, el_visible_class); + } else { + vis(el, "dn"); + } } + } } function cycle_platform() { - if (platform_override == null) { - platform_override = "default"; - } else if (platform_override == "default") { - platform_override = "unknown"; - } else if (platform_override == "unknown") { - platform_override = "win"; - } else if (platform_override == "win") { - platform_override = "unix"; - } else if (platform_override == "unix") { - platform_override = "default"; - } - adjust_for_platform(); + if (platform_override == null) { + platform_override = "default"; + } else if (platform_override == "default") { + platform_override = "unknown"; + } else if (platform_override == "unknown") { + platform_override = "win"; + } else if (platform_override == "win") { + platform_override = "unix"; + } else if (platform_override == "unix") { + platform_override = "default"; + } + adjust_for_platform(); } function set_up_cycle_button() { - var cycle_button = document.getElementById("platform-button"); - if (cycle_button !== null) { - cycle_button.onclick = cycle_platform; - } + var cycle_button = document.getElementById("platform-button"); + if (cycle_button !== null) { + cycle_button.onclick = cycle_platform; + } - var key="test"; - var idx=0; - var unlocked=false; + var key = "test"; + var idx = 0; + var unlocked = false; - document.onkeypress = function(event) { - if (event.key == "n" && unlocked) { - cycle_platform(); - } + document.onkeypress = function (event) { + if (event.key == "n" && unlocked) { + cycle_platform(); + } - if (event.key == key[idx]) { - idx += 1; - - if (idx == key.length) { - if (cycle_button !== null) { - vis(cycle_button, "db"); - } - unlocked = true; - cycle_platform(); - } - } else if (event.key == key[0]) { - idx = 1; - } else { - idx = 0; + if (event.key == key[idx]) { + idx += 1; + + if (idx == key.length) { + if (cycle_button !== null) { + vis(cycle_button, "db"); } - }; + unlocked = true; + cycle_platform(); + } + } else if (event.key == key[0]) { + idx = 1; + } else { + idx = 0; + } + }; } -var override_map = new Map ([ - ["unix", "unix"], - ["win", "win"], - ["linux", "unix"], - ["win32", "win"], - ["win64", "win"], - ["windows", "win"], - ["wsl", "win"], - ["default", "default"], - ["generic", "default"], - ["all", "default"], +var override_map = new Map([ + ["unix", "unix"], + ["win", "win"], + ["linux", "unix"], + ["win32", "win"], + ["win64", "win"], + ["windows", "win"], + ["wsl", "win"], + ["default", "default"], + ["generic", "default"], + ["all", "default"], ]); function check_initial_override() { - var urlParams = new URLSearchParams(location.search); - if (urlParams.has('platform_override')) { - var override = urlParams.get('platform_override').toLowerCase(); - // Now normalise in case people pass unusual things in - override = override_map.get(override); - if (override === undefined) { - platform_override = "unknown"; - } else { - platform_override = override; - } + var urlParams = new URLSearchParams(location.search); + if (urlParams.has("platform_override")) { + var override = urlParams.get("platform_override").toLowerCase(); + // Now normalise in case people pass unusual things in + override = override_map.get(override); + if (override === undefined) { + platform_override = "unknown"; + } else { + platform_override = override; } + } +} + +function set_up_copy_buttons() { + var buttons = document.querySelectorAll(".copy-code-btn"); + buttons.forEach(function (btn) { + btn.addEventListener("click", function () { + var wrap = btn.closest(".pre-copy-wrap"); + var code = wrap && wrap.querySelector("code"); + if (!code) { + return; + } + var text = code.textContent; + + var original_label = btn.getAttribute("aria-label"); + + function mark_copied() { + var text_el = btn.querySelector(".copy-code-btn__text"); + if (text_el) text_el.textContent = "Copied!"; + btn.setAttribute("aria-label", "Copied!"); + btn.classList.add("copied"); + setTimeout(function () { + if (text_el) text_el.textContent = "Copy"; + btn.setAttribute("aria-label", original_label); + btn.classList.remove("copied"); + }, 2000); + } + + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard + .writeText(text) + .then(mark_copied) + .catch(function () { + fallback_copy(code, mark_copied); + }); + } else { + fallback_copy(code, mark_copied); + } + }); + }); +} + +function fallback_copy(code_el, on_success) { + var selection = window.getSelection(); + var range = document.createRange(); + range.selectNodeContents(code_el); + selection.removeAllRanges(); + selection.addRange(range); + try { + document.execCommand("copy"); + on_success(); + } catch (e) {} + selection.removeAllRanges(); } (function () { - check_initial_override(); - adjust_for_platform(); - set_up_cycle_button(); -}()); + check_initial_override(); + adjust_for_platform(); + set_up_cycle_button(); + set_up_copy_buttons(); +})(); diff --git a/templates/components/tools/rustup.html.hbs b/templates/components/tools/rustup.html.hbs index fc7e909b1..d649ee7ae 100644 --- a/templates/components/tools/rustup.html.hbs +++ b/templates/components/tools/rustup.html.hbs @@ -1,7 +1,19 @@

{{fluent "tools-rustup-unixy"}}

-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+ +

{{fluent "tools-rustup-windows-2"}}

@@ -20,14 +32,38 @@

{{fluent "tools-rustup-wsl-heading"}}

{{fluent "tools-rustup-wsl"}}

-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+ +

{{fluent "tools-rustup-manual-default"}}

-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+
+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
+ +

From 8ce508653b29b379d2ddc0a0279c45138b06b2d6 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Fri, 10 Apr 2026 00:26:21 +0530 Subject: [PATCH 2/5] chore: revert the whitespace changes --- static/scripts/tools-install.js | 426 ++++++++++++++------------------ 1 file changed, 186 insertions(+), 240 deletions(-) diff --git a/static/scripts/tools-install.js b/static/scripts/tools-install.js index 9b87ca75e..1bce05f85 100644 --- a/static/scripts/tools-install.js +++ b/static/scripts/tools-install.js @@ -1,287 +1,233 @@ var platform_override = null; function vis(elem, apply) { - ["db", "di", "dn"].forEach((c) => { - if (c === apply) { - elem.classList.add(c); - } else { - elem.classList.remove(c); - } - }); + ["db", "di", "dn"].forEach(c => { + if (c === apply) { + elem.classList.add(c); + } else { + elem.classList.remove(c); + } + }); } function detect_platform() { - "use strict"; + "use strict"; - if (platform_override) { - return platform_override; - } - - var os = "unknown"; - - if (navigator.platform == "Linux x86_64") { - os = "unix"; - } - if (navigator.platform == "Linux i686") { - os = "unix"; - } - if (navigator.platform == "Linux i686 on x86_64") { - os = "unix"; - } - if (navigator.platform == "Linux aarch64") { - os = "unix"; - } - if (navigator.platform == "Linux armv6l") { - os = "unix"; - } - if (navigator.platform == "Linux armv7l") { - os = "unix"; - } - if (navigator.platform == "Linux armv8l") { - os = "unix"; - } - if (navigator.platform == "Linux ppc64") { - os = "unix"; - } - if (navigator.platform == "Linux mips") { - os = "unix"; - } - if (navigator.platform == "Linux mips64") { - os = "unix"; - } - if (navigator.platform == "Linux riscv64") { - os = "unix"; - } - if (navigator.platform == "Mac") { - os = "unix"; - } - if (navigator.platform == "Win32") { - os = "win"; - } - if (navigator.platform == "FreeBSD x86_64") { - os = "unix"; - } - if (navigator.platform == "FreeBSD amd64") { - os = "unix"; - } - if (navigator.platform == "NetBSD x86_64") { - os = "unix"; - } - if (navigator.platform == "NetBSD amd64") { - os = "unix"; - } - - // I wish I knew by now, but I don't. Try harder. - if (os == "unknown") { - if (navigator.appVersion.indexOf("Win") != -1) { - os = "win"; - } - if (navigator.appVersion.indexOf("Mac") != -1) { - os = "unix"; + if (platform_override) { + return platform_override; } - // rust-www/#692 - FreeBSD epiphany! - if (navigator.appVersion.indexOf("FreeBSD") != -1) { - os = "unix"; - } - } - // Firefox Quantum likes to hide platform and appVersion but oscpu works - if (navigator.oscpu) { - if (navigator.oscpu.indexOf("Windows") != -1) { - os = "win"; - } - if (navigator.oscpu.indexOf("Mac") != -1) { - os = "unix"; - } - if (navigator.oscpu.indexOf("Linux") != -1) { - os = "unix"; - } - if (navigator.oscpu.indexOf("FreeBSD") != -1) { - os = "unix"; + var os = "unknown"; + + if (navigator.platform == "Linux x86_64") {os = "unix";} + if (navigator.platform == "Linux i686") {os = "unix";} + if (navigator.platform == "Linux i686 on x86_64") {os = "unix";} + if (navigator.platform == "Linux aarch64") {os = "unix";} + if (navigator.platform == "Linux armv6l") {os = "unix";} + if (navigator.platform == "Linux armv7l") {os = "unix";} + if (navigator.platform == "Linux armv8l") {os = "unix";} + if (navigator.platform == "Linux ppc64") {os = "unix";} + if (navigator.platform == "Linux mips") {os = "unix";} + if (navigator.platform == "Linux mips64") {os = "unix";} + if (navigator.platform == "Linux riscv64") {os = "unix";} + if (navigator.platform == "Mac") {os = "unix";} + if (navigator.platform == "Win32") {os = "win";} + if (navigator.platform == "FreeBSD x86_64") {os = "unix";} + if (navigator.platform == "FreeBSD amd64") {os = "unix";} + if (navigator.platform == "NetBSD x86_64") {os = "unix";} + if (navigator.platform == "NetBSD amd64") {os = "unix";} + + // I wish I knew by now, but I don't. Try harder. + if (os == "unknown") { + if (navigator.appVersion.indexOf("Win")!=-1) {os = "win";} + if (navigator.appVersion.indexOf("Mac")!=-1) {os = "unix";} + // rust-www/#692 - FreeBSD epiphany! + if (navigator.appVersion.indexOf("FreeBSD")!=-1) {os = "unix";} } - if (navigator.oscpu.indexOf("NetBSD") != -1) { - os = "unix"; + + // Firefox Quantum likes to hide platform and appVersion but oscpu works + if (navigator.oscpu) { + if (navigator.oscpu.indexOf("Windows")!=-1) {os = "win";} + if (navigator.oscpu.indexOf("Mac")!=-1) {os = "unix";} + if (navigator.oscpu.indexOf("Linux")!=-1) {os = "unix";} + if (navigator.oscpu.indexOf("FreeBSD")!=-1) {os = "unix";} + if (navigator.oscpu.indexOf("NetBSD")!=-1) {os = "unix";} } - } - return os; + return os; } function adjust_for_platform() { - "use strict"; - - var platform = detect_platform(); + "use strict"; - var unix_div = document.getElementById("platform-instructions-unix"); - var win_div = document.getElementById("platform-instructions-win"); - var default_div = document.getElementById("platform-instructions-default"); + var platform = detect_platform(); - vis(unix_div, "dn"); - vis(win_div, "dn"); - vis(default_div, "dn"); + var unix_div = document.getElementById("platform-instructions-unix"); + var win_div = document.getElementById("platform-instructions-win"); + var default_div = document.getElementById("platform-instructions-default"); - if (platform == "unix") { - vis(unix_div, "db"); - } else if (platform == "win") { - vis(win_div, "db"); - } else { - vis(default_div, "db"); - } + vis(unix_div, "dn"); + vis(win_div, "dn"); + vis(default_div, "dn"); - var platform_specific = document.getElementsByClassName("platform-specific"); - for (var el of platform_specific) { - var el_is_not_win = el.className.indexOf("not-win") !== -1; - var el_is_inline = el.tagName.toLowerCase() == "span"; - var el_visible_class = "db"; - if (el_is_inline) { - el_visible_class = "di"; - } - if (platform == "win") { - if (el_is_not_win) { - vis(el, "dn"); - } else { - vis(el, el_visible_class); - } + if (platform == "unix") { + vis(unix_div, "db"); + } else if (platform == "win") { + vis(win_div, "db"); } else { - if (el_is_not_win) { - vis(el, el_visible_class); - } else { - vis(el, "dn"); - } + vis(default_div, "db"); + } + + var platform_specific = document.getElementsByClassName("platform-specific"); + for (var el of platform_specific) { + var el_is_not_win = el.className.indexOf("not-win") !== -1; + var el_is_inline = el.tagName.toLowerCase() == "span"; + var el_visible_class = "db"; + if (el_is_inline) { + el_visible_class = "di"; + } + if (platform == "win") { + if (el_is_not_win) { + vis(el, "dn"); + } else { + vis(el, el_visible_class); + } + } else { + if (el_is_not_win) { + vis(el, el_visible_class); + } else { + vis(el, "dn"); + } + } } - } } function cycle_platform() { - if (platform_override == null) { - platform_override = "default"; - } else if (platform_override == "default") { - platform_override = "unknown"; - } else if (platform_override == "unknown") { - platform_override = "win"; - } else if (platform_override == "win") { - platform_override = "unix"; - } else if (platform_override == "unix") { - platform_override = "default"; - } - adjust_for_platform(); + if (platform_override == null) { + platform_override = "default"; + } else if (platform_override == "default") { + platform_override = "unknown"; + } else if (platform_override == "unknown") { + platform_override = "win"; + } else if (platform_override == "win") { + platform_override = "unix"; + } else if (platform_override == "unix") { + platform_override = "default"; + } + adjust_for_platform(); } function set_up_cycle_button() { - var cycle_button = document.getElementById("platform-button"); - if (cycle_button !== null) { - cycle_button.onclick = cycle_platform; - } - - var key = "test"; - var idx = 0; - var unlocked = false; - - document.onkeypress = function (event) { - if (event.key == "n" && unlocked) { - cycle_platform(); + var cycle_button = document.getElementById("platform-button"); + if (cycle_button !== null) { + cycle_button.onclick = cycle_platform; } - if (event.key == key[idx]) { - idx += 1; + var key="test"; + var idx=0; + var unlocked=false; - if (idx == key.length) { - if (cycle_button !== null) { - vis(cycle_button, "db"); + document.onkeypress = function(event) { + if (event.key == "n" && unlocked) { + cycle_platform(); } - unlocked = true; - cycle_platform(); - } - } else if (event.key == key[0]) { - idx = 1; - } else { - idx = 0; - } - }; + + if (event.key == key[idx]) { + idx += 1; + + if (idx == key.length) { + if (cycle_button !== null) { + vis(cycle_button, "db"); + } + unlocked = true; + cycle_platform(); + } + } else if (event.key == key[0]) { + idx = 1; + } else { + idx = 0; + } + }; } -var override_map = new Map([ - ["unix", "unix"], - ["win", "win"], - ["linux", "unix"], - ["win32", "win"], - ["win64", "win"], - ["windows", "win"], - ["wsl", "win"], - ["default", "default"], - ["generic", "default"], - ["all", "default"], +var override_map = new Map ([ + ["unix", "unix"], + ["win", "win"], + ["linux", "unix"], + ["win32", "win"], + ["win64", "win"], + ["windows", "win"], + ["wsl", "win"], + ["default", "default"], + ["generic", "default"], + ["all", "default"], ]); function check_initial_override() { - var urlParams = new URLSearchParams(location.search); - if (urlParams.has("platform_override")) { - var override = urlParams.get("platform_override").toLowerCase(); - // Now normalise in case people pass unusual things in - override = override_map.get(override); - if (override === undefined) { - platform_override = "unknown"; - } else { - platform_override = override; + var urlParams = new URLSearchParams(location.search); + if (urlParams.has('platform_override')) { + var override = urlParams.get('platform_override').toLowerCase(); + // Now normalise in case people pass unusual things in + override = override_map.get(override); + if (override === undefined) { + platform_override = "unknown"; + } else { + platform_override = override; + } } - } } -function set_up_copy_buttons() { - var buttons = document.querySelectorAll(".copy-code-btn"); - buttons.forEach(function (btn) { - btn.addEventListener("click", function () { - var wrap = btn.closest(".pre-copy-wrap"); - var code = wrap && wrap.querySelector("code"); - if (!code) { - return; - } - var text = code.textContent; - - var original_label = btn.getAttribute("aria-label"); - function mark_copied() { - var text_el = btn.querySelector(".copy-code-btn__text"); - if (text_el) text_el.textContent = "Copied!"; - btn.setAttribute("aria-label", "Copied!"); - btn.classList.add("copied"); - setTimeout(function () { - if (text_el) text_el.textContent = "Copy"; - btn.setAttribute("aria-label", original_label); - btn.classList.remove("copied"); - }, 2000); - } - - if (navigator.clipboard && navigator.clipboard.writeText) { - navigator.clipboard - .writeText(text) - .then(mark_copied) - .catch(function () { - fallback_copy(code, mark_copied); - }); - } else { - fallback_copy(code, mark_copied); - } +function set_up_copy_buttons() { + var buttons = document.querySelectorAll('.copy-code-btn'); + buttons.forEach(function(btn) { + btn.addEventListener('click', function() { + var wrap = btn.closest('.pre-copy-wrap'); + var code = wrap && wrap.querySelector('code'); + if (!code) { return; } + var text = code.textContent; + + var original_label = btn.getAttribute('aria-label'); + + function mark_copied() { + var text_el = btn.querySelector('.copy-code-btn__text'); + if (text_el) { text_el.textContent = 'Copied!'; } + btn.setAttribute('aria-label', 'Copied!'); + btn.classList.add('copied'); + setTimeout(function() { + if (text_el) { text_el.textContent = 'Copy'; } + btn.setAttribute('aria-label', original_label); + btn.classList.remove('copied'); + }, 2000); + } + + if (navigator.clipboard && navigator.clipboard.writeText) { + navigator.clipboard.writeText(text).then(mark_copied).catch(function() { + fallback_copy(code, mark_copied); + }); + } else { + fallback_copy(code, mark_copied); + } + }); }); - }); } function fallback_copy(code_el, on_success) { - var selection = window.getSelection(); - var range = document.createRange(); - range.selectNodeContents(code_el); - selection.removeAllRanges(); - selection.addRange(range); - try { - document.execCommand("copy"); - on_success(); - } catch (e) {} - selection.removeAllRanges(); + var selection = window.getSelection(); + var range = document.createRange(); + range.selectNodeContents(code_el); + selection.removeAllRanges(); + selection.addRange(range); + try { + document.execCommand('copy'); + on_success(); + } catch(e) {} + selection.removeAllRanges(); } (function () { - check_initial_override(); - adjust_for_platform(); - set_up_cycle_button(); - set_up_copy_buttons(); -})(); + check_initial_override(); + adjust_for_platform(); + set_up_cycle_button(); + set_up_copy_buttons(); +}()); From c969fae8432cc04391f91a7cd31cb57b4c3b6a57 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Fri, 10 Apr 2026 01:16:20 +0530 Subject: [PATCH 3/5] fix: move svg code into icon component --- templates/components/icons/check.html.hbs | 3 +++ templates/components/icons/copy.html.hbs | 4 ++++ templates/components/tools/rustup.html.hbs | 27 +++++----------------- 3 files changed, 13 insertions(+), 21 deletions(-) create mode 100644 templates/components/icons/check.html.hbs create mode 100644 templates/components/icons/copy.html.hbs diff --git a/templates/components/icons/check.html.hbs b/templates/components/icons/check.html.hbs new file mode 100644 index 000000000..9a5df5666 --- /dev/null +++ b/templates/components/icons/check.html.hbs @@ -0,0 +1,3 @@ + diff --git a/templates/components/icons/copy.html.hbs b/templates/components/icons/copy.html.hbs new file mode 100644 index 000000000..781ca4548 --- /dev/null +++ b/templates/components/icons/copy.html.hbs @@ -0,0 +1,4 @@ + diff --git a/templates/components/tools/rustup.html.hbs b/templates/components/tools/rustup.html.hbs index d649ee7ae..f11de025b 100644 --- a/templates/components/tools/rustup.html.hbs +++ b/templates/components/tools/rustup.html.hbs @@ -4,13 +4,8 @@
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@@ -35,13 +30,8 @@
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@@ -54,13 +44,8 @@
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
From a7666fd4fa90d5f0f83806003785e0d2161fb094 Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Fri, 10 Apr 2026 01:24:15 +0530 Subject: [PATCH 4/5] fix: remove fallback function --- static/scripts/tools-install.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/static/scripts/tools-install.js b/static/scripts/tools-install.js index 1bce05f85..4955ab196 100644 --- a/static/scripts/tools-install.js +++ b/static/scripts/tools-install.js @@ -201,30 +201,11 @@ function set_up_copy_buttons() { }, 2000); } - if (navigator.clipboard && navigator.clipboard.writeText) { - navigator.clipboard.writeText(text).then(mark_copied).catch(function() { - fallback_copy(code, mark_copied); - }); - } else { - fallback_copy(code, mark_copied); - } + navigator.clipboard.writeText(text).then(mark_copied).catch(function() {}); }); }); } -function fallback_copy(code_el, on_success) { - var selection = window.getSelection(); - var range = document.createRange(); - range.selectNodeContents(code_el); - selection.removeAllRanges(); - selection.addRange(range); - try { - document.execCommand('copy'); - on_success(); - } catch(e) {} - selection.removeAllRanges(); -} - (function () { check_initial_override(); adjust_for_platform(); From d27267ed801b833f4b34c0234bb6824cbc0cec8f Mon Sep 17 00:00:00 2001 From: Kanishk Pachauri Date: Fri, 10 Apr 2026 05:46:03 +0530 Subject: [PATCH 5/5] fix: convert svg components to .svg image --- static/images/check.svg | 3 +++ static/images/copy.svg | 4 ++++ templates/components/icons/check.html.hbs | 3 --- templates/components/icons/copy.html.hbs | 4 ---- templates/components/tools/rustup.html.hbs | 12 ++++++------ 5 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 static/images/check.svg create mode 100644 static/images/copy.svg delete mode 100644 templates/components/icons/check.html.hbs delete mode 100644 templates/components/icons/copy.html.hbs diff --git a/static/images/check.svg b/static/images/check.svg new file mode 100644 index 000000000..3afbd39ff --- /dev/null +++ b/static/images/check.svg @@ -0,0 +1,3 @@ + diff --git a/static/images/copy.svg b/static/images/copy.svg new file mode 100644 index 000000000..75fe25f03 --- /dev/null +++ b/static/images/copy.svg @@ -0,0 +1,4 @@ + diff --git a/templates/components/icons/check.html.hbs b/templates/components/icons/check.html.hbs deleted file mode 100644 index 9a5df5666..000000000 --- a/templates/components/icons/check.html.hbs +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/templates/components/icons/copy.html.hbs b/templates/components/icons/copy.html.hbs deleted file mode 100644 index 781ca4548..000000000 --- a/templates/components/icons/copy.html.hbs +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/templates/components/tools/rustup.html.hbs b/templates/components/tools/rustup.html.hbs index f11de025b..c5300d075 100644 --- a/templates/components/tools/rustup.html.hbs +++ b/templates/components/tools/rustup.html.hbs @@ -4,8 +4,8 @@
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@@ -30,8 +30,8 @@
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
@@ -44,8 +44,8 @@
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh