From 03486c3b6feafb18f00b0e0c092a1bd4ac2f3903 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 14 Jul 2012 01:57:19 +0200 Subject: Use virtual paths for package details Extend the routing front/back ends to allow for using "/package/$pkgname/" for individual packages. Signed-off-by: Lukas Fleischer --- web/lib/routing.inc.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'web/lib/routing.inc.php') diff --git a/web/lib/routing.inc.php b/web/lib/routing.inc.php index 0d940a2..e8a2deb 100644 --- a/web/lib/routing.inc.php +++ b/web/lib/routing.inc.php @@ -17,6 +17,8 @@ $ROUTES = array( '/addvote' => 'addvote.php', ); +$PKG_PATH = '/packages'; + function get_route($path) { global $ROUTES; @@ -37,3 +39,19 @@ function get_uri($path) { 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); + } +} -- cgit v1.2.3-70-g09d2