Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions include/layout.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<span class="' . $algorithm . 'sum">' . $checksum . '</span>';
}

return '<span class="sha256-row"><span class="sha256">' . $checksum . '</span><button type="button" class="sha256-copy" data-copy-text="' . $checksum . '" aria-label="Copy sha256 checksum">Copy</button></span>';
}

function get_nav_items(): array {
return [
new NavItem(
Expand Down
8 changes: 6 additions & 2 deletions include/version.inc
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ function show_source_releases()
<?php download_link($rel['filename'], $rel['filename']); ?>
<span class="releasedate"><?php echo date('d M Y', strtotime($rel['date'])); ?></span>
<?php
if (isset($rel['md5'])) echo '<span class="md5sum">', $rel['md5'], '</span>';
if (isset($rel['sha256'])) echo '<span class="sha256">', $rel['sha256'], '</span>';
if (isset($rel['md5'])) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove the MD5 section?

echo '<span class="md5sum">', $rel['md5'], '</span>';
}
if (isset($rel['sha256'])) {
echo checksum_html($rel['sha256']);
}
?>
<?php if (isset($rel['note']) && $rel['note']): ?>
<p>
Expand Down
15 changes: 15 additions & 0 deletions js/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,3 +879,18 @@ function applyTheme(theme) {
}

applyTheme(savedTheme)

const downloads = document.querySelector('.downloads');
downloads?.addEventListener('click', function (event) {
var button = event.target.closest('.sha256-copy');
if (!button || !navigator.clipboard) {
return;
}

navigator.clipboard.writeText(button.dataset.copyText).then(function () {
button.textContent = 'Copied';
setTimeout(function () {
button.textContent = 'Copy';
}, 1500);
});
});
6 changes: 2 additions & 4 deletions pre-release-builds.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,8 @@
<a href="<?php echo $file_info['path'] ?>"><?php echo "php-{$info['version']}.tar.{$file_type}"; ?></a>
<span class="releasedate"><?php echo date('d M Y', strtotime($info['date'])); ?></span>
<?php foreach ($QA_CHECKSUM_TYPES as $algo): ?>
<span class="<?php echo $algo; ?>">
<?php if (isset($file_info[$algo]) && strlen($file_info[$algo])) : ?>
<?php echo $file_info[$algo]; ?>
<?php echo checksum_html($file_info[$algo], $algo); ?>
<?php else: ?>
<em><small>No checksum value available</small></em>)&nbsp;
<?php endif; ?>
Expand Down Expand Up @@ -189,7 +188,7 @@
}

if ($includeSha && $sha !== '') {
$parts[] = '<span class="sha256">' . htmlspecialchars($sha, ENT_QUOTES, 'UTF-8') . '</span>';
$parts[] = checksum_html($sha);
}

return '<li>' . implode(' ', $parts) . '</li>';
Expand Down Expand Up @@ -311,4 +310,3 @@

<?php
site_footer(['sidebar' => $SIDEBAR_DATA]);

3 changes: 1 addition & 2 deletions releases/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,7 @@ function mk_rel(int $major,
$linebreak = '';
foreach (['md5', 'sha256'] as $cs) {
if (isset($src[$cs])) {
echo $linebreak;
echo "<span class=\"{$cs}sum\">{$cs}: {$src[$cs]}</span>\n";
echo $linebreak, checksum_html($src[$cs], $cs), "\n";
$linebreak = "<br/>";
}
}
Expand Down
37 changes: 35 additions & 2 deletions styles/theme-base.css
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,47 @@ 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,
.downloads .sha256-row {
display: flex;
align-items: center;
gap: 0.5rem;
}
.content-box .sha256-row .sha256,
.downloads .sha256-row .sha256 {
min-width: 0;
}
.content-box .sha256-copy,
.downloads .sha256-copy {
border: 1px solid var(--dark-blue-color);
border-radius: 30px;
background-color: var(--dark-blue-color);
color: #fff;
padding: 0.2rem 0.65rem;
font-size: 0.75rem;
line-height: 1rem;
cursor: pointer;
min-width: 4.25rem;
text-align: center;
white-space: nowrap;
}
.content-box .sha256-copy:hover,
.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);
}
.content-box .releasedate {
float: right;
font-size: 0.9rem;
Expand Down