Skip to content

Commit e787bc9

Browse files
committed
Add links to download PGP signatures, fixes #191
1 parent ce25411 commit e787bc9

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

src/Controller/HomeController.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\Routing\Annotation\Route;
99
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
1010
use Symfony\Component\HttpFoundation\BinaryFileResponse;
11+
use Symfony\Component\HttpFoundation\RedirectResponse;
1112

1213
class HomeController extends AbstractController
1314
{
@@ -140,6 +141,24 @@ public function downloadSha256Sum(string $projectDir, Request $req): Response
140141
]);
141142
}
142143

144+
/**
145+
* @Route("/download/latest-stable/composer.phar.asc", name="download_asc_stable")
146+
* @Route("/download/latest-preview/composer.phar.asc", name="download_asc_preview")
147+
* @Route("/download/latest-2.x/composer.phar.asc", name="download_asc_2x")
148+
* @Route("/download/{version}/composer.phar.asc", name="download_asc_specific")
149+
*/
150+
public function downloadPGPSignature(string $projectDir, Request $req, string $version = null): Response
151+
{
152+
$channel = str_replace('download_asc_', '', $req->attributes->get('_route'));
153+
if ($channel !== 'specific') {
154+
$channel = preg_replace('{^(\d+)x$}', '$1', $channel);
155+
$versions = json_decode(file_get_contents($projectDir.'/web/versions'), true);
156+
$version = $versions[$channel][0]['version'];
157+
}
158+
159+
return new RedirectResponse('https://github.com/composer/composer/releases/download/'.$version.'/composer.phar.asc');
160+
}
161+
143162
/**
144163
* @Route("/download/{version}/composer.phar", name="download_version")
145164
* @Route("/download/{version}/composer.phar.sha256sum", name="download_version_sha256sum")

templates/download.html.twig

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ php -r "unlink('composer-setup.php');"</pre>
9898
aria-label="Get the lastest composer stable release's SHA256 sum">sha256</a> /
9999
<a href="{{ path('download_sha256sum_stable') }}"
100100
title="Get the lastest composer stable release's SHA256 sum in sha256sum format"
101-
aria-label="Get the lastest composer stable release's SHA256 sum in sha256sum format">sha256sum</a>)
101+
aria-label="Get the lastest composer stable release's SHA256 sum in sha256sum format">sha256sum</a> /
102+
<a href="{{ path('download_asc_stable') }}"
103+
title="Get the lastest composer stable release's PGP signature"
104+
aria-label="Get the lastest composer stable release's PGP signature">asc</a>)
102105
<br/>
103106
<a href="{{ path('download_preview') }}"
104107
title="Get the lastest composer preview release"
@@ -108,7 +111,10 @@ php -r "unlink('composer-setup.php');"</pre>
108111
aria-label="Get the lastest composer preview release's SHA256 sum">sha256</a> /
109112
<a href="{{ path('download_sha256sum_preview') }}"
110113
title="Get the lastest composer preview release's SHA256 sum in sha256sum format"
111-
aria-label="Get the lastest composer preview release's SHA256 sum in sha256sum format">sha256sum</a>)
114+
aria-label="Get the lastest composer preview release's SHA256 sum in sha256sum format">sha256sum</a> /
115+
<a href="{{ path('download_asc_preview') }}"
116+
title="Get the lastest composer preview release's PGP signature"
117+
aria-label="Get the lastest composer preview release's PGP signature">asc</a>)
112118
<br/>
113119
<a href="{{ path('download_snapshot') }}"
114120
title="Get the lastest composer snapshot"
@@ -138,7 +144,10 @@ php -r "unlink('composer-setup.php');"</pre>
138144
aria-label="Get the lastest composer 2.x stable release's SHA256 sum">sha256</a> /
139145
<a href="{{ path('download_sha256sum_2x') }}"
140146
title="Get the lastest composer 2.x stable release's SHA256 sum in sha256sum format"
141-
aria-label="Get the lastest composer 2.x stable release's SHA256 sum in sha256sum format">sha256sum</a>)
147+
aria-label="Get the lastest composer 2.x stable release's SHA256 sum in sha256sum format">sha256sum</a> /
148+
<a href="{{ path('download_asc_2x') }}"
149+
title="Get the lastest composer 2.x release's PGP signature"
150+
aria-label="Get the lastest composer 2.x release's PGP signature">asc</a>)
142151
<br/>
143152
</p>
144153
<table aria-label="Composer versions history" role="table" aria-describedby="composer-history-caption">
@@ -151,11 +160,16 @@ php -r "unlink('composer-setup.php');"</pre>
151160
aria-label="Download version {{ version }}">{{ version }}</a>
152161
</td>
153162
<td style="width: 100px" role="cell">{{ meta.date|date('Y-m-d') }}</td>
154-
<td role="cell" style="width: 500px">
163+
<td role="cell" style="width: 530px">
155164
<a href="{{ path('download_version', {version: version}) }}.sha256sum"
156165
title="Download the SHA256 checksum for version {{ version }} in sha256sum format"
157-
aria-label="Download the SHA256 checksum for version {{ version }} in sha256sum format">sha256sum</a> <code
158-
style="font-size: 0.7em; position: relative; top: -2px">{{ meta.sha256sum }}</code>
166+
aria-label="Download the SHA256 checksum for version {{ version }} in sha256sum format">sha256sum</a>
167+
<code style="font-size: 0.7em; position: relative; top: -2px" aria-label="sha256 checksum" title="sha256 checksum">{{ meta.sha256sum }}</code>
168+
{% if version >= '2.0.3' or version >= '2.0.10' and version != '2.0.2' %}
169+
<a href="{{ path('download_asc_specific', {version: version}) }}"
170+
title="Get the PGP signature for version {{ version }}"
171+
aria-label="Get the PGP signature for version {{ version }}">asc</a>
172+
{% endif %}
159173
</td>
160174
<td role="cell">
161175
<a href="{{ path('changelog', {version: version}) }}"

0 commit comments

Comments
 (0)