File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,14 @@ function indent (int $level): string
41
41
return $ output ;
42
42
}
43
43
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
+
44
52
$ html = "<ul class= \"phar-list \"> \n" ;
45
53
46
54
foreach ($ filesGroupedByVersion as $ version => $ files ) {
@@ -51,7 +59,10 @@ function indent (int $level): string
51
59
indent (4 ) . "<ul class= \"phar-list__files \"> \n" ;
52
60
53
61
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" ;
55
66
}
56
67
57
68
$ html .= indent (4 ) . "</ul> \n" .
Original file line number Diff line number Diff line change @@ -191,4 +191,10 @@ body {
191
191
* + * {
192
192
margin-top : 0.25rem ;
193
193
}
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 ;
194
200
}
You can’t perform that action at this time.
0 commit comments