distroquery: added support for query search box

This commit is contained in:
Silvan Calarco 2024-07-06 18:28:59 +02:00
parent 7e451f7cbb
commit 931beb254a
5 changed files with 145 additions and 100 deletions

View File

@ -54,8 +54,13 @@ $url_prefix = home_url() . "/rpms/";
echo " > <a href=\"" . $url_prefix . "\">Repositories</a>";
$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);
$q = $_GET['q'];
$query_append = "";
if ($page != "") $query_append="&page=" . $page;
if ($q != "") $query_append .= "&q=" . urlencode($q);
if ($query_append[0] == '&') $query_append[0] = "?";
$request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/repository/' . $repo . $query_append);
$j = json_decode($request["body"], true);
if ($j["error"] != "") {
@ -65,8 +70,15 @@ $url_prefix = home_url() . "/rpms/";
echo " > " . $repo;
echo "<h1>" . _r("List of packages") . ":</h1>";
echo "<form id=\"distroquery\" method=\"get\" action=\"" . $url_prefix . "/" . $repo . "\">";
echo "<label class=\"screen-reader-text\" for=\"q\">" . _r("Search packages") . ":</label>";
echo "<input id=\"q\" class=\"field\" type=\"text\" name=\"q\" placeholder=\"" . _r("Search here") . "\"> - ";
if ($q != "") echo _r("Results for:") . " <strong>" . $q . "</strong> - ";
// Pagination
if ($j["query"]["pages"]) {
$query_append = "";
if ($q != "") $query_append .= "&q=" . urlencode($q);
$page = $j["query"]["page"];
$pages = $j["query"]["pages"];
$from_page = 1;
@ -77,15 +89,16 @@ $url_prefix = home_url() . "/rpms/";
$from_page = $to_page - 20;
if ($from_page < 1) $from_page = 1;
}
echo _r("Page") . " " . $page . " " . _r("of") . " " . $pages . " [ ";
echo "" . $j["query"]["total"] . " " . _r("result(s) found") . " - " .
_r("Showing 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 . "\">&lt;</a>&nbsp;";
echo "<a href=\"" . $url_prefix . "/" . $repo . "?page=" . $back_page . $query_append . "\">&lt;</a>&nbsp;";
}
for ($i = $from_page; $i <= $to_page; $i++) {
if ($i != $j["query"]["page"]) {
echo "<a href=\"" . $url_prefix . "/" . $repo . "?page=" . $i . "\">" . $i . "</a>&nbsp;";
echo "<a href=\"" . $url_prefix . "/" . $repo . "?page=" . $i . $query_append . "\">" . $i . "</a>&nbsp;";
} else {
echo "<strong>" . $i . "</strong>&nbsp";
}
@ -94,9 +107,11 @@ $url_prefix = home_url() . "/rpms/";
$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 . "\">&gt;</a>&nbsp;";
echo "<a href=\"" . $url_prefix . "/" . $repo . "?page=" . $next_page . $query_append . "\">&gt;</a>&nbsp;";
}
echo "]</br></br>";
} else {
echo "0 " . _r("result(s) found");
}
foreach ($j["packages"] as $package) {
@ -104,6 +119,8 @@ $url_prefix = home_url() . "/rpms/";
echo "<a href=\"" . $package_url . "\">". $package["name"] . "</a>: " . $package["summary"] . "</br>";
}
echo "</form>";
}
} else if ($arch == "") {

Binary file not shown.

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Responsive Theme\n"
"Report-Msgid-Bugs-To: bugs@openmamba.org\n"
"POT-Creation-Date: 2024-06-29 14:01+0200\n"
"POT-Creation-Date: 2024-07-06 18:03+0200\n"
"PO-Revision-Date: 2014-12-08 16:25+0100\n"
"Last-Translator: Silvan Calarco <silvan.calarco@mambasoft.it>\n"
"Language-Team: Italian, Italy\n"
@ -26,7 +26,7 @@ msgstr "Leggi di più &#8250;"
msgid "Pages:"
msgstr "Pagine:"
#: ../distroquery.php:40 ../distroquery.php:77 ../distroquery.php:135
#: ../distroquery.php:40 ../distroquery.php:128 ../distroquery.php:186
msgid "Repositories"
msgstr "Repository"
@ -34,126 +34,134 @@ msgstr "Repository"
msgid "Available repositories"
msgstr "Repository disponibili"
#: ../distroquery.php:64
#: ../distroquery.php:71
msgid "List of packages"
msgstr "Elenco dei pacchetti"
#: ../distroquery.php:83 ../distroquery.php:140
#: ../distroquery.php:74
msgid "Search packages"
msgstr "Cerca pacchetti"
#: ../distroquery.php:75
msgid "Search here"
msgstr "Cerca qui"
#: ../distroquery.php:76
msgid "Results for:"
msgstr "Risultati per:"
#: ../distroquery.php:92
msgid "result(s) found"
msgstr "risultati trovati"
#: ../distroquery.php:93
msgid "Showing page"
msgstr "Mostro la pagina"
#: ../distroquery.php:93
msgid "of"
msgstr "di"
#: ../distroquery.php:134 ../distroquery.php:191
msgid "ERROR"
msgstr "ERRORE"
#: ../distroquery.php:90 ../distroquery.php:147
#: ../distroquery.php:141 ../distroquery.php:198
msgid "Resources"
msgstr "Risorse"
#: ../distroquery.php:91 ../distroquery.php:148
#: ../distroquery.php:142 ../distroquery.php:199
msgid "Source files"
msgstr "File sorgenti"
#: ../distroquery.php:92 ../distroquery.php:149
#: ../distroquery.php:143 ../distroquery.php:200
msgid "Changes"
msgstr "Modifiche"
#: ../distroquery.php:93 ../distroquery.php:150
#: ../distroquery.php:144 ../distroquery.php:201
msgid "Issues"
msgstr "Problemi"
#: ../distroquery.php:94 ../distroquery.php:151
#: ../distroquery.php:145 ../distroquery.php:202
msgid "Add a new issue"
msgstr "Segnala un problema"
#: ../distroquery.php:95 ../distroquery.php:152
#: ../distroquery.php:146 ../distroquery.php:203
msgid "Download"
msgstr "Scarica"
#: ../distroquery.php:102 ../distroquery.php:159
#: ../distroquery.php:153 ../distroquery.php:210
msgid "Name"
msgstr "Nome"
#: ../distroquery.php:103 ../distroquery.php:160
#: ../distroquery.php:154 ../distroquery.php:211
msgid "Release"
msgstr "Versione"
#: ../distroquery.php:106 ../distroquery.php:164
#: ../distroquery.php:157 ../distroquery.php:215
msgid "Group"
msgstr "Gruppo"
#: ../distroquery.php:107
#: ../distroquery.php:158
msgid "Maintainer"
msgstr "Manutentore"
#: ../distroquery.php:108 ../distroquery.php:165
#: ../distroquery.php:159 ../distroquery.php:216
msgid "Description"
msgstr "Descrizione"
#: ../distroquery.php:109
#: ../distroquery.php:160
msgid "License"
msgstr "Licenza"
#: ../distroquery.php:110 ../distroquery.php:166
#: ../distroquery.php:161 ../distroquery.php:217
msgid "Size"
msgstr "Dimensione"
#: ../distroquery.php:111 ../distroquery.php:167
#: ../distroquery.php:162 ../distroquery.php:218
msgid "Upstream URL"
msgstr "URL di origine"
#: ../distroquery.php:112
#: ../distroquery.php:163
msgid "Build time"
msgstr "Data di compilazione"
#: ../distroquery.php:113
#: ../distroquery.php:164
msgid "Built RPMS"
msgstr "RPM creati"
#: ../distroquery.php:119
#: ../distroquery.php:170
msgid "Build requirements"
msgstr "Dipendenze di compilazione"
#: ../distroquery.php:163
#: ../distroquery.php:214
msgid "Architecture"
msgstr "Architettura"
#: ../distroquery.php:168
#: ../distroquery.php:219
msgid "Source RPM"
msgstr "RPM sorgente"
#: ../distroquery.php:171
#: ../distroquery.php:222
msgid "Brothers"
msgstr "Collegati"
#: ../distroquery.php:177
#: ../distroquery.php:228
msgid "Provides"
msgstr "Fornisce"
#: ../distroquery.php:184
#: ../distroquery.php:235
msgid "Obsoletes"
msgstr "Rende obsoleti"
#: ../distroquery.php:191
#: ../distroquery.php:242
msgid "Requires"
msgstr "Richiede"
#: ../footer.php:63
msgid "&copy;"
msgstr "&copy;"
#: ../footer.php:68
msgid "&uarr;"
msgstr "&uarr;"
#: ../footer.php:68
msgid "scroll to top"
msgstr "scorri all'inizio"
#: ../footer.php:70
msgid "Website provided by"
msgstr "Sito web fornito da"
#: ../footer.php:71
msgid "WordPress"
msgstr "WordPress"
#: ../functions.php:126 ../functions.php:137
msgid "for"
msgstr "per"
@ -243,10 +251,22 @@ msgstr "Salve, %1$s"
msgid "Logout"
msgstr "Esci"
#~ msgid "This website uses cookies to improve user experience."
#~ msgstr ""
#~ "Questo sito utilizza i cookie per migliorare l'esperienza di navigazione "
#~ "dell'utente."
msgid "&copy;"
msgstr "&copy;"
#~ msgid "Archive for %s"
#~ msgstr "Archivio per %s"
msgid "scroll to top"
msgstr "scorri all'inizio"
msgid "Website provided by"
msgstr "Sito web fornito da"
msgid "WordPress"
msgstr "WordPress"
msgid "This website uses cookies to improve user experience."
msgstr ""
"Questo sito utilizza i cookie per migliorare l'esperienza di navigazione "
"dell'utente."
msgid "Archive for %s"
msgstr "Archivio per %s"

View File

@ -8,13 +8,13 @@ msgid ""
msgstr ""
"Project-Id-Version: openmamba 1.0\n"
"Report-Msgid-Bugs-To: bugs@openmamba.org\n"
"POT-Creation-Date: 2024-06-29 14:01+0200\n"
"POT-Creation-Date: 2024-07-06 18:03+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../bbpress.php:41 ../search-page.php:42 ../webbuild-page.php:47
@ -27,7 +27,7 @@ msgstr ""
msgid "Pages:"
msgstr ""
#: ../distroquery.php:40 ../distroquery.php:77 ../distroquery.php:135
#: ../distroquery.php:40 ../distroquery.php:128 ../distroquery.php:186
msgid "Repositories"
msgstr ""
@ -35,126 +35,134 @@ msgstr ""
msgid "Available repositories"
msgstr ""
#: ../distroquery.php:64
#: ../distroquery.php:71
msgid "List of packages"
msgstr ""
#: ../distroquery.php:83 ../distroquery.php:140
#: ../distroquery.php:74
msgid "Search packages"
msgstr ""
#: ../distroquery.php:75
msgid "Search here"
msgstr ""
#: ../distroquery.php:76
msgid "Results for:"
msgstr ""
#: ../distroquery.php:92
msgid "result(s) found"
msgstr ""
#: ../distroquery.php:93
msgid "Showing page"
msgstr ""
#: ../distroquery.php:93
msgid "of"
msgstr ""
#: ../distroquery.php:134 ../distroquery.php:191
msgid "ERROR"
msgstr ""
#: ../distroquery.php:90 ../distroquery.php:147
#: ../distroquery.php:141 ../distroquery.php:198
msgid "Resources"
msgstr ""
#: ../distroquery.php:91 ../distroquery.php:148
#: ../distroquery.php:142 ../distroquery.php:199
msgid "Source files"
msgstr ""
#: ../distroquery.php:92 ../distroquery.php:149
#: ../distroquery.php:143 ../distroquery.php:200
msgid "Changes"
msgstr ""
#: ../distroquery.php:93 ../distroquery.php:150
#: ../distroquery.php:144 ../distroquery.php:201
msgid "Issues"
msgstr ""
#: ../distroquery.php:94 ../distroquery.php:151
#: ../distroquery.php:145 ../distroquery.php:202
msgid "Add a new issue"
msgstr ""
#: ../distroquery.php:95 ../distroquery.php:152
#: ../distroquery.php:146 ../distroquery.php:203
msgid "Download"
msgstr ""
#: ../distroquery.php:102 ../distroquery.php:159
#: ../distroquery.php:153 ../distroquery.php:210
msgid "Name"
msgstr ""
#: ../distroquery.php:103 ../distroquery.php:160
#: ../distroquery.php:154 ../distroquery.php:211
msgid "Release"
msgstr ""
#: ../distroquery.php:106 ../distroquery.php:164
#: ../distroquery.php:157 ../distroquery.php:215
msgid "Group"
msgstr ""
#: ../distroquery.php:107
#: ../distroquery.php:158
msgid "Maintainer"
msgstr ""
#: ../distroquery.php:108 ../distroquery.php:165
#: ../distroquery.php:159 ../distroquery.php:216
msgid "Description"
msgstr ""
#: ../distroquery.php:109
#: ../distroquery.php:160
msgid "License"
msgstr ""
#: ../distroquery.php:110 ../distroquery.php:166
#: ../distroquery.php:161 ../distroquery.php:217
msgid "Size"
msgstr ""
#: ../distroquery.php:111 ../distroquery.php:167
#: ../distroquery.php:162 ../distroquery.php:218
msgid "Upstream URL"
msgstr ""
#: ../distroquery.php:112
#: ../distroquery.php:163
msgid "Build time"
msgstr ""
#: ../distroquery.php:113
#: ../distroquery.php:164
msgid "Built RPMS"
msgstr ""
#: ../distroquery.php:119
#: ../distroquery.php:170
msgid "Build requirements"
msgstr ""
#: ../distroquery.php:163
#: ../distroquery.php:214
msgid "Architecture"
msgstr ""
#: ../distroquery.php:168
#: ../distroquery.php:219
msgid "Source RPM"
msgstr ""
#: ../distroquery.php:171
#: ../distroquery.php:222
msgid "Brothers"
msgstr ""
#: ../distroquery.php:177
#: ../distroquery.php:228
msgid "Provides"
msgstr ""
#: ../distroquery.php:184
#: ../distroquery.php:235
msgid "Obsoletes"
msgstr ""
#: ../distroquery.php:191
#: ../distroquery.php:242
msgid "Requires"
msgstr ""
#: ../footer.php:63
msgid "&copy;"
msgstr ""
#: ../footer.php:68
msgid "&uarr;"
msgstr ""
#: ../footer.php:68
msgid "scroll to top"
msgstr ""
#: ../footer.php:70
msgid "Website provided by"
msgstr ""
#: ../footer.php:71
msgid "WordPress"
msgstr ""
#: ../functions.php:126 ../functions.php:137
msgid "for"
msgstr ""

View File

@ -1,5 +1,5 @@
#!/bin/sh
xgettext --default-domain=responsive --language=PHP --keyword=__ --keyword=_e --sort-by-file --copyright-holder="Silvan Calarco" --package-name=openmamba --package-version=1.0 --msgid-bugs-address="bugs@openmamba.org" ../*.php
xgettext --default-domain=responsive --language=PHP --keyword=__ --keyword=_e --keyword=_r --sort-by-file --copyright-holder="Silvan Calarco" --package-name=openmamba --package-version=1.0 --msgid-bugs-address="bugs@openmamba.org" ../*.php
msgmerge it_IT.po responsive.po -o it_IT.po
sed -i "s|#~ ||" it_IT.po
msgcat it_IT.po | msgfmt -o it_IT.mo -