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>"; echo " > <a href=\"" . $url_prefix . "\">Repositories</a>";
$page = $_GET['page']; $page = $_GET['page'];
if ($page != "") $query_string="?page=" . $page; $q = $_GET['q'];
$request = wp_remote_get('https://push.openmamba.org/openmamba/distroquery/api/v1/repository/' . $repo . $query_string); $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); $j = json_decode($request["body"], true);
if ($j["error"] != "") { if ($j["error"] != "") {
@ -65,8 +70,15 @@ $url_prefix = home_url() . "/rpms/";
echo " > " . $repo; echo " > " . $repo;
echo "<h1>" . _r("List of packages") . ":</h1>"; 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 // Pagination
if ($j["query"]["pages"]) { if ($j["query"]["pages"]) {
$query_append = "";
if ($q != "") $query_append .= "&q=" . urlencode($q);
$page = $j["query"]["page"]; $page = $j["query"]["page"];
$pages = $j["query"]["pages"]; $pages = $j["query"]["pages"];
$from_page = 1; $from_page = 1;
@ -77,15 +89,16 @@ $url_prefix = home_url() . "/rpms/";
$from_page = $to_page - 20; $from_page = $to_page - 20;
if ($from_page < 1) $from_page = 1; 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) { if ($from_page > 1) {
$back_page = $from_page - 10; $back_page = $from_page - 10;
if ($back_page < 1) $back_page = 1; 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++) { for ($i = $from_page; $i <= $to_page; $i++) {
if ($i != $j["query"]["page"]) { 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 { } else {
echo "<strong>" . $i . "</strong>&nbsp"; echo "<strong>" . $i . "</strong>&nbsp";
} }
@ -94,9 +107,11 @@ $url_prefix = home_url() . "/rpms/";
$next_page = $to_page + 10; $next_page = $to_page + 10;
if ($next_page > $pages) $next_page = $pages; if ($next_page > $pages) $next_page = $pages;
if ($next_page < 1) $next_page = 1; 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>"; echo "]</br></br>";
} else {
echo "0 " . _r("result(s) found");
} }
foreach ($j["packages"] as $package) { 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 "<a href=\"" . $package_url . "\">". $package["name"] . "</a>: " . $package["summary"] . "</br>";
} }
echo "</form>";
} }
} else if ($arch == "") { } else if ($arch == "") {

Binary file not shown.

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Responsive Theme\n" "Project-Id-Version: Responsive Theme\n"
"Report-Msgid-Bugs-To: bugs@openmamba.org\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" "PO-Revision-Date: 2014-12-08 16:25+0100\n"
"Last-Translator: Silvan Calarco <silvan.calarco@mambasoft.it>\n" "Last-Translator: Silvan Calarco <silvan.calarco@mambasoft.it>\n"
"Language-Team: Italian, Italy\n" "Language-Team: Italian, Italy\n"
@ -26,7 +26,7 @@ msgstr "Leggi di più &#8250;"
msgid "Pages:" msgid "Pages:"
msgstr "Pagine:" msgstr "Pagine:"
#: ../distroquery.php:40 ../distroquery.php:77 ../distroquery.php:135 #: ../distroquery.php:40 ../distroquery.php:128 ../distroquery.php:186
msgid "Repositories" msgid "Repositories"
msgstr "Repository" msgstr "Repository"
@ -34,126 +34,134 @@ msgstr "Repository"
msgid "Available repositories" msgid "Available repositories"
msgstr "Repository disponibili" msgstr "Repository disponibili"
#: ../distroquery.php:64 #: ../distroquery.php:71
msgid "List of packages" msgid "List of packages"
msgstr "Elenco dei pacchetti" 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" msgid "ERROR"
msgstr "ERRORE" msgstr "ERRORE"
#: ../distroquery.php:90 ../distroquery.php:147 #: ../distroquery.php:141 ../distroquery.php:198
msgid "Resources" msgid "Resources"
msgstr "Risorse" msgstr "Risorse"
#: ../distroquery.php:91 ../distroquery.php:148 #: ../distroquery.php:142 ../distroquery.php:199
msgid "Source files" msgid "Source files"
msgstr "File sorgenti" msgstr "File sorgenti"
#: ../distroquery.php:92 ../distroquery.php:149 #: ../distroquery.php:143 ../distroquery.php:200
msgid "Changes" msgid "Changes"
msgstr "Modifiche" msgstr "Modifiche"
#: ../distroquery.php:93 ../distroquery.php:150 #: ../distroquery.php:144 ../distroquery.php:201
msgid "Issues" msgid "Issues"
msgstr "Problemi" msgstr "Problemi"
#: ../distroquery.php:94 ../distroquery.php:151 #: ../distroquery.php:145 ../distroquery.php:202
msgid "Add a new issue" msgid "Add a new issue"
msgstr "Segnala un problema" msgstr "Segnala un problema"
#: ../distroquery.php:95 ../distroquery.php:152 #: ../distroquery.php:146 ../distroquery.php:203
msgid "Download" msgid "Download"
msgstr "Scarica" msgstr "Scarica"
#: ../distroquery.php:102 ../distroquery.php:159 #: ../distroquery.php:153 ../distroquery.php:210
msgid "Name" msgid "Name"
msgstr "Nome" msgstr "Nome"
#: ../distroquery.php:103 ../distroquery.php:160 #: ../distroquery.php:154 ../distroquery.php:211
msgid "Release" msgid "Release"
msgstr "Versione" msgstr "Versione"
#: ../distroquery.php:106 ../distroquery.php:164 #: ../distroquery.php:157 ../distroquery.php:215
msgid "Group" msgid "Group"
msgstr "Gruppo" msgstr "Gruppo"
#: ../distroquery.php:107 #: ../distroquery.php:158
msgid "Maintainer" msgid "Maintainer"
msgstr "Manutentore" msgstr "Manutentore"
#: ../distroquery.php:108 ../distroquery.php:165 #: ../distroquery.php:159 ../distroquery.php:216
msgid "Description" msgid "Description"
msgstr "Descrizione" msgstr "Descrizione"
#: ../distroquery.php:109 #: ../distroquery.php:160
msgid "License" msgid "License"
msgstr "Licenza" msgstr "Licenza"
#: ../distroquery.php:110 ../distroquery.php:166 #: ../distroquery.php:161 ../distroquery.php:217
msgid "Size" msgid "Size"
msgstr "Dimensione" msgstr "Dimensione"
#: ../distroquery.php:111 ../distroquery.php:167 #: ../distroquery.php:162 ../distroquery.php:218
msgid "Upstream URL" msgid "Upstream URL"
msgstr "URL di origine" msgstr "URL di origine"
#: ../distroquery.php:112 #: ../distroquery.php:163
msgid "Build time" msgid "Build time"
msgstr "Data di compilazione" msgstr "Data di compilazione"
#: ../distroquery.php:113 #: ../distroquery.php:164
msgid "Built RPMS" msgid "Built RPMS"
msgstr "RPM creati" msgstr "RPM creati"
#: ../distroquery.php:119 #: ../distroquery.php:170
msgid "Build requirements" msgid "Build requirements"
msgstr "Dipendenze di compilazione" msgstr "Dipendenze di compilazione"
#: ../distroquery.php:163 #: ../distroquery.php:214
msgid "Architecture" msgid "Architecture"
msgstr "Architettura" msgstr "Architettura"
#: ../distroquery.php:168 #: ../distroquery.php:219
msgid "Source RPM" msgid "Source RPM"
msgstr "RPM sorgente" msgstr "RPM sorgente"
#: ../distroquery.php:171 #: ../distroquery.php:222
msgid "Brothers" msgid "Brothers"
msgstr "Collegati" msgstr "Collegati"
#: ../distroquery.php:177 #: ../distroquery.php:228
msgid "Provides" msgid "Provides"
msgstr "Fornisce" msgstr "Fornisce"
#: ../distroquery.php:184 #: ../distroquery.php:235
msgid "Obsoletes" msgid "Obsoletes"
msgstr "Rende obsoleti" msgstr "Rende obsoleti"
#: ../distroquery.php:191 #: ../distroquery.php:242
msgid "Requires" msgid "Requires"
msgstr "Richiede" msgstr "Richiede"
#: ../footer.php:63
msgid "&copy;"
msgstr "&copy;"
#: ../footer.php:68 #: ../footer.php:68
msgid "&uarr;" msgid "&uarr;"
msgstr "&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 #: ../functions.php:126 ../functions.php:137
msgid "for" msgid "for"
msgstr "per" msgstr "per"
@ -243,10 +251,22 @@ msgstr "Salve, %1$s"
msgid "Logout" msgid "Logout"
msgstr "Esci" msgstr "Esci"
#~ msgid "This website uses cookies to improve user experience." msgid "&copy;"
#~ msgstr "" msgstr "&copy;"
#~ "Questo sito utilizza i cookie per migliorare l'esperienza di navigazione "
#~ "dell'utente."
#~ msgid "Archive for %s" msgid "scroll to top"
#~ msgstr "Archivio per %s" 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 "" msgstr ""
"Project-Id-Version: openmamba 1.0\n" "Project-Id-Version: openmamba 1.0\n"
"Report-Msgid-Bugs-To: bugs@openmamba.org\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n" "Language: \n"
"MIME-Version: 1.0\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" "Content-Transfer-Encoding: 8bit\n"
#: ../bbpress.php:41 ../search-page.php:42 ../webbuild-page.php:47 #: ../bbpress.php:41 ../search-page.php:42 ../webbuild-page.php:47
@ -27,7 +27,7 @@ msgstr ""
msgid "Pages:" msgid "Pages:"
msgstr "" msgstr ""
#: ../distroquery.php:40 ../distroquery.php:77 ../distroquery.php:135 #: ../distroquery.php:40 ../distroquery.php:128 ../distroquery.php:186
msgid "Repositories" msgid "Repositories"
msgstr "" msgstr ""
@ -35,126 +35,134 @@ msgstr ""
msgid "Available repositories" msgid "Available repositories"
msgstr "" msgstr ""
#: ../distroquery.php:64 #: ../distroquery.php:71
msgid "List of packages" msgid "List of packages"
msgstr "" 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" msgid "ERROR"
msgstr "" msgstr ""
#: ../distroquery.php:90 ../distroquery.php:147 #: ../distroquery.php:141 ../distroquery.php:198
msgid "Resources" msgid "Resources"
msgstr "" msgstr ""
#: ../distroquery.php:91 ../distroquery.php:148 #: ../distroquery.php:142 ../distroquery.php:199
msgid "Source files" msgid "Source files"
msgstr "" msgstr ""
#: ../distroquery.php:92 ../distroquery.php:149 #: ../distroquery.php:143 ../distroquery.php:200
msgid "Changes" msgid "Changes"
msgstr "" msgstr ""
#: ../distroquery.php:93 ../distroquery.php:150 #: ../distroquery.php:144 ../distroquery.php:201
msgid "Issues" msgid "Issues"
msgstr "" msgstr ""
#: ../distroquery.php:94 ../distroquery.php:151 #: ../distroquery.php:145 ../distroquery.php:202
msgid "Add a new issue" msgid "Add a new issue"
msgstr "" msgstr ""
#: ../distroquery.php:95 ../distroquery.php:152 #: ../distroquery.php:146 ../distroquery.php:203
msgid "Download" msgid "Download"
msgstr "" msgstr ""
#: ../distroquery.php:102 ../distroquery.php:159 #: ../distroquery.php:153 ../distroquery.php:210
msgid "Name" msgid "Name"
msgstr "" msgstr ""
#: ../distroquery.php:103 ../distroquery.php:160 #: ../distroquery.php:154 ../distroquery.php:211
msgid "Release" msgid "Release"
msgstr "" msgstr ""
#: ../distroquery.php:106 ../distroquery.php:164 #: ../distroquery.php:157 ../distroquery.php:215
msgid "Group" msgid "Group"
msgstr "" msgstr ""
#: ../distroquery.php:107 #: ../distroquery.php:158
msgid "Maintainer" msgid "Maintainer"
msgstr "" msgstr ""
#: ../distroquery.php:108 ../distroquery.php:165 #: ../distroquery.php:159 ../distroquery.php:216
msgid "Description" msgid "Description"
msgstr "" msgstr ""
#: ../distroquery.php:109 #: ../distroquery.php:160
msgid "License" msgid "License"
msgstr "" msgstr ""
#: ../distroquery.php:110 ../distroquery.php:166 #: ../distroquery.php:161 ../distroquery.php:217
msgid "Size" msgid "Size"
msgstr "" msgstr ""
#: ../distroquery.php:111 ../distroquery.php:167 #: ../distroquery.php:162 ../distroquery.php:218
msgid "Upstream URL" msgid "Upstream URL"
msgstr "" msgstr ""
#: ../distroquery.php:112 #: ../distroquery.php:163
msgid "Build time" msgid "Build time"
msgstr "" msgstr ""
#: ../distroquery.php:113 #: ../distroquery.php:164
msgid "Built RPMS" msgid "Built RPMS"
msgstr "" msgstr ""
#: ../distroquery.php:119 #: ../distroquery.php:170
msgid "Build requirements" msgid "Build requirements"
msgstr "" msgstr ""
#: ../distroquery.php:163 #: ../distroquery.php:214
msgid "Architecture" msgid "Architecture"
msgstr "" msgstr ""
#: ../distroquery.php:168 #: ../distroquery.php:219
msgid "Source RPM" msgid "Source RPM"
msgstr "" msgstr ""
#: ../distroquery.php:171 #: ../distroquery.php:222
msgid "Brothers" msgid "Brothers"
msgstr "" msgstr ""
#: ../distroquery.php:177 #: ../distroquery.php:228
msgid "Provides" msgid "Provides"
msgstr "" msgstr ""
#: ../distroquery.php:184 #: ../distroquery.php:235
msgid "Obsoletes" msgid "Obsoletes"
msgstr "" msgstr ""
#: ../distroquery.php:191 #: ../distroquery.php:242
msgid "Requires" msgid "Requires"
msgstr "" msgstr ""
#: ../footer.php:63
msgid "&copy;"
msgstr ""
#: ../footer.php:68 #: ../footer.php:68
msgid "&uarr;" msgid "&uarr;"
msgstr "" 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 #: ../functions.php:126 ../functions.php:137
msgid "for" msgid "for"
msgstr "" msgstr ""

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/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 msgmerge it_IT.po responsive.po -o it_IT.po
sed -i "s|#~ ||" it_IT.po sed -i "s|#~ ||" it_IT.po
msgcat it_IT.po | msgfmt -o it_IT.mo - msgcat it_IT.po | msgfmt -o it_IT.mo -