0028868b72060a31d1ac6d35407f6d78c7ceb680 kate Tue Nov 7 10:00:48 2017 -0800 Implement text pennantIcon (for 'New' tag). Simplify code while hood is up. refs #20270 diff --git src/hg/lib/hui.c src/hg/lib/hui.c index 75611db..92bdd19 100644 --- src/hg/lib/hui.c +++ src/hg/lib/hui.c @@ -8384,133 +8384,129 @@ count++; while (sources && sameString(sources->name, source->name)) { source = slPopHead(&sources); fputs(", ", stdout); fputs(source->description, stdout); count++; } webPrintLinkCellEnd(); } sqlFreeResult(&sr); webPrintLinkTableEnd(); printf("Total: %d\n", count); } -boolean printPennantIconNote(struct trackDb *tdb) -// Returns TRUE and prints out the "pennantIcon" and note when found. -//This is used by hgTrackUi and hgc before printing out trackDb "html" +static char *makePennantIcon(struct trackDb *tdb, char **hintRet) +// Builds a string with pennantIcon HTML and returns it. Also returns hint. */ { char *setting = trackDbSetting(tdb, "pennantIcon"); -if (setting != NULL) - { +if (setting == NULL) + return FALSE; + setting = cloneString(setting); char *icon = nextWord(&setting); char buffer[4096]; char *src = NULL; +char *url = NULL, *hint = NULL, *color = NULL; - if (startsWith("http://", icon) || startsWith("ftp://", icon) || - startsWith("https://", icon)) +boolean isTextIcon = FALSE; +if (!(endsWith(icon, ".jpg") || endsWith(icon, ".png"))) + { + isTextIcon = TRUE; + color = nextWord(&setting); + src = strLower(icon); + } +else if (startsWith("http://", icon) || startsWith("https://", icon) || + startsWith("ftp://", icon)) src = htmlEncode(icon); else { safef(buffer, sizeof buffer, "../images/%s", icon); src = htmlEncode(buffer); } - char *url = NULL; - if (setting != NULL) - url = nextWord(&setting); - char *hint = NULL; - if (setting != NULL) - hint = htmlEncode(stripEnclosingDoubleQuotes(setting)); - - if (!isEmpty(url)) +if (setting) { - if (isEmpty(hint)) - printf("
",url,src);
- else
+ url = nextWord(&setting);
+ if (setting)
{
- printf("
",hint,url,src);
-
- // Special case for liftOver from hg17 or hg18, but this should probably be generalized.
- if (sameString(icon,"18.jpg") && startsWithWord("lifted",hint))
- printf(" Note: these data have been converted via liftOver from the Mar. 2006 "
- "(NCBI36/hg18) version of the track.");
- else if (sameString(icon,"17.jpg") && startsWithWord("lifted",hint))
- printf(" Note: these data have been converted via liftOver from the May 2004 "
- "(NCBI35/hg17) version of the track.");
- else
- printf(" Note: %s.",hint);
- printf("