mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add RSS feed for modified packages
This commit is contained in:
parent
e7db894eb7
commit
4330fe4f33
3 changed files with 77 additions and 3 deletions
62
web/html/modified-rss.php
Normal file
62
web/html/modified-rss.php
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib' . PATH_SEPARATOR . '../lang');
|
||||||
|
include_once("aur.inc.php");
|
||||||
|
include_once("pkgfuncs.inc.php");
|
||||||
|
include_once("feedcreator.class.php");
|
||||||
|
|
||||||
|
#detect prefix
|
||||||
|
$protocol = isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=='on' ? "https" : "http";
|
||||||
|
$host = $_SERVER['HTTP_HOST'];
|
||||||
|
|
||||||
|
$feed_key = 'modified-pkg-feed-' . $protocol;
|
||||||
|
|
||||||
|
header("Content-Type: application/rss+xml");
|
||||||
|
|
||||||
|
$bool = false;
|
||||||
|
$ret = get_cache_value($feed_key, $bool);
|
||||||
|
if ($bool) {
|
||||||
|
echo $ret;
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
$rss = new RSSCreator20();
|
||||||
|
$rss->cssStyleSheet = false;
|
||||||
|
$rss->xslStyleSheet = false;
|
||||||
|
|
||||||
|
# Use UTF-8 (fixes FS#10706).
|
||||||
|
$rss->encoding = "UTF-8";
|
||||||
|
|
||||||
|
#All the general RSS setup
|
||||||
|
$rss->title = "AUR Latest Modified Packages";
|
||||||
|
$rss->description = "The latest modified packages in the AUR";
|
||||||
|
$rss->link = "${protocol}://{$host}";
|
||||||
|
$rss->syndicationURL = "{$protocol}://{$host}" . get_uri('/rss/');
|
||||||
|
$image = new FeedImage();
|
||||||
|
$image->title = "AUR Latest Modified Packages";
|
||||||
|
$image->url = "{$protocol}://{$host}/css/archnavbar/aurlogo.png";
|
||||||
|
$image->link = $rss->link;
|
||||||
|
$image->description = "AUR Latest Modified Packages Feed";
|
||||||
|
$rss->image = $image;
|
||||||
|
|
||||||
|
#Get the latest packages and add items for them
|
||||||
|
$packages = latest_modified_pkgs(100);
|
||||||
|
|
||||||
|
foreach ($packages as $indx => $row) {
|
||||||
|
$item = new FeedItem();
|
||||||
|
$item->title = $row["Name"];
|
||||||
|
$item->link = "{$protocol}://{$host}" . get_pkg_uri($row["Name"]);
|
||||||
|
$item->description = $row["Description"];
|
||||||
|
$item->date = intval($row["ModifiedTS"]);
|
||||||
|
$item->source = "{$protocol}://{$host}";
|
||||||
|
$item->author = username_from_id($row["MaintainerUID"]);
|
||||||
|
$item->guidIsPermaLink = true;
|
||||||
|
$item->guid = $row["Name"] . "-" . $row["ModifiedTS"];
|
||||||
|
$rss->addItem($item);
|
||||||
|
}
|
||||||
|
|
||||||
|
#save it so that useCached() can find it
|
||||||
|
$feedContent = $rss->createFeed();
|
||||||
|
set_cache_value($feed_key, $feedContent, 600);
|
||||||
|
echo $feedContent;
|
||||||
|
?>
|
|
@ -925,13 +925,13 @@ function sanitize_ids($ids) {
|
||||||
*
|
*
|
||||||
* @return array $packages Package info for the specified number of recent packages
|
* @return array $packages Package info for the specified number of recent packages
|
||||||
*/
|
*/
|
||||||
function latest_pkgs($numpkgs) {
|
function latest_pkgs($numpkgs, $orderBy='SubmittedTS') {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
|
|
||||||
$q = "SELECT Packages.*, MaintainerUID, SubmittedTS ";
|
$q = "SELECT Packages.*, MaintainerUID, SubmittedTS, ModifiedTS ";
|
||||||
$q.= "FROM Packages LEFT JOIN PackageBases ON ";
|
$q.= "FROM Packages LEFT JOIN PackageBases ON ";
|
||||||
$q.= "PackageBases.ID = Packages.PackageBaseID ";
|
$q.= "PackageBases.ID = Packages.PackageBaseID ";
|
||||||
$q.= "ORDER BY SubmittedTS DESC ";
|
$q.= "ORDER BY " . $orderBy . " DESC ";
|
||||||
$q.= "LIMIT " . intval($numpkgs);
|
$q.= "LIMIT " . intval($numpkgs);
|
||||||
$result = $dbh->query($q);
|
$result = $dbh->query($q);
|
||||||
|
|
||||||
|
@ -944,3 +944,14 @@ function latest_pkgs($numpkgs) {
|
||||||
|
|
||||||
return $packages;
|
return $packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine package information for latest modified packages
|
||||||
|
*
|
||||||
|
* @param int $numpkgs Number of packages to get information on
|
||||||
|
*
|
||||||
|
* @return array $packages Package info for the specified number of recently modified packages
|
||||||
|
*/
|
||||||
|
function latest_modified_pkgs($numpkgs) {
|
||||||
|
return latest_pkgs($numpkgs, 'ModifiedTS');
|
||||||
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ $ROUTES = array(
|
||||||
'/logout' => 'logout.php',
|
'/logout' => 'logout.php',
|
||||||
'/passreset' => 'passreset.php',
|
'/passreset' => 'passreset.php',
|
||||||
'/rpc' => 'rpc.php',
|
'/rpc' => 'rpc.php',
|
||||||
|
'/rss/modified' => 'modified-rss.php',
|
||||||
'/rss' => 'rss.php',
|
'/rss' => 'rss.php',
|
||||||
'/tos' => 'tos.php',
|
'/tos' => 'tos.php',
|
||||||
'/tu' => 'tu.php',
|
'/tu' => 'tu.php',
|
||||||
|
|
Loading…
Add table
Reference in a new issue