f1d16c8dda5212308a33fa1642a07b7e8c28b047
max
  Thu Mar 30 07:57:27 2023 -0700
adding downloadUrl trackDb statement, no docs yet, refs #30904

diff --git src/hg/lib/hui.c src/hg/lib/hui.c
index 5c2c4f2..9266dc6 100644
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@ -529,30 +529,42 @@
                 "%s=%s&"
                 "%s=%s&"
                 "%s=%s'>"
         "Display regions of interest (%d)</a>",
                     MULTI_REGION_BED_WIN_FULL, tdb->track, cgiEncode(regionFile), tdb->track, 
                     hStringFromTv(vis),
                     CT_CUSTOM_DOC_TEXT_VAR, cgiEncode(customHtml),
                     CT_CUSTOM_TEXT_VAR, cgiEncode(dyStringCannibalize(&dsCustomText)), regionCount);
 printf(" in multi-region view (custom regions mode)");
 printf("&nbsp;&nbsp;&nbsp;");
 printf("<a href=\"../goldenPath/help/multiRegionHelp.html\" target=_blank>(Help)</a>\n");
 printf("</p>");
 return TRUE;
 }
 
+static void makeFileDownloads(char *fileDownloads) 
+/* print an additional file download link, file can be anywhere on the internet, useful e.g. for GTF files for gene tracks */
+{
+char *parts[2];
+int partCount = chopByWhite(fileDownloads, parts, 2);
+if (partCount!=2)
+    puts("<b>Internal Error:</b> The downloadUrl trackDb statement needs exactly two arguments, the file type and the URL.");
+char* fileType = parts[0];
+char* url = parts[1];
+printf("<br>Download: <a href=\"%s\">%s File</a>", url, fileType);
+}
+
 void extraUiLinks(char *db, struct trackDb *tdb, struct cart *cart)
 // Show metadata, and downloads, schema links where appropriate
 {
 makeMultiRegionLink(db, tdb, cart);
 
 struct slPair *pairs = trackDbMetaPairs(tdb);
 if (pairs != NULL)
     printf("<b>Metadata:</b><br>%s\n", pairsAsHtmlTable( pairs, tdb, FALSE, FALSE));
 else if (!tdbIsComposite(tdb) && !trackHubDatabase(db) && (metadataForTable(db, tdb, NULL) != NULL))
     printf("<b>Metadata:</b><br>%s\n", metadataAsHtmlTable(db, tdb, FALSE, FALSE));
 
 boolean schemaLink = trackDataAccessible(db, tdb);
 boolean downloadLink = (trackDbSetting(tdb, "wgEncode") != NULL && !tdbIsSuperTrack(tdb));
 int links = 0;
 if (schemaLink)
@@ -561,30 +573,35 @@
     links++;
 
 if (links > 0)
     cgiDown(0.7);
 if (links > 1)
     printf("<table><tr><td nowrap>View table: ");
 
 if (schemaLink && differentString("longTabix", tdb->type) && !isCustomComposite(tdb))
     // FIXME: hgTables.showSchmaLongTabix is a currently a dummy routine, so let's not got here
     // until it's implemented
     {
     makeSchemaLink(db,tdb,(links > 1 ? "Data format":"Data schema/format description and download"));
     if (downloadLink)
 	printf(", ");
     }
+
+char *fileDownloads = trackDbSetting(tdb, "downloadUrl");
+if (fileDownloads)
+    makeFileDownloads(fileDownloads);
+
 if (downloadLink)
     {
     // special case exception (hg18:NHGRI BiPs are in 7 different dbs but only hg18 has downloads):
     char *targetDb = trackDbSetting(tdb, "compareGenomeLinks");
     if (targetDb != NULL)
 	{
 	targetDb = cloneFirstWordByDelimiter(targetDb,'=');
 	if (!startsWith("hg",targetDb))
 	    freez(&targetDb);
 	}
     if (targetDb == NULL)
 	targetDb = cloneString(db);
 
     makeNamedDownloadsLink(targetDb, tdb, (links > 1 ? "downloads":"Downloads"));
     freez(&targetDb);