distroquery: make files search optional and refine check for other available results and paging

This commit is contained in:
Silvan Calarco 2013-10-15 11:40:22 +02:00
parent 4dfb651da5
commit 07d3dbdf7d
4 changed files with 146 additions and 107 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: distromatic 1.4.1\n"
"Report-Msgid-Bugs-To: silvan.calarco@mambasoft.it\n"
"POT-Creation-Date: 2013-10-15 00:07+0200\n"
"POT-Creation-Date: 2013-10-15 11:33+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"
@ -17,120 +17,128 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
#: src/distroquery.c:181
#: src/distroquery.c:182
msgid "Source"
msgstr ""
#: src/distroquery.c:225
#: src/distroquery.c:227
msgid "Search"
msgstr ""
#: src/distroquery.c:259
#: src/distroquery.c:261
msgid "sources"
msgstr ""
#: src/distroquery.c:270
#: src/distroquery.c:265
msgid "files"
msgstr ""
#: src/distroquery.c:276
msgid "Search software packages"
msgstr ""
#: src/distroquery.c:374 src/distroquery.c:639 src/distroquery.c:807
#: src/distroquery.c:380 src/distroquery.c:658 src/distroquery.c:826
msgid "Download"
msgstr ""
#: src/distroquery.c:383
#: src/distroquery.c:389
msgid "Details"
msgstr ""
#: src/distroquery.c:401 src/distroquery.c:436
#: src/distroquery.c:407 src/distroquery.c:443
#, c-format
msgid "Other results in "
msgstr ""
#: src/distroquery.c:402 src/distroquery.c:437
#: src/distroquery.c:408 src/distroquery.c:444
#, c-format
msgid "Results in"
msgstr ""
#: src/distroquery.c:405 src/distroquery.c:440
#: src/distroquery.c:411 src/distroquery.c:447
msgid "for arch "
msgstr ""
#: src/distroquery.c:414
#: src/distroquery.c:420
msgid "provides"
msgstr ""
#: src/distroquery.c:449
#: src/distroquery.c:456
msgid "provides file "
msgstr ""
#: src/distroquery.c:516
#: src/distroquery.c:529
msgid "result(s) shown"
msgstr ""
#: src/distroquery.c:534
#: src/distroquery.c:531
msgid "result(s) found"
msgstr ""
#: src/distroquery.c:553
msgid "Search results for"
msgstr ""
#: src/distroquery.c:604 src/distroquery.c:769
#: src/distroquery.c:623 src/distroquery.c:788
msgid "Version"
msgstr ""
#: src/distroquery.c:609
#: src/distroquery.c:628
msgid "Size"
msgstr ""
#: src/distroquery.c:612
#: src/distroquery.c:631
msgid "Related packages"
msgstr ""
#: src/distroquery.c:641 src/distroquery.c:809
#: src/distroquery.c:660 src/distroquery.c:828
msgid "Developers details"
msgstr ""
#: src/distroquery.c:643
#: src/distroquery.c:662
msgid "Source package"
msgstr ""
#: src/distroquery.c:649 src/distroquery.c:810
#: src/distroquery.c:668 src/distroquery.c:829
msgid "Maintainer"
msgstr ""
#: src/distroquery.c:650 src/distroquery.c:811
#: src/distroquery.c:669 src/distroquery.c:830
msgid "Build date"
msgstr ""
#: src/distroquery.c:653
#: src/distroquery.c:672
msgid "Obsoletes"
msgstr ""
#: src/distroquery.c:667
#: src/distroquery.c:686
msgid "Provides"
msgstr ""
#: src/distroquery.c:682
#: src/distroquery.c:701
msgid "Requires"
msgstr ""
#: src/distroquery.c:701
#: src/distroquery.c:720
msgid "Files list"
msgstr ""
#: src/distroquery.c:776
#: src/distroquery.c:795
msgid "Built packages"
msgstr ""
#: src/distroquery.c:814
#: src/distroquery.c:833
msgid "Source files"
msgstr ""
#: src/distroquery.c:824
#: src/distroquery.c:843
msgid "Patches"
msgstr ""
#: src/distroquery.c:835
#: src/distroquery.c:854
msgid "Build requirements"
msgstr ""
#: src/distroquery.c:849
#: src/distroquery.c:868
msgid "Changelog"
msgstr ""

BIN
po/it.gmo

Binary file not shown.

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: distromatic 1.4.1\n"
"Report-Msgid-Bugs-To: silvan.calarco@mambasoft.it\n"
"POT-Creation-Date: 2013-10-15 00:07+0200\n"
"POT-Creation-Date: 2013-10-15 11:33+0200\n"
"PO-Revision-Date: 2013-10-14 01:19+0200\n"
"Last-Translator: Silvan Calarco <silvan.calarco@mambasoft.it>\n"
"Language-Team: Italian\n"
@ -17,120 +17,128 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/distroquery.c:181
#: src/distroquery.c:182
msgid "Source"
msgstr "Sorgente"
#: src/distroquery.c:225
#: src/distroquery.c:227
msgid "Search"
msgstr "Cerca"
#: src/distroquery.c:259
#: src/distroquery.c:261
msgid "sources"
msgstr "sorgenti"
#: src/distroquery.c:270
#: src/distroquery.c:265
msgid "files"
msgstr "file"
#: src/distroquery.c:276
msgid "Search software packages"
msgstr "Cerca pacchetti software"
#: src/distroquery.c:374 src/distroquery.c:639 src/distroquery.c:807
#: src/distroquery.c:380 src/distroquery.c:658 src/distroquery.c:826
msgid "Download"
msgstr "Scarica"
#: src/distroquery.c:383
#: src/distroquery.c:389
msgid "Details"
msgstr "Dettagli"
#: src/distroquery.c:401 src/distroquery.c:436
#: src/distroquery.c:407 src/distroquery.c:443
#, c-format
msgid "Other results in "
msgstr "Altri risultati in "
#: src/distroquery.c:402 src/distroquery.c:437
#: src/distroquery.c:408 src/distroquery.c:444
#, c-format
msgid "Results in"
msgstr "Risultati in"
#: src/distroquery.c:405 src/distroquery.c:440
#: src/distroquery.c:411 src/distroquery.c:447
msgid "for arch "
msgstr "per l'architettura "
#: src/distroquery.c:414
#: src/distroquery.c:420
msgid "provides"
msgstr "fornisce"
#: src/distroquery.c:449
#: src/distroquery.c:456
msgid "provides file "
msgstr "fornisce il file "
#: src/distroquery.c:516
#: src/distroquery.c:529
msgid "result(s) shown"
msgstr "risultati mostrati"
#: src/distroquery.c:534
#: src/distroquery.c:531
msgid "result(s) found"
msgstr "risultati trovati"
#: src/distroquery.c:553
msgid "Search results for"
msgstr "Risultati della ricerca per"
#: src/distroquery.c:604 src/distroquery.c:769
#: src/distroquery.c:623 src/distroquery.c:788
msgid "Version"
msgstr "Versione"
#: src/distroquery.c:609
#: src/distroquery.c:628
msgid "Size"
msgstr "Dimensione"
#: src/distroquery.c:612
#: src/distroquery.c:631
msgid "Related packages"
msgstr "Pacchetti collegati"
#: src/distroquery.c:641 src/distroquery.c:809
#: src/distroquery.c:660 src/distroquery.c:828
msgid "Developers details"
msgstr "Dettagli per gli sviluppatori"
#: src/distroquery.c:643
#: src/distroquery.c:662
msgid "Source package"
msgstr "Pacchetto sorgente"
#: src/distroquery.c:649 src/distroquery.c:810
#: src/distroquery.c:668 src/distroquery.c:829
msgid "Maintainer"
msgstr "Manutentore"
#: src/distroquery.c:650 src/distroquery.c:811
#: src/distroquery.c:669 src/distroquery.c:830
msgid "Build date"
msgstr "Data di compilazione"
#: src/distroquery.c:653
#: src/distroquery.c:672
msgid "Obsoletes"
msgstr "Rende obsoleti"
#: src/distroquery.c:667
#: src/distroquery.c:686
msgid "Provides"
msgstr "Fornisce"
#: src/distroquery.c:682
#: src/distroquery.c:701
msgid "Requires"
msgstr "Richiede"
#: src/distroquery.c:701
#: src/distroquery.c:720
msgid "Files list"
msgstr "Lista dei file"
#: src/distroquery.c:776
#: src/distroquery.c:795
msgid "Built packages"
msgstr "Pacchetti compilati"
#: src/distroquery.c:814
#: src/distroquery.c:833
msgid "Source files"
msgstr "File sorgenti"
#: src/distroquery.c:824
#: src/distroquery.c:843
msgid "Patches"
msgstr "Patch"
#: src/distroquery.c:835
#: src/distroquery.c:854
msgid "Build requirements"
msgstr "Requisiti per la compilazione"
#: src/distroquery.c:849
#: src/distroquery.c:868
msgid "Changelog"
msgstr "Modifiche"

View File

@ -76,7 +76,7 @@
#include "functions.h"
// must be as big as ARCHS_MAX (5)
const char* ARCHS[ARCHS_MAX] = { "i586" , "x86_64" , "arm" , "", ""};
const char* ARCHS[ARCHS_MAX] = { "i586", "x86_64", "arm", "", "" };
static struct configTag *firstconfigtag = NULL, *configtag = NULL;
char *query = "";
@ -93,6 +93,7 @@ struct configTag *query_repositories[100];
int search_milestone1 = 0, search_milestone2 = 1, search_devel = 1;
int search_sources = 0, searchbox = 0;
int search_files = 0;
/* Converts a hex character to its integer value */
char from_hex(char ch) {
@ -217,7 +218,8 @@ void printInputForm() {
"'&search_i586='+getElementById('search_i586').checked+"
"'&search_x86_64='+getElementById('search_x86_64').checked+"
"'&search_arm='+getElementById('search_arm').checked+"
"'&search_sources='+getElementById('search_sources').checked"
"'&search_sources='+getElementById('search_sources').checked+"
"'&search_files='+getElementById('search_files').checked"
")";
printf("<queryform><![CDATA[");
@ -258,6 +260,10 @@ void printInputForm() {
if (search_sources) printf("checked=checked ");
printf("onclick=%s>%s&nbsp;", ajax_call, _("sources"));
printf("<input type=checkbox id=\"search_files\" ");
if (search_files) printf("checked=checked ");
printf("onclick=%s>%s&nbsp;", ajax_call, _("files"));
printf("<br>");
/* ct = firstconfigtag;
while (ct) {
@ -273,7 +279,7 @@ void printInputForm() {
void printQueryData() {
int a, i, j, k, numresults = 0, localresults, localprovidesresults;
int a, i, j, k, numresults = 0, otherresults = 0, localresults, localprovidesresults, localsourceresults;
char dbname[PATH_MAX];
sqlite3 *dbf;
sqlite3_stmt *statement, *stmt1;
@ -417,6 +423,7 @@ void printQueryData() {
}
/* files search */
if (search_files) {
snprintf(dbname, PATH_MAX, "%s%s-%s-files.db",
query_repositories[i]->repository_dir,
query_repositories[i]->tag,
@ -453,13 +460,15 @@ void printQueryData() {
}
sqlite3_close(dbf);
}
}
if (localprovidesresults > 0) printf("</div>");
sqlite3_finalize(statement);
}
}
}
}
if ((localresults >= query_limit) || (localprovidesresults >= query_limit)) otherresults = 1;
} /* if query_repository */
} /* archs loop */
} /* repositories loop */
if (search_sources) {
snprintf(sql, PATH_MAX,
@ -477,8 +486,10 @@ void printQueryData() {
}
if (query_repositories[i]->db[ARCHS_MAX] &&
(sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
localsourceresults = 0;
while (sqlite3_step(statement) == SQLITE_ROW) {
numresults++;
localsourceresults++;
get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
@ -508,26 +519,34 @@ void printQueryData() {
} else {
fprintf(stderr, "ERROR: SQLite: %s (%s)\n", sqlite3_errmsg(query_repositories[i]->db[ARCHS_MAX]), sql);
}
}
}
if (localsourceresults >= query_limit) otherresults = 1;
} /* repositories loop */
} /* search_sources */
printf("<hr>");
printf("]]></queryreply>");
printf("<querystatus><![CDATA[%d %s.&nbsp;", numresults, _("result(s) shown"));
if (otherresults)
printf("<querystatus><![CDATA[%d %s.", numresults, _("result(s) shown"));
else
printf("<querystatus><![CDATA[%d %s.", numresults, _("result(s) found"));
k = query_offset / query_limit + 1; /* k = current shown page */
if (k < 7) j=1; else j=k-5; /* j = start pages list from */
if (numresults < query_limit) {
if (!otherresults) {
/* current page is last available */
a=k;
j=a-10;
if (j <= 0) j=1;
} else a=j+9; /* a = number of page links displayed */
if (a > 1) {
printf("&nbsp;[&nbsp;");
for (i = j; i <= a; i++) {
if (i != k) printf("<a href='javascript:distroquery_request(\"%s&limit=%d&offset=%d\")'>",
query_next, query_limit, query_limit * (i-1));
printf("%d", i);
printf("</a>&nbsp");
}
printf("]");
}
printf("]]></querystatus>");
printf("<title><![CDATA[%s '%s' :: %s]]></title>",
@ -920,13 +939,17 @@ void parse_request_variables(char *data) {
query_archs[2] = strstr(valuetok, "false") != valuetok;
} else if (!strcmp(vartok, "search_sources")) {
search_sources = strstr(valuetok, "false") != valuetok;
} else if (!strcmp(vartok, "search_files")) {
search_files = strstr(valuetok, "false") != valuetok;
}
if (vartok && valuetok) {
strcat(query_next, vartok);
strcat(query_next, "=");
strcat(query_next, valuetok);
strcat(query_next, "&");
}
}
}
if (query_next[strlen(query_next)] == '&') query_next[strlen(query_next)] = '\0';
ct = firstconfigtag;