distroquery: favicon management and some other output data improvements
This commit is contained in:
parent
9c1d4b1547
commit
0610ab9760
@ -163,6 +163,23 @@ int find_query_arch(char* arch) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
void printRPMFlags(int flags) {
|
||||
if (flags & RPMSENSE_LESS) printf("<");
|
||||
if (flags & RPMSENSE_GREATER) printf(">");
|
||||
if (flags & RPMSENSE_EQUAL) printf("=");
|
||||
}
|
||||
|
||||
void printTagsLine(const char* arch, const char* tag, const char* group, const char* license) {
|
||||
if (!arch)
|
||||
printf("<div style='display:inline;color:white;background-color:red'> Source </div> ");
|
||||
else
|
||||
printf("<div style='display:inline;color:white;background-color:green'> %s </div> ", arch);
|
||||
printf("<div style='display:inline;color:black;background-color:yellow'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:lightblue'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:orange'> %s </div>",
|
||||
tag, group, license);
|
||||
}
|
||||
|
||||
void printInputForm() {
|
||||
struct configTag *ct = firstconfigtag;
|
||||
|
||||
@ -207,8 +224,9 @@ void printQueryData() {
|
||||
|
||||
int a, i, j, k, numresults = 0;
|
||||
char dbname[PATH_MAX];
|
||||
sqlite3_stmt *statement;
|
||||
sqlite3_stmt *statement, *stmt1;
|
||||
char sql[PATH_MAX];
|
||||
char buffer[PATH_MAX];
|
||||
|
||||
printf("<queryreply><![CDATA[");
|
||||
for (i = 0; i < strlen(query); i++) {
|
||||
@ -238,6 +256,15 @@ void printQueryData() {
|
||||
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname);
|
||||
}
|
||||
}
|
||||
if (!query_repositories[i]->db[ARCHS_MAX]) {
|
||||
snprintf(dbname, PATH_MAX, "%s%s-sources.db",
|
||||
query_repositories[i]->repository_dir, query_repositories[i]->tag);
|
||||
if (sqlite3_open_v2(dbname, (sqlite3**)&query_repositories[i]->db[ARCHS_MAX], SQLITE_OPEN_READONLY, NULL)) {
|
||||
query_repositories[i]->db[ARCHS_MAX] = NULL;
|
||||
fprintf(stderr, "ERROR: unable to open sqlite3 db %s; ignoring.\n", dbname);
|
||||
}
|
||||
}
|
||||
|
||||
if (query_repositories[i]->db[a]) {
|
||||
snprintf(sql, PATH_MAX,
|
||||
"SELECT * FROM packages WHERE name LIKE '%%%s%%' OR summary LIKE '%%%s%%' OR description LIKE '%%%s%%' OR version LIKE '%%%s%%' "
|
||||
@ -249,20 +276,29 @@ void printQueryData() {
|
||||
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[a], sql, strlen(sql), &statement, NULL) == SQLITE_OK) {
|
||||
while (sqlite3_step(statement) == SQLITE_ROW) {
|
||||
numresults++;
|
||||
printf("<div style='position:relative'><hr><br><div style='display:inline;color:white;background-color:green'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:yellow'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:lightblue'> %s </div><br>"
|
||||
"<b>%s</b> %s-%s<br>%s",
|
||||
query_repositories[i]->arch[a],
|
||||
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, "name")),
|
||||
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, "summary")));
|
||||
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM sources WHERE id=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")));
|
||||
if (sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) {
|
||||
sqlite3_step(stmt1);
|
||||
get_favicon_from_url(sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
|
||||
} else buffer[0]='\0';
|
||||
|
||||
printf("<div style='position:relative'><hr><br>");
|
||||
printTagsLine(query_repositories[i]->arch[a],
|
||||
query_repositories[i]->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
|
||||
printf("<br><img src=\"%s\" width\"16\" height=\"16\"> ", buffer);
|
||||
|
||||
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>",
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")));
|
||||
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;'>"
|
||||
@ -277,7 +313,7 @@ void printQueryData() {
|
||||
printf("<div style='display:inline;background-color:green'>"
|
||||
" <a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">Download</a> </div>",
|
||||
query_repositories[i]->download_prefix,
|
||||
query_repositories[i]->download_dir,
|
||||
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")));
|
||||
@ -316,26 +352,33 @@ void printQueryData() {
|
||||
(sqlite3_prepare_v2((sqlite3*)query_repositories[i]->db[ARCHS_MAX], sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
||||
while (sqlite3_step(statement) == SQLITE_ROW) {
|
||||
numresults++;
|
||||
printf("<hr><br><div style='display:inline;color:black;background-color:red'> Source </div> "
|
||||
"<div style='display:inline;color:black;background-color:yellow'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:lightblue'> %s </div><br>"
|
||||
"<b>%s</b> %s-%s<br>%s<br>License: %s</br>URL: %s<br><br>"
|
||||
"<div style='text-align:justify;text-justify:inter-word;font-style:italic'>%s</div><br>",
|
||||
query_repositories[i]->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
||||
|
||||
get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
|
||||
|
||||
printf("<hr><br>");
|
||||
|
||||
printTagsLine(NULL,
|
||||
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, "license")));
|
||||
|
||||
printf("<br><img src=\"%s\" width\"16\" height=\"16\"> ", buffer);
|
||||
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")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")));
|
||||
printf(" <div style='display:inline;background-color:lightblue;font-weight:strong'>"
|
||||
"<a href='javascript:distroquery_request("
|
||||
"\"repository=%s&package=%s\")' style=\"color:black\"> Details </a></div>",
|
||||
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>",
|
||||
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'>"
|
||||
" <a href='javascript:distroquery_request("
|
||||
"\"repository=%s&package=%s\")' style=\"color:black\">Details</a> </div>",
|
||||
query_repositories[i]->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")));
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "ERROR: SQLite: %s (%s)\n", sqlite3_errmsg(query_repositories[i]->db[ARCHS_MAX]), sql);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -354,12 +397,6 @@ void printQueryData() {
|
||||
}
|
||||
}
|
||||
|
||||
void printRPMFlags(int flags) {
|
||||
if (flags & RPMSENSE_LESS) printf("<");
|
||||
if (flags & RPMSENSE_GREATER) printf(">");
|
||||
if (flags & RPMSENSE_EQUAL) printf("=");
|
||||
}
|
||||
|
||||
void printPackageData() {
|
||||
|
||||
int a, i, j, k;
|
||||
@ -369,6 +406,7 @@ void printPackageData() {
|
||||
char sql[PATH_MAX];
|
||||
char buffer[PATH_MAX];
|
||||
struct configTag* ct = findRepositoryByTag(query_repository);
|
||||
humanDate strdate;
|
||||
sizeString strsize;
|
||||
|
||||
printf("<queryreply><![CDATA[");
|
||||
@ -388,20 +426,25 @@ void printPackageData() {
|
||||
|
||||
snprintf(dbname, PATH_MAX, "%s%s-sources.db", ct->repository_dir, ct->tag);
|
||||
if (!sqlite3_open_v2(dbname, &dbs, SQLITE_OPEN_READONLY, NULL)) {
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM sources WHERE id=%d",
|
||||
|
||||
snprintf(sql, PATH_MAX,
|
||||
"SELECT * FROM sources,packagers WHERE sources.id=%d AND sources.id_packager=packagers.id",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id_source")));
|
||||
if (sqlite3_prepare_v2(dbs, sql, strlen(sql), &stmt1, NULL) == SQLITE_OK) sqlite3_step(stmt1);
|
||||
}
|
||||
|
||||
printf("<hr><br><div style='display:inline;color:white;background-color:green'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:yellow'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:lightblue'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:orange'> %s </div><br><br>"
|
||||
"<h1>%s - %s</h1>Version: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>Size: %s",
|
||||
query_arch,
|
||||
ct->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")),
|
||||
printf("<hr><br>");
|
||||
printTagsLine(query_arch,
|
||||
ct->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "license")));
|
||||
|
||||
get_favicon_from_url(sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "url")),buffer,PATH_MAX);
|
||||
|
||||
printf("<br><br>"
|
||||
"<h1><img src=\"%s\" width\"16\" height=\"16\"> "
|
||||
"%s - %s</h1>Version: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>Size: %s",
|
||||
buffer,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
||||
@ -445,6 +488,10 @@ void printPackageData() {
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")),
|
||||
sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, NULL, "name")));
|
||||
|
||||
printf("<br>Maintainer: %s", sqlite3_column_text(stmt1,sqlite3_find_column_id(stmt1, "packagers", "name")));
|
||||
printf("<br>Build date: %s",
|
||||
simpleTimeToHuman(sqlite3_column_int(stmt1,sqlite3_find_column_id(stmt1, NULL, "buildtime")), (humanDate *) & strdate));
|
||||
|
||||
printf("<br><br>Obsoletes:");
|
||||
snprintf(sql, PATH_MAX, "SELECT * FROM obsoletes WHERE id_package=%d",
|
||||
sqlite3_column_int(statement,sqlite3_find_column_id(statement, NULL, "id")));
|
||||
@ -496,7 +543,7 @@ void printPackageData() {
|
||||
|
||||
void printSourcePackageData() {
|
||||
|
||||
int a, i, j, k, numresults = 0;
|
||||
int a, i, j, k;
|
||||
char dbname[PATH_MAX];
|
||||
sqlite3 *db, *dba;
|
||||
sqlite3_stmt *statement, *stmt1;
|
||||
@ -521,15 +568,19 @@ void printSourcePackageData() {
|
||||
if (db &&
|
||||
(sqlite3_prepare_v2(db, sql, strlen(sql), &statement, NULL) == SQLITE_OK)) {
|
||||
while (sqlite3_step(statement) == SQLITE_ROW) {
|
||||
numresults++;
|
||||
printf("<hr><br><div style='display:inline;color:white;background-color:red'> Source </div> "
|
||||
"<div style='display:inline;color:black;background-color:yellow'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:lightblue'> %s </div> "
|
||||
"<div style='display:inline;color:black;background-color:orange'> %s </div><br><br>"
|
||||
"<h1>%s - %s</h1>Version: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>Size: %s",
|
||||
ct->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")),
|
||||
|
||||
printf("<hr><br>");
|
||||
printTagsLine(NULL,
|
||||
ct->tag,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "groupdescr")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "license")));
|
||||
|
||||
get_favicon_from_url(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "url")),buffer,PATH_MAX);
|
||||
|
||||
printf("<br><br>"
|
||||
"<h1><img src=\"%s\" width\"16\" height=\"16\"> "
|
||||
"%s - %s</h1>Version: %s-%s<br>URL: <a href=\"%s\" target=_new>%s</a><br>Size: %s",
|
||||
buffer,
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "name")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "summary")),
|
||||
sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "version")),
|
||||
@ -560,7 +611,7 @@ void printSourcePackageData() {
|
||||
htmlclean(sqlite3_column_text(statement,sqlite3_find_column_id(statement, NULL, "description")),buffer,PATH_MAX));
|
||||
|
||||
/* download */
|
||||
printf("<div style='display:inline;background-color:green'>"
|
||||
printf("<div style='display:inline;background-color:red'>"
|
||||
" <a href=\"%s%s/SRPMS.base/%s-%s-%s.src.rpm\" style=\"color:white\">Download</a> </div>",
|
||||
ct->download_prefix,
|
||||
ct->download_dir,
|
||||
|
@ -626,3 +626,27 @@ int scansdir(const char *dir, struct dirent ***namelist,
|
||||
|
||||
return(i);
|
||||
}
|
||||
|
||||
int
|
||||
get_favicon_from_url(const char* url,char *buf,int bufsize) {
|
||||
|
||||
int i=0,l=0;
|
||||
|
||||
/* expecting urls in the form http://address/... */
|
||||
if (url) {
|
||||
while ((i<bufsize) && url[i]) {
|
||||
buf[i]=url[i];
|
||||
if (buf[i] == '/') {
|
||||
l++;
|
||||
if (l == 3) break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
buf[i]='\0';
|
||||
} else {
|
||||
/* use current site as default icon */
|
||||
buf[0]='\0';
|
||||
}
|
||||
strcat(buf,"/favicon.ico");
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,5 +39,5 @@ int scansdir(const char *dir, struct dirent ***namelist,
|
||||
int (*select)(const struct dirent *),
|
||||
int (*compar)(const struct dirent **, const struct dirent **));
|
||||
void backtraceHandler(int sig);
|
||||
|
||||
int get_favicon_from_url(const char* url,char *buf,int bufsize);
|
||||
#endif /* FUNCTIONS_H */
|
||||
|
@ -34,7 +34,6 @@ void print_contents_subtree(FILE *f,
|
||||
struct fileTree* ft,
|
||||
struct configTag* ct,
|
||||
char* buf, int bufsize);
|
||||
int get_pkg_icon(struct headerSourceList *h,char *buf,int bufsize);
|
||||
int generatePkgList(struct configTag *ct, int arch);
|
||||
int generateSrcPkgList(struct configTag *ct);
|
||||
|
||||
|
@ -838,29 +838,6 @@ generateHTMLMainIndex(struct configTag *configtag)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
get_pkg_icon(struct headerSourceList *h,char *buf,int bufsize) {
|
||||
|
||||
int i=0,l=0;
|
||||
|
||||
/* expecting urls in the form http://address/... */
|
||||
if (h->url) {
|
||||
while ((i<bufsize) && h->url[i]) {
|
||||
buf[i]=h->url[i];
|
||||
if (buf[i] == '/') {
|
||||
l++;
|
||||
if (l == 3) break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
buf[i]='\0';
|
||||
} else {
|
||||
/* use current site as default icon */
|
||||
strcat(buf,"/");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
generateHTML_SRPMSFiles(struct configTag *configtag)
|
||||
{
|
||||
@ -978,10 +955,10 @@ generateHTML_SRPMSFiles(struct configTag *configtag)
|
||||
return 1;
|
||||
}
|
||||
|
||||
get_pkg_icon(currheadersourcelist,buffer2,1024);
|
||||
get_favicon_from_url(currheadersourcelist->url,buffer2,1024);
|
||||
|
||||
fprintf(fout,
|
||||
"<h1><img src=\"%s/favicon.ico\" width=\"16\" height=\"16\">"
|
||||
"<h1><img src=\"%s\" width=\"16\" height=\"16\">"
|
||||
" %s: %s (source)</h1><table class=\"pkgpage\" width=\"100%%\">\n",
|
||||
buffer2,
|
||||
currheadersourcelist->name,
|
||||
@ -1449,10 +1426,10 @@ generateHTMLFiles(struct configTag *ct, int arch)
|
||||
perror(htmlfile);
|
||||
return 1;
|
||||
}
|
||||
get_pkg_icon(currheaderlist->sourceheader,buffer,1024);
|
||||
get_favicon_from_url(currheaderlist->sourceheader->url,buffer,1024);
|
||||
|
||||
fprintf(fout,
|
||||
"<h1><img src=\"%s/favicon.ico\" width=\"16\" height=\"16\">"
|
||||
"<h1><img src=\"%s\" width=\"16\" height=\"16\">"
|
||||
" %s: %s</h1><table class=\"pkgpage\" width=\"100%%\">",
|
||||
buffer,
|
||||
currheaderlist->name,
|
||||
|
Loading…
Reference in New Issue
Block a user