mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 09:43:03 +00:00
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 <archlinux@cryptocrack.de>
This commit is contained in:
parent
2425f963f8
commit
03486c3b6f
10 changed files with 40 additions and 15 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -15,7 +15,7 @@ if ($atype == 'Trusted User' || $atype== 'Developer'):
|
|||
?>
|
||||
|
||||
<div class="box">
|
||||
<h2>Votes for <a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2>
|
||||
<h2>Votes for <a href="<?php echo get_pkg_uri(pkgname_from_id($pkgid)); ?>"><?php echo pkgname_from_id($pkgid) ?></a></h2>
|
||||
<div class="boxbody">
|
||||
|
||||
<?php
|
||||
|
|
|
@ -238,8 +238,7 @@ function add_package_comment($pkgid, $uid, $comment, $dbh=NULL) {
|
|||
# Simply making these strings translatable won't work, users would be
|
||||
# getting emails in the language that the user who posted the comment was in
|
||||
$body =
|
||||
'from ' . $AUR_LOCATION . '/' . get_uri('/packages/') . '?ID='
|
||||
. $pkgid . "\n"
|
||||
'from ' . $AUR_LOCATION . '/' . get_pkg_uri($row['Name']) . "\n"
|
||||
. username_from_sid($_COOKIE['AURSID'], $dbh) . " wrote:\n\n"
|
||||
. $comment
|
||||
. "\n\n---\nIf you no longer wish to receive notifications about this package, please go the the above package page and click the UnNotify button.";
|
||||
|
@ -744,7 +743,7 @@ function pkg_flag ($atype, $ids, $action=true, $dbh=NULL) {
|
|||
if (mysql_num_rows($result)) {
|
||||
while ($row = mysql_fetch_assoc($result)) {
|
||||
# construct email
|
||||
$body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/" . get_uri('/packages/') . "?ID=" . $row['ID'] . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?Action=AccountInfo&ID=" . $f_uid;
|
||||
$body = "Your package " . $row['Name'] . " has been flagged out of date by " . $f_name . " [1]. You may view your package at:\n" . $AUR_LOCATION . "/" . get_pkg_uri($row['Name']) . "\n\n[1] - " . $AUR_LOCATION . "/" . get_uri('/accounts/') . "?Action=AccountInfo&ID=" . $f_uid;
|
||||
$body = wordwrap($body, 70);
|
||||
$headers = "Reply-to: nobody@archlinux.org\nFrom:aur-notify@archlinux.org\nX-Mailer: PHP\nX-MimeOLE: Produced By AUR\n";
|
||||
@mail($row['Email'], "AUR Out-of-date Notification for ".$row['Name'], $body, $headers);
|
||||
|
@ -813,7 +812,7 @@ function pkg_delete ($atype, $ids, $mergepkgid, $dbh=NULL) {
|
|||
$body = "";
|
||||
if ($mergepkgid) {
|
||||
$body .= username_from_sid($_COOKIE['AURSID']) . " merged \"".$pkgname."\" into \"$mergepkgname\".\n\n";
|
||||
$body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_uri('/packages/') . "?ID=".$mergepkgid." and click the Notify button if you wish to recieve them again.";
|
||||
$body .= "You will no longer receive notifications about this package, please go to https://aur.archlinux.org/" . get_pkg_uri($mergepkgname) . " and click the Notify button if you wish to recieve them again.";
|
||||
} else {
|
||||
$body .= username_from_sid($_COOKIE['AURSID']) . " deleted \"".$pkgname."\".\n\n";
|
||||
$body .= "You will no longer receive notifications about this package.";
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="box">
|
||||
<form action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>" method="post">
|
||||
<form action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>" method="post">
|
||||
<fieldset>
|
||||
<input type="hidden" name="IDs[<?php echo $row['ID'] ?>]" value="1" />
|
||||
<input type="hidden" name="ID" value="<?php echo $row['ID'] ?>" />
|
||||
|
|
|
@ -4,7 +4,7 @@ $count = package_comments_count($_GET['ID']);
|
|||
?>
|
||||
<div id="news">
|
||||
<h3>
|
||||
<a href="<?php echo htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES) ?>&comments=all" title="<?php echo __('View all %s comments' , $count) ?>"><?php echo __('Latest Comments') ?></a>
|
||||
<a href="<?php echo htmlentities($_SERVER['REQUEST_URI'], ENT_QUOTES) ?>?comments=all" title="<?php echo __('View all %s comments' , $count) ?>"><?php echo __('Latest Comments') ?></a>
|
||||
<span class="arrow"></span>
|
||||
</h3>
|
||||
|
||||
|
@ -14,7 +14,7 @@ $count = package_comments_count($_GET['ID']);
|
|||
endif; ?>
|
||||
<h4>
|
||||
<?php if (canDeleteCommentArray($row, $atype, $uid)): ?>
|
||||
<form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row['ID'] ?>">
|
||||
<form method="post" action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>">
|
||||
<fieldset style="display:inline;">
|
||||
<input type="hidden" name="action" value="do_DeleteComment" />
|
||||
<input type="hidden" name="comment_id" value="<?php echo $row['ID'] ?>" />
|
||||
|
|
|
@ -57,7 +57,7 @@ if ($SID && ($uid == $row["MaintainerUID"] ||
|
|||
($atype == "Developer" || $atype == "Trusted User"))):
|
||||
?>
|
||||
<td>
|
||||
<form method="post" action="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $pkgid ?>">
|
||||
<form method="post" action="<?php echo htmlspecialchars(get_pkg_uri($row['Name']), ENT_QUOTES); ?>">
|
||||
<div>
|
||||
<input type="hidden" name="action" value="do_ChangeCategory" />
|
||||
<?php if ($SID): ?>
|
||||
|
@ -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])):
|
||||
?>
|
||||
<li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[2]?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li>
|
||||
<li><a href="<?php echo htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1]?>"><?php echo $darr[0].$darr[1]?></a></li>
|
||||
<?php else: ?>
|
||||
<li><a href="http://www.archlinux.org/packages/?q=<?php echo urlencode($darr[0])?>" title="<?php echo __('View packages details for').' '.$darr[0].$darr[1] ?>"><?php echo $darr[0].$darr[1] ?></a></li>
|
||||
<?php endif; ?>
|
||||
|
@ -155,7 +155,7 @@ if ($atype == "Developer" || $atype == "Trusted User"):
|
|||
# darr: (PackageName, PackageID)
|
||||
while (list($k, $darr) = each($requiredby)):
|
||||
?>
|
||||
<li><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $darr[1] ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li>
|
||||
<li><a href="<?php echo htmlspecialchars(get_pkg_uri($darr[0]), ENT_QUOTES); ?>" title="<?php echo __('View packages details for').' '.$darr[0]?>"><?php echo $darr[0] ?></a></li>
|
||||
<?php endwhile; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -52,7 +52,7 @@ if (!$result): ?>
|
|||
<td><input type="checkbox" name="IDs[<?php echo $row["ID"] ?>]" value="1" /></td>
|
||||
<?php endif; ?>
|
||||
<td><?php echo htmlspecialchars($row["Category"]) ?></td>
|
||||
<td><a href="<?php echo get_uri('/packages/'); ?>?ID=<?php echo $row["ID"] ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td>
|
||||
<td><a href="<?php echo htmlspecialchars(get_pkg_uri($row["Name"]), ENT_QUOTES); ?>"><?php echo htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]) ?></a></td>
|
||||
<td><?php echo $row["NumVotes"] ?></td>
|
||||
<?php if ($SID): ?>
|
||||
<td>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<?php foreach ($newest_packages->getIterator() as $row): ?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo get_uri('/packages/'); ?>?ID=<?php print intval($row["ID"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a>
|
||||
<a href="<?php echo get_pkg_uri($row["Name"]); ?>"><?php print htmlspecialchars($row["Name"]) . ' ' . htmlspecialchars($row["Version"]); ?></a>
|
||||
</td>
|
||||
<td>
|
||||
<span><?php print gmdate("Y-m-d H:i", intval($row["ModifiedTS"])); ?></span>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue