mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add clone hints to 404 error pages
When clicking on the linked Git clone URL of a package base, users are faced with a 404 error page since the URL is not supposed to be opened in a web browser. Add some notes to 404 error pages corresponding to Git clone URLs that explain how to use them instead. Fixes FS#51266. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
df6bb72807
commit
e182ba0c42
1 changed files with 33 additions and 0 deletions
|
@ -2,12 +2,45 @@
|
|||
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib');
|
||||
|
||||
$path = $_SERVER['PATH_INFO'];
|
||||
$tokens = explode('/', $path);
|
||||
|
||||
if (preg_match('/^([a-z0-9][a-z0-9.+_-]*?)(\.git)?$/', $tokens[1], $matches)) {
|
||||
$gitpkg = $matches[1];
|
||||
if (pkg_from_name($gitpkg)) {
|
||||
$gitcmd = 'git clone ' . sprintf(config_get('options', 'git_clone_uri_anon'), htmlspecialchars($gitpkg));
|
||||
$gitlink = get_pkgbase_uri($gitpkg);
|
||||
} else {
|
||||
unset($gitpkg);
|
||||
}
|
||||
} else {
|
||||
unset($gitpkg);
|
||||
}
|
||||
|
||||
html_header( __("Page Not Found") );
|
||||
?>
|
||||
|
||||
<div id="error-page" class="box 404">
|
||||
<h2>404 - <?= __("Page Not Found") ?></h2>
|
||||
<p><?= __("Sorry, the page you've requested does not exist.") ?></p>
|
||||
<?php if (isset($gitpkg)): ?>
|
||||
<ul>
|
||||
<li>
|
||||
<strong><?= __("Note") ?>:</strong>
|
||||
<?= __("Git clone URLs are not meant to be opened in a browser.") ?>
|
||||
</li>
|
||||
<li>
|
||||
<?= __("To clone the Git repository of %s, run %s.",
|
||||
'<strong>' . htmlspecialchars($gitpkg) . '</strong>',
|
||||
'<code>' . htmlspecialchars($gitcmd) . '</code>') ?>
|
||||
</li>
|
||||
<li>
|
||||
<?= __("Click %shere%s to return to the %s details page.",
|
||||
'<a href="' . htmlspecialchars($gitlink, ENT_QUOTES) . '">', '</a>',
|
||||
'<strong>' . htmlspecialchars($gitpkg) . '</strong>') ?>
|
||||
</li>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
|
Loading…
Add table
Reference in a new issue