Skip to content

Commit d37c885

Browse files
committed
gh-pages: various minor tweaks
* Minor textual adjustments for the homepage. * Remove modified date for the PHAR listing (as it would currently be inaccurate). * Improve code style consistency of build script. * Remove trailing spaces in style.css file.
1 parent af5b852 commit d37c885

File tree

6 files changed

+30
-25
lines changed

6 files changed

+30
-25
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1+
#
2+
# Auto detect text files and perform LF normalization
3+
#
14
* text=auto eol=lf

.github/workflows/publish-website.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ concurrency:
2424
jobs:
2525
build:
2626
# Don't run on forks.
27-
if: github.repository == 'PHPCSStandards/PHP_CodeSniffer'
27+
if: github.event.repository.fork == false
2828
runs-on: ubuntu-latest
2929
steps:
3030
# By default use the `gh-pages` branch.
@@ -85,4 +85,3 @@ jobs:
8585
- name: Deploy to GitHub Pages
8686
id: deployment
8787
uses: actions/deploy-pages@v4
88-

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
vendor
1+
/vendor/
22
.phpunit.result.cache
33
src/phars/index.html

build/generate_phars_list.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
/**
44
* Script to auto-generate the `phars/index.html` page for the GH Pages website.
55
*
6+
* {@internal This script has a minimum PHP requirement of PHP 7.0.}
7+
*
68
* @copyright 2025 PHPCSStandards and contributors
79
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
810
*/
911

1012
// A directory containing files that are named {phpcs,phpcbf}-*.{phar,phar.asc}.
1113
$pharDir = __DIR__ . '/../src/phars';
1214

13-
$allFiles = array_filter(scandir($pharDir), function ($file) {
15+
$allFiles = array_filter(scandir($pharDir), function (string $file) {
1416
return preg_match('/\.phar(\.asc)?$/', $file);
1517
});
1618

@@ -34,11 +36,11 @@
3436
return version_compare($b, $a);
3537
});
3638

37-
function indent (int $level): string
39+
function indent(int $level): string
3840
{
3941
$indentSpaces = ' ';
4042

41-
$output = "";
43+
$output = '';
4244

4345
for ($i = 0; $i < $level; $i++) {
4446
$output .= $indentSpaces;
@@ -47,36 +49,37 @@ function indent (int $level): string
4749
return $output;
4850
}
4951

50-
function humanReadableFilesize($file) {
52+
function humanReadableFilesize(string $file): string
53+
{
5154
$bytes = filesize($file);
5255

53-
$units = ['B', 'K', 'M', 'G'];
56+
$units = ['B', 'K', 'M', 'G'];
5457
$factor = floor((strlen($bytes) - 1) / 3);
55-
return sprintf("%.1f", $bytes / pow(1024, $factor)) . $units[(int) $factor];
58+
return sprintf('%.1f', $bytes / pow(1024, $factor)) . $units[(int) $factor];
5659
}
5760

5861
$html = "<ul class=\"phar-list\">\n";
5962

6063
foreach ($filesGroupedByVersion as $version => $files) {
6164
sort($files);
6265

63-
$html .= indent(3) . "<li class=\"phar-list__version\">\n" .
64-
indent(4) . "<h2 class=\"phar-list__version-label\">" . $version . "</h2>\n" .
65-
indent(4) . "<ul class=\"phar-list__files\">\n";
66+
$html .= indent(3) . "<li class=\"phar-list__version\">\n"
67+
. indent(4) . '<h2 class="phar-list__version-label">' . $version . "</h2>\n"
68+
. indent(4) . "<ul class=\"phar-list__files\">\n";
6669

6770
foreach ($files as $file) {
6871
$fileSize = humanReadableFilesize($pharDir . '/' . $file);
69-
$lastModifiedDate = shell_exec(escapeshellcmd("git log -1 --pretty=\"format:%cs\" -- " . $pharDir . '/' . $file));
7072

71-
$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";
73+
$html .= indent(5) . '<li><a download href="/phars/' . htmlspecialchars($file) . '">' . htmlspecialchars($file)
74+
. '</a> <span class="phar-list__filesize">' . htmlspecialchars($fileSize) . "</span></li>\n";
7275
}
7376

74-
$html .= indent(4) . "</ul>\n" .
75-
indent(3) . "</li>\n";
77+
$html .= indent(4) . "</ul>\n"
78+
. indent(3) . "</li>\n";
7679
}
7780

78-
$html .= indent(2) . "</li>\n" .
79-
"</ul>\n";
81+
$html .= indent(2) . "</li>\n"
82+
. "</ul>\n";
8083

8184
$template = file_get_contents(__DIR__ . '/phars.html.template');
8285

src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ <h2 class="download-box__title">PHPCBF</h2>
4747
</div>
4848
<aside class="additional-info">
4949
<a href="./phars/">
50-
See more versions in our PHAR archive
50+
Find more versions in the PHAR archive
5151
</a>
5252

5353
</aside>
@@ -59,7 +59,7 @@ <h2 class="download-box__title">PHPCBF</h2>
5959
</svg>
6060
GitHub
6161
</a> | <a href="https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki">
62-
Wiki
62+
Documentation
6363
</a>
6464
</aside>
6565
</main>

src/styles.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
--background-color: #f3f4f6;
66
--foreground-color: #111827;
77
--primary-color: #10b981;
8-
8+
99
@media (prefers-color-scheme: dark) {
1010
--background-color: #111827;
1111
--foreground-color: #f3f4f6;
12-
}
12+
}
1313
}
1414

1515
a {
@@ -27,10 +27,10 @@ html, body {
2727

2828
body {
2929
font-family: 'Open Sans', sans-serif;
30-
30+
3131
background: var(--background-color);
3232
background: radial-gradient(circle, rgba(243, 244, 246, 1) 0%, rgba(209, 213, 219, 1) 100%);
33-
33+
3434
@media (prefers-color-scheme: dark) {
3535
background: radial-gradient(circle, rgba(22, 34, 54, 1) 0%, rgba(17, 24, 39, 1) 100%);
3636
}
@@ -166,7 +166,7 @@ body {
166166
padding-top: 1.5rem;
167167

168168
font-size: .8rem;
169-
min-width: 300px;
169+
min-width: 300px;
170170
}
171171

172172
/* a faint separator between the list items */

0 commit comments

Comments
 (0)