copr-be: add link to Pulp content for a given project

Fix https://github.com/fedora-copr/copr/issues/3448

The only downside is that there IMHO isn't any way of distinguishing if a given
project stores results in Pulp or not and therefore the link will be shown to
all projects. If you think it will be confusing for users, we can merge once the
majority of Copr projects uses Pulp.
This commit is contained in:
Jakub Kadlcik 2025-07-04 11:12:37 +02:00
parent be2e3a6d35
commit c10d3aa108

View file

@ -260,6 +260,7 @@ foreach($filelist as $file) {
$frontend_baseurl = '{{ frontend_base_url }}';
$pulp_baseurl = '{{ pulp_content_url }}';
$path = explode('/', $_SERVER['REQUEST_URI']);
if (count($path) >= 7) {
$owner = preg_replace('/^(@|%40)(.*)$/', 'g/$2', $path[2]);
@ -267,14 +268,20 @@ if (count($path) >= 7) {
$buildid = ltrim(explode('-', $path[5])[0], '0');
$frontend_url = implode('/', [$frontend_baseurl, 'coprs', $owner, $project, 'build', $buildid]);
$frontend_url_text = 'Go to COPR frontend build';
$pulp_url = implode('/', [$pulp_baseurl, $owner, $project]);
$pulp_url_text = 'Go to Pulp results for this project';
} else if (count($path) >= 5) {
$owner = preg_replace('/^(@|%40)(.*)$/', 'g/$2', $path[2]);
$project = $path[3];
$frontend_url = implode('/', [$frontend_baseurl, 'coprs', $owner, $project]);
$frontend_url_text = 'Go to COPR frontend project';
$pulp_url = implode('/', [$pulp_baseurl, $owner, $project]);
$pulp_url_text = 'Go to Pulp results for this project';
} else {
$frontend_url = $frontend_baseurl;
$frontend_url_text = 'Go to COPR frontend';
$pulp_url = $pulp_baseurl;
$pulp_url_text = 'Go to Pulp';
}
// Print ending stuff
@ -282,7 +289,10 @@ print "</tbody>
</table>
</div>
<div class='script_title'>Lighttpd Enhanced Directory Listing Script</div>
<div class='script_title' style='float:left; font-size:10pt'><a href=".$frontend_url.">".$frontend_url_text."</a></div>
<div class='script_title' style='float:left; font-size:10pt'>
<a href=".$frontend_url.">".$frontend_url_text."</a> |
<a href=".$pulp_url." title='Not all Copr projects store results in Pulp yet'>".$pulp_url_text."</a>
</div>
<script type='text/javascript'>
// <!--