6f07cab7fdf96c16066566d551fc310d0d8afb52 max Tue Mar 1 13:36:13 2016 -0800 for patents track, refs #14486: - two additional trackDb statements to remove or separate extra fields of bigBed files in track hubs - changes to hgc to format extra fields as a table, looks somewhat nicer - two scripts to reformat patent tables to bigBed files diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index 9325cf9..e95dc54 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -932,55 +932,50 @@ * return itemName. */ { char *sql = trackDbSetting(tdb, "idInUrlSql"); char *id = itemName; if (sql != NULL) { char query[1024]; sqlSafef(query, sizeof(query), sql, itemName); struct sqlConnection *conn = hAllocConn(database); id = sqlQuickString(conn, query); hFreeConn(&conn); } return id; } -char* constructUrl(struct trackDb *tdb, char *urlSetting, char *idInUrl, boolean encode) +char* getUrlSetting(struct trackDb *tdb, char* urlSetting) +/* get the "url" setting for the current track */ { -/* construct the url by replacing $$, etc in the url given by urlSetting. - * Replace $$ with itemName. */ - -// check the url setting prefix and get the correct url setting from trackDb char *url; if (sameWord(urlSetting, "url")) url = tdb->url; else url = trackDbSetting(tdb, urlSetting); - -if (url == NULL || url[0] == 0) - return NULL; - -char* eUrl = replaceInUrl(url, idInUrl, cart, database, seqName, winStart, winEnd, tdb->track, encode); -return eUrl; +return url; } void printIframe(struct trackDb *tdb, char *itemName) /* print an iframe with the URL specified in trackDb (iframeUrl), can have * the standard codes in it (like $$ for itemName, etc) */ { -char* eUrl = constructUrl(tdb, "iframeUrl", itemName, FALSE); +char *url = getUrlSetting(tdb, "iframeUrl"); +if (url==NULL) + return; +char *eUrl = replaceInUrl(url, itemName, cart, database, seqName, winStart, winEnd, tdb->track, FALSE); if (eUrl==NULL) return; char *iframeOptions = trackDbSettingOrDefault(tdb, "iframeOptions", "width='100%%' height='1024'"); // Resizing requires the hgcDetails pages to include a bit of javascript. // // Explanation how this works and why the javascript is needed: // http://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content // In short: // - iframes have a fixed size in html, resizing can only be done in javascript // - the iframed page cannot call the resize() function in the hgc html directly, as they have // been loaded from different webservers // - one way around it is that the iframed page includes a helper page on our server and // send their size to the helper page (pages can call functions of included pages) // - the helper page then sends the size back to hgc (pages on the same server can @@ -993,49 +988,64 @@ { \ document.getElementById('hgcIframe').height = parseInt(height)+10; \ } \ \ \ \
", eUrl, iframeOptions);
}
void printCustomUrlWithLabel(struct trackDb *tdb, char *itemName, char *itemLabel, char *urlSetting, boolean encode)
/* Print custom URL specified in trackDb settings. */
{
char urlLabelSetting[32];
// replace the $$ and other wildchards with the url given in tdb
-char* eUrl = constructUrl(tdb, urlSetting, itemName, encode);
+char *url = getUrlSetting(tdb, "url");
+//char* eUrl = constructUrl(tdb, url, itemName, encode);
+if (url==NULL)
+ return;
+
+char* eUrl = replaceInUrl(url, itemName, cart, database, seqName, winStart, winEnd, tdb->track, encode);
if (eUrl==NULL)
return;
/* create the url label setting for trackDb from the url
setting prefix */
safef(urlLabelSetting, sizeof(urlLabelSetting), "%sLabel", urlSetting);
-printf("%s ",
- trackDbSettingOrDefault(tdb, urlLabelSetting, "Outside Link:"));
+char *linkLabel = trackDbSettingOrDefault(tdb, urlLabelSetting, "Outside Link:");
+
+// if we got no item name from hgTracks or the item name does not appear in the URL
+// there is no need to show the item name at all
+if (isEmpty(itemName) || !stringIn("$$", url))
+ {
+ printf("%s
",eUrl, linkLabel);
+ return;
+ }
+
+printf("%s ",linkLabel);
+
printf("", eUrl);
if (sameWord(tdb->table, "npredGene"))
{
printf("%s (%s)
\n", itemName, "NCBI MapView");
}
else
{
char *label = itemName;
- if (isNotEmpty(itemLabel) && !sameString(itemName, itemLabel))
+ if (isNotEmpty(itemLabel) && sameString(itemName, itemLabel))
label = itemLabel;
printf("%s
\n", label);
}
//freeMem(&eUrl); small memory leak
}
void printCustomUrl(struct trackDb *tdb, char *itemName, boolean encode)
/* Wrapper to call printCustomUrlWithLabel using the url setting in trackDb */
{
char urlSetting[10];
safef(urlSetting, sizeof(urlSetting), "url");
printCustomUrlWithLabel(tdb, itemName, itemName, urlSetting, encode);
}
@@ -1466,38 +1476,50 @@
}
// split the id into parts and print each part as a link
struct slName *slIds = slNameListFromComma(idList);
struct slName *itemId = NULL;
// handle id->name mapping for multi-source items
int nameCount;
char **idNames = getIdNameMap(tdb, col, &nameCount);
printf("
%s: | ", col->comment); + + // do not print a row if the fieldName from the .as file is in the "skipFields" list + if (skipIds && slNameInList(skipIds, fieldName)) + continue; + + // split this table to separate current row from the previous one, if the trackDb option is set + if (sepFields && slNameInList(sepFields, fieldName)) + printf("
\n
%s | ", col->comment); // bold style now in HGStyle.css + if (col->isList || col->isArray || col->lowType->stringy || asTypesIsInt(col->lowType->type)) printIdOrLinks(col, fieldToUrl, tdb, fields[ix]); else if (asTypesIsFloating(col->lowType->type)) { double valDouble = strtod(fields[ix],NULL); if (errno == 0 && valDouble != 0) printf("%g | %s | \n", fields[ix]); // decided not to print error } else printf("%s | \n", fields[ix]); } asObjectFree(&as); freeMem(fieldToUrl); +if (skipIds) + slFreeList(skipIds); +if (sepFields) + slFreeList(sepFields); + if (count > 0) printf("