From 60d11022f2ba23643c658755888ef9d9b44d6291 Mon Sep 17 00:00:00 2001 From: Luffy <52o@qq52o.cn> Date: Mon, 6 Jul 2026 17:53:23 +0800 Subject: [PATCH 1/2] Add a copy function for the SHA256 checksum --- include/version.inc | 26 ++++++++++++++++++++++++-- styles/theme-base.css | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/include/version.inc b/include/version.inc index 31e4ff7a8a..a18b7d84cf 100644 --- a/include/version.inc +++ b/include/version.inc @@ -139,8 +139,15 @@ function show_source_releases() ', $rel['md5'], ''; - if (isset($rel['sha256'])) echo '', $rel['sha256'], ''; + if (isset($rel['md5'])) { + echo '', $rel['md5'], ''; + } + if (isset($rel['sha256'])) { + echo ''; + echo '', $rel['sha256'], ''; + echo ''; + echo ''; + } ?>

@@ -161,5 +168,20 @@ function show_source_releases() + Date: Wed, 8 Jul 2026 18:02:31 +0800 Subject: [PATCH 2/2] Add copy functionality for SHA256 checksum and optimize display --- include/layout.inc | 12 ++++++++++++ include/version.inc | 20 +------------------- js/common.js | 15 +++++++++++++++ pre-release-builds.php | 6 ++---- releases/index.php | 3 +-- styles/theme-base.css | 19 +++++++++++++------ 6 files changed, 44 insertions(+), 31 deletions(-) diff --git a/include/layout.inc b/include/layout.inc index 30550b6a65..eea636a0f7 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -504,6 +504,18 @@ function site_footer(array $config = []): void require __DIR__ . "/footer.inc"; } +function checksum_html(string $checksum, string $algorithm = 'sha256'): string +{ + $checksum = htmlspecialchars($checksum, ENT_QUOTES, 'UTF-8'); + $algorithm = htmlspecialchars($algorithm, ENT_QUOTES, 'UTF-8'); + + if ($algorithm !== 'sha256') { + return '' . $checksum . ''; + } + + return '' . $checksum . ''; +} + function get_nav_items(): array { return [ new NavItem( diff --git a/include/version.inc b/include/version.inc index a18b7d84cf..0f59fcfd66 100644 --- a/include/version.inc +++ b/include/version.inc @@ -143,10 +143,7 @@ function show_source_releases() echo '', $rel['md5'], ''; } if (isset($rel['sha256'])) { - echo ''; - echo '', $rel['sha256'], ''; - echo ''; - echo ''; + echo checksum_html($rel['sha256']); } ?> @@ -168,20 +165,5 @@ function show_source_releases() - "> - - + No checksum value available @@ -189,7 +188,7 @@ } if ($includeSha && $sha !== '') { - $parts[] = '' . htmlspecialchars($sha, ENT_QUOTES, 'UTF-8') . ''; + $parts[] = checksum_html($sha); } return '

  • ' . implode(' ', $parts) . '
  • '; @@ -311,4 +310,3 @@ $SIDEBAR_DATA]); - diff --git a/releases/index.php b/releases/index.php index 6044ae8a3d..41b11524dd 100644 --- a/releases/index.php +++ b/releases/index.php @@ -222,8 +222,7 @@ function mk_rel(int $major, $linebreak = ''; foreach (['md5', 'sha256'] as $cs) { if (isset($src[$cs])) { - echo $linebreak; - echo "{$cs}: {$src[$cs]}\n"; + echo $linebreak, checksum_html($src[$cs], $cs), "\n"; $linebreak = "
    "; } } diff --git a/styles/theme-base.css b/styles/theme-base.css index 1715046f8a..a6cd2fe9e9 100644 --- a/styles/theme-base.css +++ b/styles/theme-base.css @@ -789,23 +789,28 @@ fieldset { overflow: hidden; text-overflow: ellipsis; } -.content-box .md5sum:before { +.content-box .md5sum:before, +.downloads .md5sum:before { content: "md5: "; font-family: var(--font-family-sans-serif); } -.content-box .sha256:before { +.content-box .sha256:before, +.downloads .sha256:before { content: "sha256: "; font-family: var(--font-family-sans-serif); } -.content-box .sha256-row { +.content-box .sha256-row, +.downloads .sha256-row { display: flex; align-items: center; gap: 0.5rem; } -.content-box .sha256-row .sha256 { +.content-box .sha256-row .sha256, +.downloads .sha256-row .sha256 { min-width: 0; } -.content-box .sha256-copy { +.content-box .sha256-copy, +.downloads .sha256-copy { border: 1px solid var(--dark-blue-color); border-radius: 30px; background-color: var(--dark-blue-color); @@ -819,7 +824,9 @@ fieldset { white-space: nowrap; } .content-box .sha256-copy:hover, -.content-box .sha256-copy:focus { +.content-box .sha256-copy:focus, +.downloads .sha256-copy:hover, +.downloads .sha256-copy:focus { border-color: var(--dark-magenta-color); background-color: var(--dark-magenta-color); }