mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Extend the routing front/back ends to allow for using "/package/$pkgname/" for individual packages. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
57 lines
1 KiB
PHP
57 lines
1 KiB
PHP
<?php
|
|
|
|
$ROUTES = array(
|
|
'' => 'home.php',
|
|
'/index.php' => 'home.php',
|
|
'/packages' => 'packages.php',
|
|
'/register' => 'account.php',
|
|
'/accounts' => 'account.php',
|
|
'/login' => 'login.php',
|
|
'/logout' => 'logout.php',
|
|
'/passreset' => 'passreset.php',
|
|
'/rpc' => 'rpc.php',
|
|
'/rss' => 'rss.php',
|
|
'/submit' => 'pkgsubmit.php',
|
|
'/tu' => 'tu.php',
|
|
'/voters' => 'voters.php',
|
|
'/addvote' => 'addvote.php',
|
|
);
|
|
|
|
$PKG_PATH = '/packages';
|
|
|
|
function get_route($path) {
|
|
global $ROUTES;
|
|
|
|
if (isset($ROUTES[$path])) {
|
|
return $ROUTES[$path];
|
|
} else {
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
function get_uri($path) {
|
|
global $USE_VIRTUAL_URLS;
|
|
global $ROUTES;
|
|
|
|
if ($USE_VIRTUAL_URLS) {
|
|
return $path;
|
|
} else {
|
|
return get_route($path);
|
|
}
|
|
}
|
|
|
|
function get_pkg_route() {
|
|
global $PKG_PATH;
|
|
return $PKG_PATH;
|
|
}
|
|
|
|
function get_pkg_uri($pkgname) {
|
|
global $USE_VIRTUAL_URLS;
|
|
global $PKG_PATH;
|
|
|
|
if ($USE_VIRTUAL_URLS) {
|
|
return $PKG_PATH . '/' . urlencode($pkgname) . '/';
|
|
} else {
|
|
return get_route($PKG_PATH) . '?N=' . urlencode($pkgname);
|
|
}
|
|
}
|