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/html/index.php | 10 +++++++++- web/html/pkgsubmit.php | 2 +- web/html/voters.php | 2 +- web/lib/pkgfuncs.inc.php | 7 +++---- web/lib/routing.inc.php | 18 ++++++++++++++++++ web/template/actions_form.php | 2 +- web/template/pkg_comments.php | 4 ++-- web/template/pkg_details.php | 6 +++--- web/template/pkg_search_results.php | 2 +- web/template/stats/updates_table.php | 2 +- 10 files changed, 40 insertions(+), 15 deletions(-) diff --git a/web/html/index.php b/web/html/index.php index b0f346d..de38178 100644 --- a/web/html/index.php +++ b/web/html/index.php @@ -5,8 +5,16 @@ include_once("config.inc.php"); include_once("routing.inc.php"); $path = rtrim($_SERVER['PATH_INFO'], '/'); +$tokens = explode('/', $path); -if (get_route($path) !== NULL) { +if (isset($tokens[1]) &&'/' . $tokens[1] == get_pkg_route()) { + if (isset($tokens[2])) { + unset($_GET['ID']); + $_GET['N'] = $tokens[2]; + } + + include get_route('/' . $tokens[1]); +} elseif (get_route($path) !== NULL) { include get_route($path); } else { switch ($path) { diff --git a/web/html/pkgsubmit.php b/web/html/pkgsubmit.php index 8c93b0c..b918e8b 100644 --- a/web/html/pkgsubmit.php +++ b/web/html/pkgsubmit.php @@ -400,7 +400,7 @@ if ($uid): # Entire package creation process is atomic end_atomic_commit($dbh); - header('Location: ' . get_uri('/packages/') . '?ID=' . $packageID); + header('Location: ' . get_pkg_uri($pkg_name)); } chdir($cwd); diff --git a/web/html/voters.php b/web/html/voters.php index 378e605..3ba5248 100644 --- a/web/html/voters.php +++ b/web/html/voters.php @@ -15,7 +15,7 @@ if ($atype == 'Trusted User' || $atype== 'Developer'): ?>
-

Votes for

+

Votes for

'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); + } +} diff --git a/web/template/actions_form.php b/web/template/actions_form.php index 9cd5024..045022d 100644 --- a/web/template/actions_form.php +++ b/web/template/actions_form.php @@ -1,5 +1,5 @@
-
+
diff --git a/web/template/pkg_comments.php b/web/template/pkg_comments.php index 5b5f610..40b2fd1 100644 --- a/web/template/pkg_comments.php +++ b/web/template/pkg_comments.php @@ -4,7 +4,7 @@ $count = package_comments_count($_GET['ID']); ?>

- +

@@ -14,7 +14,7 @@ $count = package_comments_count($_GET['ID']); endif; ?>

- +
diff --git a/web/template/pkg_details.php b/web/template/pkg_details.php index 4cb8602..b4b52d5 100644 --- a/web/template/pkg_details.php +++ b/web/template/pkg_details.php @@ -57,7 +57,7 @@ if ($SID && ($uid == $row["MaintainerUID"] || ($atype == "Developer" || $atype == "Trusted User"))): ?> - +
@@ -139,7 +139,7 @@ if ($atype == "Developer" || $atype == "Trusted User"): # darr: (DepName, DepCondition, PackageID), where ID is NULL if it didn't exist if (!is_null($darr[2])): ?> -
  • +
  • @@ -155,7 +155,7 @@ if ($atype == "Developer" || $atype == "Trusted User"): # darr: (PackageName, PackageID) while (list($k, $darr) = each($requiredby)): ?> -
  • +
  • diff --git a/web/template/pkg_search_results.php b/web/template/pkg_search_results.php index 440698b..11db7a1 100644 --- a/web/template/pkg_search_results.php +++ b/web/template/pkg_search_results.php @@ -52,7 +52,7 @@ if (!$result): ?> ]" value="1" /> - "> + "> diff --git a/web/template/stats/updates_table.php b/web/template/stats/updates_table.php index 835d956..6e43e22 100644 --- a/web/template/stats/updates_table.php +++ b/web/template/stats/updates_table.php @@ -6,7 +6,7 @@ getIterator() as $row): ?> - "> + "> -- cgit v1.2.3-70-g09d2