From 07d3dbdf7da266e1a40bf71968ff7c824b895350 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Tue, 15 Oct 2013 11:40:22 +0200 Subject: [PATCH] distroquery: make files search optional and refine check for other available results and paging --- po/distromatic.pot | 68 ++++++++++++++------------ po/it.gmo | Bin 1869 -> 1954 bytes po/it.po | 68 ++++++++++++++------------ src/distroquery.c | 117 +++++++++++++++++++++++++++------------------ 4 files changed, 146 insertions(+), 107 deletions(-) diff --git a/po/distromatic.pot b/po/distromatic.pot index b065960..a8b65f1 100644 --- a/po/distromatic.pot +++ b/po/distromatic.pot @@ -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 \n" "Language-Team: LANGUAGE \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 "" diff --git a/po/it.gmo b/po/it.gmo index 4671b616e96fb694d392b682d0582147fec359ed..843f6b6ef3b3821e1f6d2a67fdf4e42002631344 100644 GIT binary patch delta 773 zcmXZaJ1hi29LMo-yJyeqyq&j`Tp}UDMR5rQ1&OFs5)C09xww#UL_~7YTqTI3P-ql- z(P=c|5s@eqDxIKG(enN6%_Os*o!y<8|NlSx6h14@yj8i!h8Cqas}~s4B?DY&_gIV% zScNYb#t$sQU-Zy8`S&3VF>FH3i&=Y6-}hrB4kPn2W`Y|{n8FHNwBt?G0y|iUyQlzi zSdZuE;_~>cnLLs3xn)$_PEgkNA|_39bcd_xOSxBZ1y#X)1y0S5o JPUd>OmVZ}tJgWcz delta 726 zcmYk)PbhmA^ zMs86XJYpl3QJML${T0-KexlO67%JucsCh}-KaDy2nZ1n|GhKR6l!5;xW*a1lwEY!r zuA+a3y}aO*0Y15Dr>eA3iO0*Ng6O2`GRhE_9Q0DETk7U2icrz(XVm}T6iWWMFaHyW m=abHMFp-!@j1_L29e;i%H14i#WU}dn?25^3q?ec0dHDqgl{}XK diff --git a/po/it.po b/po/it.po index b1b8358..feeff3b 100644 --- a/po/it.po +++ b/po/it.po @@ -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 \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" diff --git a/src/distroquery.c b/src/distroquery.c index 0df7276..67c4c3c 100644 --- a/src/distroquery.c +++ b/src/distroquery.c @@ -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("%s ", ajax_call, _("sources")); + printf("%s ", ajax_call, _("files")); + printf("
"); /* 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,49 +423,52 @@ void printQueryData() { } /* files search */ - snprintf(dbname, PATH_MAX, "%s%s-%s-files.db", - query_repositories[i]->repository_dir, - query_repositories[i]->tag, - query_repositories[i]->arch[a]); - if (!sqlite3_open_v2(dbname, &dbf, SQLITE_OPEN_READONLY, NULL)) { - snprintf(sql, PATH_MAX, "SELECT * FROM files,packages_files_rel " + if (search_files) { + snprintf(dbname, PATH_MAX, "%s%s-%s-files.db", + query_repositories[i]->repository_dir, + query_repositories[i]->tag, + query_repositories[i]->arch[a]); + if (!sqlite3_open_v2(dbname, &dbf, SQLITE_OPEN_READONLY, NULL)) { + snprintf(sql, PATH_MAX, "SELECT * FROM files,packages_files_rel " "WHERE files.name LIKE '%%%s%%' AND " "packages_files_rel.id_file = files.id " "ORDER BY files.name = '%s' DESC, files.name LIKE '%s%%' DESC, " "files.name LIKE '%%%s%%' DESC LIMIT %d OFFSET %d", - queryenc, queryenc, queryenc, queryenc, query_limit, query_offset); - if (sqlite3_prepare_v2(dbf, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { - while (sqlite3_step(stmt1) == SQLITE_ROW) { - numresults++; - if (++localprovidesresults == 1) { - printf("

"); - if (localresults > 0) printf(_("Other results in ")); - else printf(_("Results in")); - printf(" %s %s %s:
", - query_repositories[i]->tag, - _("for arch "), - query_repositories[i]->arch[a]); + queryenc, queryenc, queryenc, queryenc, query_limit, query_offset); + if (sqlite3_prepare_v2(dbf, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { + while (sqlite3_step(stmt1) == SQLITE_ROW) { + numresults++; + if (++localprovidesresults == 1) { + printf("

"); + if (localresults > 0) printf(_("Other results in ")); + else printf(_("Results in")); + printf(" %s %s %s:
", + query_repositories[i]->tag, + _("for arch "), + query_repositories[i]->arch[a]); + } + printf("%s %s %s
", + query_repositories[i]->tag, + sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "name")), + query_repositories[i]->arch[a], + sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "name")), + _("provides file "), + resolveFilePath(dbf, sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "id_file")), buffer)); } - printf("%s %s %s
", - query_repositories[i]->tag, - sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "name")), - query_repositories[i]->arch[a], - sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packages_files_rel", "name")), - _("provides file "), - resolveFilePath(dbf, sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "id_file")), buffer)); + sqlite3_finalize(stmt1); } - sqlite3_finalize(stmt1); + sqlite3_close(dbf); } - sqlite3_close(dbf); } if (localprovidesresults > 0) printf("
"); 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,25 +519,33 @@ 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("
"); printf("]]>"); - printf("", - query_next, query_limit, query_limit * (i-1)); - printf("%d", i); - printf(" "); + if (a > 1) { + printf(" [ "); + for (i = j; i <= a; i++) { + if (i != k) printf("", + query_next, query_limit, query_limit * (i-1)); + printf("%d", i); + printf(" "); + } + printf("]"); } printf("]]>"); @@ -920,11 +939,15 @@ 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, "&"); } - 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';