2024-06-01 22:31:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Distroquery API Template
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @file distroquery.php
|
|
|
|
* @package openmamba-theme
|
|
|
|
* @author Silvan Calarco
|
|
|
|
* @copyright 2024
|
|
|
|
* @license license.txt
|
|
|
|
* @version Release: 1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Exit if accessed directly
|
|
|
|
if ( !defined( 'ABSPATH' ) ) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2024-06-29 12:52:20 +02:00
|
|
|
$url_prefix = home_url() . "/rpms/";
|
2024-06-01 22:31:12 +02:00
|
|
|
|
|
|
|
?>
|
|
|
|
<?php get_header(); ?>
|
|
|
|
|
2024-06-02 12:19:32 +02:00
|
|
|
<div id="content-full" class="grid col-940"><span id="distromatic">
|
2024-06-01 22:31:12 +02:00
|
|
|
|
|
|
|
<?php
|
2024-06-02 12:19:32 +02:00
|
|
|
// Navigation bar
|
|
|
|
echo "<a href=\"" . home_url() . "\">Home</a>";
|
2024-06-01 22:31:12 +02:00
|
|
|
|
|
|
|
$repo=get_query_var('repo');
|
|
|
|
$package=get_query_var('package');
|
|
|
|
$arch=get_query_var('arch');
|
|
|
|
|
2024-06-29 14:04:42 +02:00
|
|
|
|
2024-06-01 22:31:12 +02:00
|
|
|
if ($repo == "") {
|
|
|
|
//
|
|
|
|
// Repositories
|
|
|
|
//
|
2024-06-29 14:04:42 +02:00
|
|
|
echo " > " . _r("Repositories");
|
2024-06-02 12:19:32 +02:00
|
|
|
|
2024-06-29 14:04:42 +02:00
|
|
|
echo "<h1>" . _r("Available repositories") . ":</h1>";
|
2024-06-01 22:31:12 +02:00
|
|
|
$request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/repositories');
|
2024-06-02 12:19:32 +02:00
|
|
|
$j = json_decode($request["body"], true);
|
2024-06-01 22:31:12 +02:00
|
|
|
foreach ($j as $repository) {
|
|
|
|
$repository_url = $url_prefix . $repository["tag"];
|
|
|
|
echo "<a href=\"" . $repository_url . "\">". $repository["tag"] . "</a>: " . $repository["description"] . "</br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ($package == "") {
|
|
|
|
//
|
|
|
|
// Repository
|
|
|
|
//
|
2024-06-02 12:19:32 +02:00
|
|
|
echo " > <a href=\"" . $url_prefix . "\">Repositories</a>";
|
|
|
|
|
2024-07-06 17:22:41 +02:00
|
|
|
$page = $_GET['page'];
|
|
|
|
if ($page != "") $query_string="?page=" . $page;
|
|
|
|
$request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/repository/' . $repo . $query_string);
|
2024-06-02 12:19:32 +02:00
|
|
|
$j = json_decode($request["body"], true);
|
|
|
|
|
|
|
|
if ($j["error"] != "") {
|
|
|
|
echo "<h3>ERROR: " . $j["error"] . "</h3>";
|
|
|
|
} else {
|
|
|
|
|
|
|
|
echo " > " . $repo;
|
2024-06-29 14:04:42 +02:00
|
|
|
echo "<h1>" . _r("List of packages") . ":</h1>";
|
2024-06-02 12:19:32 +02:00
|
|
|
|
2024-07-06 17:22:41 +02:00
|
|
|
// Pagination
|
|
|
|
if ($j["query"]["pages"]) {
|
|
|
|
$page = $j["query"]["page"];
|
|
|
|
$pages = $j["query"]["pages"];
|
|
|
|
$from_page = 1;
|
|
|
|
if ($page > 10) $from_page = $page - 10;
|
|
|
|
$to_page = $from_page + 20;
|
|
|
|
if ($to_page > $pages) {
|
|
|
|
$to_page = $pages;
|
|
|
|
$from_page = $to_page - 20;
|
|
|
|
if ($from_page < 1) $from_page = 1;
|
|
|
|
}
|
|
|
|
echo _r("Page") . " " . $page . " " . _r("of") . " " . $pages . " [ ";
|
|
|
|
if ($from_page > 1) {
|
|
|
|
$back_page = $from_page - 10;
|
|
|
|
if ($back_page < 1) $back_page = 1;
|
|
|
|
echo "<a href=\"" . $url_prefix . "/" . $repo . "?page=" . $back_page . "\"><</a> ";
|
|
|
|
}
|
|
|
|
for ($i = $from_page; $i <= $to_page; $i++) {
|
|
|
|
if ($i != $j["query"]["page"]) {
|
|
|
|
echo "<a href=\"" . $url_prefix . "/" . $repo . "?page=" . $i . "\">" . $i . "</a> ";
|
|
|
|
} else {
|
|
|
|
echo "<strong>" . $i . "</strong> ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($to_page < $pages) {
|
|
|
|
$next_page = $to_page + 10;
|
|
|
|
if ($next_page > $pages) $next_page = $pages;
|
|
|
|
if ($next_page < 1) $next_page = 1;
|
|
|
|
echo "<a href=\"" . $url_prefix . "/" . $repo . "?page=" . $next_page . "\">></a> ";
|
|
|
|
}
|
|
|
|
echo "]</br></br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($j["packages"] as $package) {
|
2024-06-02 12:19:32 +02:00
|
|
|
$package_url = $url_prefix . $repo . "/" . $package["name"];
|
|
|
|
echo "<a href=\"" . $package_url . "\">". $package["name"] . "</a>: " . $package["summary"] . "</br>";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2024-06-01 22:31:12 +02:00
|
|
|
|
2024-06-02 12:19:32 +02:00
|
|
|
} else if ($arch == "") {
|
|
|
|
//
|
|
|
|
// Source package
|
|
|
|
//
|
2024-06-29 14:04:42 +02:00
|
|
|
echo " > <a href=\"" . $url_prefix . "\">" . _r("Repositories") . "</a>";
|
2024-06-02 12:19:32 +02:00
|
|
|
|
|
|
|
$request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/package/'. $repo . "/" . $package);
|
|
|
|
$j = json_decode($request["body"], true);
|
|
|
|
|
|
|
|
if ($j["error"] != "") {
|
2024-06-29 14:04:42 +02:00
|
|
|
echo "<h3>" . _r("ERROR") . ": " . $j["error"] . "</h3>";
|
2024-06-02 12:19:32 +02:00
|
|
|
} else {
|
|
|
|
echo " > <a href=\"" . $url_prefix . "/" . $repo . "\">$repo</a> > " . $package;
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2024-06-29 14:04:42 +02:00
|
|
|
<div class="box" style="float:right;min-width:150px;padding:10px;">
|
|
|
|
<b><?php echo _r("Resources") ?>:</b><br/>
|
|
|
|
<a href="<?php echo $j["source_url"] ?>" target=_blank><?php echo _r("Source files") ?></a> |
|
|
|
|
<a href="<?php echo $j["source_url"] ?>/commits/branch/main" target=_blank><?php echo _r("Changes") ?></a><br/>
|
|
|
|
<a href="<?php echo $j["source_url"] ?>/issues" target=_blank><?php echo _r("Issues") ?></a> |
|
|
|
|
<a href="<?php echo $j["source_url"] ?>/issues/new" target=_blank><?php echo _r("Add a new issue") ?></a><br/>
|
|
|
|
<a href="<?php echo $j["download_url"] ?>" target=_blank><?php echo _r("Download") ?></a>
|
|
|
|
</div>
|
|
|
|
|
2024-06-02 12:19:32 +02:00
|
|
|
<h1><img src="https://www.google.com/s2/favicons?domain=<?php echo $j["url"] ?>" width="24" height="24">
|
|
|
|
<?php echo $j["name"] ?>: <?php echo $j["summary"] ?></h1>
|
|
|
|
|
|
|
|
<table class="pkgpage" width="100%">
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Name") ?>:</td><td><?php echo $j["name"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Release") ?>:</td><td>
|
2024-06-02 12:19:32 +02:00
|
|
|
<?php if ($j["epoch"] != "0") echo $j["epoch"].":";
|
|
|
|
echo $j["version"]."-".$j["release"] ?></td></tr>
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Group") ?>:</td><td><?php echo $j["group"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Maintainer") ?>:</td><td><?php echo $j["maintainer"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Description") ?>:</td><td><?php echo $j["description"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("License") ?>:</td><td><?php echo $j["license"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Size") ?>:</td><td><?php echo $j["size"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Upstream URL") ?>:</td><td><a href="<?php echo $j["url"] ?>" target=_blank><?php echo $j["url"] ?></a></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Build time") ?>:</td><td><?php echo iso8601_to_datetime($j["buildtime"]) ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Built RPMS") ?>:</td><td><?php
|
2024-06-02 12:19:32 +02:00
|
|
|
foreach ($j["children"] as $child) {
|
|
|
|
$child_url = $url_prefix . $repo . "/" . $child["name"] . "/" . $child["arch"];
|
|
|
|
echo "<a href=\"" . $child_url . "\">" . $child["name"] . "(" . $child["arch"] . ")</a> ";
|
|
|
|
} ?>
|
|
|
|
</td></tr>
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Build requirements") ?>:</td><td><?php
|
2024-06-02 12:19:32 +02:00
|
|
|
foreach ($j["buildrequires"] as $buildrequire) {
|
|
|
|
echo $buildrequire["name"];
|
|
|
|
if ($buildrequire["flags"] != "") echo "[" . $buildrequire["flags"] . $buildrequire["version"] . "]";
|
|
|
|
echo " ";
|
|
|
|
} ?>
|
|
|
|
</td></tr>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
}
|
|
|
|
} else if ($arch != "") {
|
2024-06-01 22:31:12 +02:00
|
|
|
//
|
|
|
|
// Package
|
|
|
|
//
|
2024-06-29 14:04:42 +02:00
|
|
|
echo " > <a href=\"" . $url_prefix . "\">" . _r("Repositories") . "</a>";
|
2024-06-02 12:19:32 +02:00
|
|
|
|
2024-06-01 22:31:12 +02:00
|
|
|
$request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/package/'. $repo . "/" . $package . "/" . $arch);
|
|
|
|
$j = json_decode($request["body"],true);
|
2024-06-02 12:19:32 +02:00
|
|
|
if ($j["error"] != "") {
|
2024-06-29 14:04:42 +02:00
|
|
|
echo "<h3>" . _r("ERROR") . ": " . $j["error"] . "</h3>";
|
2024-06-02 12:19:32 +02:00
|
|
|
} else {
|
|
|
|
echo " > <a href=\"" . $url_prefix . "/" . $repo . "\">$repo</a> > " . $package . " (" . $arch . ")";
|
|
|
|
|
2024-06-01 22:31:12 +02:00
|
|
|
?>
|
|
|
|
|
2024-06-29 14:04:42 +02:00
|
|
|
<div class="box" style="float:right;min-width:150px;padding:10px;">
|
|
|
|
<b><?php echo _r("Resources") ?>:</b><br/>
|
|
|
|
<a href="<?php echo $j["source"]["source_url"] ?>" target=_blank><?php echo _r("Source files") ?></a> |
|
|
|
|
<a href="<?php echo $j["source"]["source_url"] ?>/commits/branch/main" target=_blank><?php echo _r("Changes") ?></a><br/>
|
|
|
|
<a href="<?php echo $j["source"]["source_url"] ?>/issues" target=_blank><?php echo _r("Issues") ?></a> |
|
|
|
|
<a href="<?php echo $j["source"]["source_url"] ?>/issues/new" target=_blank><?php echo _r("Add a new issue") ?></a><br/>
|
|
|
|
<a href="<?php echo $j["download_url"] ?>" target=_blank><?php echo _r("Download") ?></a>
|
|
|
|
</div>
|
|
|
|
|
2024-06-02 12:19:32 +02:00
|
|
|
<h1><img src="https://www.google.com/s2/favicons?domain=<?php echo $j["source"]["url"] ?>" width="24" height="24">
|
|
|
|
<?php echo $j["name"] ?>: <?php echo $j["summary"] ?></h1>
|
2024-06-01 22:31:12 +02:00
|
|
|
|
|
|
|
<table class="pkgpage" width="100%">
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Name") ?>:</td><td><?php echo $j["name"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Release") ?>:</td><td>
|
2024-06-01 22:31:12 +02:00
|
|
|
<?php if ($j["source"]["epoch"] != "0") echo $j["source"]["epoch"].":";
|
|
|
|
echo $j["source"]["version"]."-".$j["source"]["release"] ?></td></tr>
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Architecture") ?>:</td><td><?php echo $j["arch"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Group") ?>:</td><td><?php echo $j["group"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Description") ?>:</td><td><?php echo $j["description"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Size") ?>:</td><td><?php echo $j["size"] ?></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Upstream URL") ?>:</td><td><a href="<?php echo $j["source"]["url"] ?>" target=_blank><?php echo $j["source"]["url"] ?></a></td></tr>
|
|
|
|
<tr><td width="15%"><?php echo _r("Source RPM") ?>:</td><td><?php
|
2024-06-02 12:19:32 +02:00
|
|
|
$sourcerpm_url = $url_prefix . $repo . "/" . $j["source"]["name"];
|
|
|
|
echo "<a href=\"". $sourcerpm_url . "\">". $j["source"]["name"] . "</a> "; ?>
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Brothers") ?>:</td><td><?php
|
2024-06-01 22:31:12 +02:00
|
|
|
foreach ($j["brothers"] as $brother) {
|
|
|
|
$brother_url = $url_prefix . $repo . "/" . $brother . "/" . $arch;
|
|
|
|
echo "<a href=\"". $brother_url . "\">". $brother . "</a> ";
|
|
|
|
} ?>
|
|
|
|
</td></tr>
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Provides") ?>:</td><td><?php
|
2024-06-01 22:31:12 +02:00
|
|
|
foreach ($j["provides"] as $provide) {
|
|
|
|
echo $provide["name"];
|
|
|
|
if ($provide["flags"] != "") echo "[" . $provide["flags"] . $provide["version"] . "]";
|
|
|
|
echo " ";
|
|
|
|
} ?>
|
|
|
|
</td></tr>
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Obsoletes") ?>:</td><td><?php
|
2024-06-29 12:52:20 +02:00
|
|
|
foreach ($j["obsoletes"] as $obsolete) {
|
|
|
|
echo $obsolete["name"];
|
|
|
|
if ($obsolete["flags"] != "") echo "[" . $obsolete["flags"] . $obsolete["version"] . "]";
|
|
|
|
echo " ";
|
|
|
|
} ?>
|
|
|
|
</td></tr>
|
2024-06-29 14:04:42 +02:00
|
|
|
<tr><td width="15%"><?php echo _r("Requires") ?>:</td><td><?php
|
2024-06-29 12:52:20 +02:00
|
|
|
foreach ($j["requires"] as $require) {
|
|
|
|
echo $require["name"];
|
|
|
|
if ($require["flags"] != "") echo "[" . $require["flags"] . $require["version"] . "]";
|
|
|
|
echo " ";
|
|
|
|
} ?>
|
|
|
|
</td></tr>
|
2024-06-01 22:31:12 +02:00
|
|
|
</table>
|
|
|
|
|
|
|
|
<?php
|
2024-06-02 12:19:32 +02:00
|
|
|
}
|
2024-06-01 22:31:12 +02:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
|
2024-06-02 12:19:32 +02:00
|
|
|
</span></div><!-- end of #content-full -->
|
2024-06-01 22:31:12 +02:00
|
|
|
|
|
|
|
<?php get_footer(); ?>
|