distroquery: added query_compact option for webbuild

This commit is contained in:
Silvan Calarco 2013-10-20 03:20:01 +02:00
parent 56c348f1b9
commit f18e247d7a

View File

@ -83,6 +83,7 @@ char *query = "";
char *query_package; char *query_package;
char *query_repository; char *query_repository;
char *query_arch = NULL; char *query_arch = NULL;
int query_compact = 0;
int query_limit = 10; int query_limit = 10;
int query_offset = 0; int query_offset = 0;
char query_next[PATH_MAX] = ""; char query_next[PATH_MAX] = "";
@ -367,7 +368,10 @@ void printQueryData() {
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
sqlite3_step(stmt1); sqlite3_step(stmt1);
get_favicon_from_url(sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX); get_favicon_from_url(sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
printf("<div style='position:relative'><hr><br>"); if (query_compact)
printf("<div style='position:relative'>");
else
printf("<div style='position:relative'><hr><br>");
printTagsLine(query_repositories[i]->arch[a], printTagsLine(query_repositories[i]->arch[a],
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
@ -375,44 +379,57 @@ void printQueryData() {
printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer); printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer);
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
} }
printf("<b>%s</b> %s-%s<br>%s", if (query_compact) {
printf("<b><a href='http://www.openmamba.org/distribution/search.html?"
"repository=%s&package=%s&arch=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
"%s</a></b> %s-%s - %s<br>",
query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
query_repositories[i]->arch[a],
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
} else {
printf("<b>%s</b> %s-%s<br>%s",
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>",
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
/* install */
/* printf("<div align=right style='position:absolute;top:5px;right:0;padding:5px;'>"
"<div><object type=\"application/x-packagekit-plugin\" width=\"400\" height=\"50\">"
"<param name=\"displayname\" value=\"%s - %s\" />"
"<param name=\"packagenames\" value=\"%s\" /></object></div>",
sqlite3_column_text(statement,1),
sqlite3_column_text(statement,6),
sqlite3_column_text(statement,1));*/
/* download */
printf("<div style='display:inline;background-color:green'>"
"&nbsp;<a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">%s</a>&nbsp;</div>",
query_repositories[i]->download_prefix,
query_repositories[i]->download_dir,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); _("Download"));
printf("<br><br><div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>", /* details */
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); printf("&nbsp;<div style='display:inline;background-color:lightblue;font-weight:strong'>"
"&nbsp;<a href=#reply onclick='distroquery_request("
"\"repository=%s&package=%s&arch=%s\")' style=\"color:black\">%s</a>&nbsp;</div>",
query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
query_repositories[i]->arch[a],
_("Details"));
printf("</div><br>");
}
/* install */
/* printf("<div align=right style='position:absolute;top:5px;right:0;padding:5px;'>"
"<div><object type=\"application/x-packagekit-plugin\" width=\"400\" height=\"50\">"
"<param name=\"displayname\" value=\"%s - %s\" />"
"<param name=\"packagenames\" value=\"%s\" /></object></div>",
sqlite3_column_text(statement,1),
sqlite3_column_text(statement,6),
sqlite3_column_text(statement,1));*/
/* download */
printf("<div style='display:inline;background-color:green'>"
"&nbsp;<a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">%s</a>&nbsp;</div>",
query_repositories[i]->download_prefix,
query_repositories[i]->download_dir,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
_("Download"));
/* details */
printf("&nbsp;<div style='display:inline;background-color:lightblue;font-weight:strong'>"
"&nbsp;<a href=#reply onclick='distroquery_request("
"\"repository=%s&package=%s&arch=%s\")' style=\"color:black\">%s</a>&nbsp;</div>",
query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
query_repositories[i]->arch[a],
_("Details"));
printf("</div><br>");
} }
} }
sqlite3_finalize(statement); sqlite3_finalize(statement);
@ -435,7 +452,20 @@ void printQueryData() {
_("for arch "), _("for arch "),
query_repositories[i]->arch[a]); query_repositories[i]->arch[a]);
} }
printf("<a href=#reply onclick='distroquery_request("
if (query_compact) {
printf("<a href='http://www.openmamba.org/distribution/search.html?"
"repository=%s&package=%s&arch=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
"%s</a> %s %s<br>",
query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
query_repositories[i]->arch[a],
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
_("provides"),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "provided", "name")));
} else {
printf("<a href=#reply onclick='distroquery_request("
"\"repository=%s&package=%s&arch=%s\")' style=\"color:black;background-color:lightblue\">%s</a> %s %s<br>", "\"repository=%s&package=%s&arch=%s\")' style=\"color:black;background-color:lightblue\">%s</a> %s %s<br>",
query_repositories[i]->tag, query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
@ -443,6 +473,7 @@ void printQueryData() {
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")), sqlite3_column_text(statement,sqlite3_find_column_id(statement, "packages", "name")),
_("provides"), _("provides"),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, "provided", "name"))); sqlite3_column_text(statement,sqlite3_find_column_id(statement, "provided", "name")));
}
} }
} }
@ -485,7 +516,7 @@ void printQueryData() {
sqlite3_close(dbf); sqlite3_close(dbf);
} }
} }
if (localprovidesresults > 0) printf("</div>"); if (localprovidesresults > 0) printf("</div><hr>");
sqlite3_finalize(statement); sqlite3_finalize(statement);
} }
@ -517,7 +548,7 @@ void printQueryData() {
get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX); get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
printf("<hr><br>"); if (!query_compact) printf("<hr><br>");
printTagsLine(NULL, printTagsLine(NULL,
query_repositories[i]->tag, query_repositories[i]->tag,
@ -525,19 +556,32 @@ void printQueryData() {
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license"))); sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")));
printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer); printf("<br><img src=\"%s\" width\"16\" height=\"16\">&nbsp;", buffer);
printf("<b>%s</b> %s-%s<br>%s<br><br>", if (query_compact) {
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")), printf("<b><a href='http://www.openmamba.org/distribution/search.html?"
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")), "repository=%s&package=%s&searchbox=true' style=\"color:black\" target='distroquery'>"
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")), "%s</a></b> %s-%s - %s<br>",
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX)); query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
} else {
printf("<b>%s</b> %s-%s<br>%s<br><br>",
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "release")),
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),buffer,PATH_MAX));
printf("<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>", printf("<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div>",
htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX)); htmlcleanNoBr(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
printf("<div style='display:inline;background-color:lightblue;font-weight:strong'>" /* source details */
"&nbsp;<a href=#reply onclick='distroquery_request(" printf("<div style='display:inline;background-color:lightblue;font-weight:strong'>"
"\"repository=%s&package=%s\")' style=\"color:black\">Details</a>&nbsp;</div>", "&nbsp;<a href=#reply onclick='distroquery_request("
query_repositories[i]->tag, "\"repository=%s&package=%s\")' style=\"color:black\">Details</a>&nbsp;</div>",
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name"))); query_repositories[i]->tag,
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")));
}
} }
sqlite3_finalize(statement); sqlite3_finalize(statement);
} else { } else {
@ -554,26 +598,26 @@ void printQueryData() {
printf("%d %s.", numresults, _("result(s) shown")); printf("%d %s.", numresults, _("result(s) shown"));
else else
printf("%d %s.", numresults, _("result(s) found")); printf("%d %s.", numresults, _("result(s) found"));
if (k < 7) j=1; else j=k-5; /* j = start pages list from */
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=#reply onclick='distroquery_request(\"%s&limit=%d&offset=%d\")'>",
query_next, query_limit, query_limit * (i-1));
printf("%d", i);
printf("</a>&nbsp");
}
printf("]");
}
if (!reply_plain) printf("]]></querystatus>");
if (!reply_plain) { if (!reply_plain) {
if (k < 7) j=1; else j=k-5; /* j = start pages list from */
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=#reply onclick='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["); printf("<title><![CDATA[");
printf("%s '%s' :: %s", _("Search results for"), query, firstconfigtag->configdefaults->distribution_name); printf("%s '%s' :: %s", _("Search results for"), query, firstconfigtag->configdefaults->distribution_name);
printf("]]></title>"); printf("]]></title>");
@ -717,12 +761,13 @@ void printPackageData() {
simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate)); simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate));
/* obsoletes */ /* obsoletes */
printf("<br><br>%s:", _("Obsoletes"));
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d", snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id"))); sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
sqlite3_finalize(stmt1); sqlite3_finalize(stmt1);
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
j=0;
while (sqlite3_step(stmt1) == SQLITE_ROW) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
if (j++ == 0) printf("<br><br>%s:", _("Obsoletes"));
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoletename"))); printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoletename")));
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion"))) { if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteversion"))) {
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteflags"))); printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "obsoleteflags")));
@ -733,13 +778,14 @@ void printPackageData() {
} }
/* provides */ /* provides */
printf("<br><br>%s:",_("Provides"));
snprintf(sql, PATH_MAX, "SELECT * FROM provides,provided " snprintf(sql, PATH_MAX, "SELECT * FROM provides,provided "
"WHERE provides.id_package=%d AND provided.id=provides.id_provided " "WHERE provides.id_package=%d AND provided.id=provides.id_provided "
"ORDER BY provided.name", "ORDER BY provided.name",
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id"))); sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
j=0;
while (sqlite3_step(stmt1) == SQLITE_ROW) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
if (j++ == 0) printf("<br><br>%s:",_("Provides"));
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name"))); printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion"))) { if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideversion"))) {
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideflags"))); printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "provideflags")));
@ -750,13 +796,14 @@ void printPackageData() {
} }
/* requires */ /* requires */
printf("<br><br>%s:", _("Requires"));
snprintf(sql, PATH_MAX, "SELECT * FROM requires,provided " snprintf(sql, PATH_MAX, "SELECT * FROM requires,provided "
"WHERE requires.id_package=%d AND provided.id=requires.id_provided " "WHERE requires.id_package=%d AND provided.id=requires.id_provided "
"ORDER BY provided.name", "ORDER BY provided.name",
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id"))); sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) { if (sqlite3_prepare_v2(db, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
j=0;
while (sqlite3_step(stmt1) == SQLITE_ROW) { while (sqlite3_step(stmt1) == SQLITE_ROW) {
if (j++ == 0) printf("<br><br>%s:", _("Requires"));
printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name"))); printf(" %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireversion"))) { if (sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireversion"))) {
printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireflags"))); printRPMFlags(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "requireflags")));
@ -1019,6 +1066,8 @@ void parse_request_variables(char *data) {
reply_xmltag = valuetok; reply_xmltag = valuetok;
} else if (!strcmp(vartok, "replyplain")) { } else if (!strcmp(vartok, "replyplain")) {
reply_plain = strstr(valuetok, "true") == valuetok; reply_plain = strstr(valuetok, "true") == valuetok;
} else if (!strcmp(vartok, "query_compact")) {
query_compact = strstr(valuetok, "true") == valuetok;
} else { } else {
/* fields to make reusable query string for next pages */ /* fields to make reusable query string for next pages */
if (!strcmp(vartok, "query")) { if (!strcmp(vartok, "query")) {