Skip to content

Commit 127edf8

Browse files
committed
gh-pages: add filesize and committer date
See https://git-scm.com/docs/pretty-formats
1 parent 05b61fc commit 127edf8

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

build/generate_phars_list.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ function indent (int $level): string
4141
return $output;
4242
}
4343

44+
function humanReadableFilesize($file) {
45+
$bytes = filesize($file);
46+
47+
$units = ['B', 'K', 'M', 'G'];
48+
$factor = floor((strlen($bytes) - 1) / 3);
49+
return sprintf("%.1f", $bytes / pow(1024, $factor)) . $units[(int) $factor];
50+
}
51+
4452
$html = "<ul class=\"phar-list\">\n";
4553

4654
foreach ($filesGroupedByVersion as $version => $files) {
@@ -51,7 +59,10 @@ function indent (int $level): string
5159
indent(4) . "<ul class=\"phar-list__files\">\n";
5260

5361
foreach ($files as $file) {
54-
$html .= indent(5) . "<li><a download href=\"phars/" . htmlspecialchars($file) . '">' . htmlspecialchars($file) . "</a></li>\n";
62+
$fileSize = humanReadableFilesize($pharDir . '/' . $file);
63+
$lastModifiedDate = shell_exec(escapeshellcmd("git log -1 --pretty=\"format:%cs\" -- " . $pharDir . '/' . $file));
64+
65+
$html .= indent(5) . "<li><a download href=\"/phars/" . htmlspecialchars($file) . '">' . htmlspecialchars($file) . "</a> <span class=\"phar-list__filesize\">" . htmlspecialchars($fileSize) . " | " . htmlspecialchars($lastModifiedDate) . "</span></li>\n";
5566
}
5667

5768
$html .= indent(4) . "</ul>\n" .

src/styles.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,4 +191,10 @@ body {
191191
* + * {
192192
margin-top: 0.25rem;
193193
}
194+
}
195+
196+
.phar-list__filesize {
197+
color: color-mix(in srgb, var(--foreground-color), #6b7280);
198+
font-size: 0.8em;
199+
margin-left: 0.25rem;
194200
}

0 commit comments

Comments
 (0)