Use url in FAVICON_SEARCH_PREFIX to get favicon url for sites
Default configuration pointing to google service Fallfack to <url>/favicon.ico if FAVICON_SEARCH_PREFIX is not set
This commit is contained in:
parent
4199fc7d62
commit
49b2967e9b
@ -34,6 +34,10 @@ URL_PREFIX="/distromatic/index.html?"
|
||||
# (default: ARCHS=i586)
|
||||
#
|
||||
#ARCHS = i586
|
||||
#
|
||||
# FAVICON_SEARCH_PREFIX:
|
||||
# external prefix url to service providing sites favicons
|
||||
FAVICON_SEARCH_PREFIX="http://www.google.com/s2/favicons?domain="
|
||||
|
||||
#[maintainers]
|
||||
# put maintainer list with aliases here
|
||||
|
@ -255,6 +255,9 @@ struct configTag* read_configuration(const char *confFile)
|
||||
} else if (!strcmp(vartok, "URL_DIR")) {
|
||||
configdefaults.url_dir =
|
||||
(char *) strdup(valuetok);
|
||||
} else if (!strcmp(vartok, "FAVICON_SEARCH_PREFIX")) {
|
||||
configdefaults.favicon_search_prefix =
|
||||
(char *) strdup(valuetok);
|
||||
} else if (!strcmp(vartok, "ARCHS")) {
|
||||
vartok = (char *) strtok(valuetok, " ");
|
||||
i = 0;
|
||||
@ -621,25 +624,26 @@ int scansdir(const char *dir, struct dirent ***namelist,
|
||||
return(i);
|
||||
}
|
||||
|
||||
#define favicon_url_prefix "http://g.etfv.co/"
|
||||
|
||||
int
|
||||
get_favicon_from_url(const char* url,char *buf,int bufsize) {
|
||||
|
||||
int i=0,l=0;
|
||||
|
||||
strncpy(buf, favicon_url_prefix, bufsize);
|
||||
if (configdefaults.favicon_search_prefix != NULL) {
|
||||
snprintf(buf, bufsize, "%s%s", configdefaults.favicon_search_prefix, url);
|
||||
} else {
|
||||
snprintf(buf, bufsize, "%s", url);
|
||||
|
||||
/* expecting urls in the form http://address/... */
|
||||
if (url) {
|
||||
while ((i<bufsize) && url[i]) {
|
||||
if (url[i] == '/') {
|
||||
l++;
|
||||
if (l == 3) break;
|
||||
}
|
||||
/* expecting urls in the form http://address/... */
|
||||
while ((i<bufsize) && buf[i]) {
|
||||
if (buf[i] == '/') {
|
||||
l++;
|
||||
if (l == 3) break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
buf[i] = 0;
|
||||
snprintf(&buf[i], bufsize - l, "/favicon.ico");
|
||||
}
|
||||
strncpy(&buf[strlen(buf)], url, i);
|
||||
return 0;
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ struct configDefaults {
|
||||
char *url_prefix;
|
||||
char *url_search_prefix;
|
||||
char *url_dir;
|
||||
char *favicon_search_prefix;
|
||||
char *arch[ARCHS_MAX];
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user