a9dd8b9c383927df373d50e5917b20c959c662fc
kate
  Wed Nov 23 10:49:30 2016 -0800
Link to new GTEX Body Map configuration page from hgc and config page. From QA review.  refs #17369

diff --git src/hg/lib/gtexUi.c src/hg/lib/gtexUi.c
index d4b3503..b8969e2 100644
--- src/hg/lib/gtexUi.c
+++ src/hg/lib/gtexUi.c
@@ -1,41 +1,67 @@
 /* GTEx (Genotype Tissue Expression) track controls */
 
 /* Copyright (C) 2015 The Regents of the University of California 
  * See README in this or parent directory for licensing information. */
 
 #include "cheapcgi.h"
 #include "cart.h"
 #include "hui.h"
 #include "trackDb.h"
 #include "jsHelper.h"
+#include "hCommon.h"
 #include "gtexTissue.h"
 #include "gtexInfo.h"
 #include "gtexUi.h"
 
 #define SYSTEM_BRAIN            "Brain"
 #define SYSTEM_REPRODUCTIVE     "Reproductive"
 #define SYSTEM_GASTRO           "Digestive"
 
 #define SYSTEM_ENDOCRINE        "Endocrine"
 #define SYSTEM_CARDIO           "Cardiovascular"
 #define SYSTEM_OTHER            "Other"
 
 
 /* Restrict features on right-click (popup) version */
 static boolean isPopup = FALSE;
 
+/* Path to Body Map-based track configuration */
+static char *_hgGtexTrackSettingsName = "../cgi-bin/hgGtexTrackSettings"; 
+
+boolean gtexIsGeneTrack(char *trackName)
+/* Identify GTEx gene track so custom trackUi CGI can be launched */
+{
+return startsWith(GTEX_GENE_TRACK_BASENAME, trackName);
+}
+
+char *gtexGeneTrackUiName()
+/* Refer to Body Map CGI if suitable */
+{
+// TODO: Remove cfg option when CGI is formally released
+#include "hgConfig.h"
+if (!cfgOption("gtexBodyMap"))
+    return hgTrackUiName();
+
+// Display body map configuration page if user is on a browser we've tested
+enum browserType bt = cgiBrowser();
+if (bt == btChrome || bt == btFF || bt == btSafari)
+    return(_hgGtexTrackSettingsName);
+
+return hgTrackUiName();
+}
+
 /* Convenience functions for tissue filter controls */
 
 static char *makeTissueColorPatch(struct gtexTissue *tis)
 /* Display a box colored by defined tissue color */
 {
 char buf[256];
 safef(buf, sizeof(buf), "<td bgcolor=#%06X></td>", tis->color);
 return(cloneString(buf));
 }
 
 static char *makeTissueLabel(struct gtexTissue *tis)
 {
 /* Display tissue color and label */
 char buf[256];
 safef(buf, sizeof(buf), "<td bgcolor=%X></td>"
@@ -424,31 +450,32 @@
 selected = cartCgiUsualString(cart, cartVar, GTEX_COLORS_DEFAULT); 
 boolean isGtexColors = sameString(selected, GTEX_COLORS_GTEX);
 cgiMakeRadioButton(cartVar, GTEX_COLORS_GTEX, isGtexColors);
 printf("GTEx\n");
 cgiMakeRadioButton(cartVar, GTEX_COLORS_RAINBOW, !isGtexColors);
 printf("Rainbow\n");
 printf("</p>");
 #endif
 
 /* Tissue filter */
 printf("<br>");
 printf("<div><b>Tissues:</b>\n");
 safef(cartVar, sizeof(cartVar), "%s.%s", track, GTEX_TISSUE_SELECT);
 if (isPopup)
     {
-    printf("<a href='../cgi-bin/hgTrackUi?g=%s'><button type='button'>Change</button><a>", track);
+    printf("<a href='%s?g=%s'><button type='button'>Change</button><a>", 
+                hTrackUiForTrack(track), track);
     }
 else
     {
     jsMakeCheckboxGroupSetClearButton(cartVar, TRUE);
     puts("&nbsp;");
     jsMakeCheckboxGroupSetClearButton(cartVar, FALSE);
     }
 printf("</div>");
 char *version = gtexVersion(tdb->table);
 struct gtexTissue *tissues = gtexGetTissues(version);
 struct slName *selectedValues = NULL;
 if (cartListVarExistsAnyLevel(cart, tdb, FALSE, GTEX_TISSUE_SELECT))
     selectedValues = cartOptionalSlNameListClosestToHome(cart, tdb, FALSE, GTEX_TISSUE_SELECT);
 char *selectType = cgiUsualString("tis", "table");
 if (sameString(selectType, "group"))