7f8b631eb54a42bd40d48dcdd85103cbc97ae534
braney
  Tue Feb 4 09:59:00 2025 -0800
pull out table named based handling into a separate function that can be
avoided if desired.

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index fae2986ec53..9d89ccac97c 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -26381,30 +26381,32 @@
 
 void doHPRCTable(struct trackDb *tdb, char *itemName)
 /* Put up a generic bigBed details page, with a table of links to turn on related
  *  * chain tracks with visibility toggles */
 {
 int start = cartInt(cart, "o");
 int end = cartInt(cart, "t");
 genericHeader(tdb, itemName);
 genericBigBedClick(NULL, tdb, itemName, start, end, 0);
 printTrackHtml(tdb);
 // tell the javscript to reorganize the column of assemblies:
 jsIncludeFile("hgc.js", NULL);
 jsInlineF("var doHPRCTable = true;\n");
 }
 
+boolean findNameBasedHandler(struct trackDb *tdb, char *track, char *item);
+
 void doMiddle()
 /* Generate body of HTML. */
 {
 char *track = cartString(cart, "g");
 char *item = cloneString(cartOptionalString(cart, "i"));
 char *parentWigMaf = cartOptionalString(cart, "parentWigMaf");
 struct trackDb *tdb = NULL;
 
 char *dupWholeName = NULL;
 boolean isDup = isDupTrack(track);
 if (isDup)
     {
     dupWholeName = track;
     track = dupTrackSkipToSourceName(track);
     }
@@ -26536,33 +26538,55 @@
 	    }
 	}
     }
 
 if (isDup)
     {
     struct dupTrack *dupList = dupTrackListFromCart(cart);
     struct dupTrack *dup = dupTrackFindInList(dupList, dupWholeName);
     if (dup != NULL)
 	{
 	tdb = dupTdbFrom(tdb, dup);
 	track = dupWholeName;
 	}
     }
 
+// do we want to avoid named based handling on this track?
+boolean avoidHandler = trackDbSettingOn(tdb, "avoidHandler");
+boolean calledHandler = FALSE;
+
+if (!avoidHandler)
+    calledHandler = findNameBasedHandler(tdb, track, item);
+
+if ((tdb != NULL) && !calledHandler)
+    {
+    genericClickHandler(tdb, item, NULL);
+    }
+else
+    {
+    cartWebStart(cart, database, "%s", track);
+    warn("Sorry, clicking there doesn't do anything yet (%s).", track);
+    }
+
+cartHtmlEnd();
+}
+
+boolean findNameBasedHandler(struct trackDb *tdb, char *track, char *item)
+// call hander routine based on name.  Return TRUE if we called a handler
+{
 char* handler = trackDbSetting(tdb, "trackHandler");
 
-/* Start of 1000+ line dispatch on table involving 100+ if/elses. */
 char *table = (tdb ? tdb->table : track);
 if (sameWord(table, "getDna"))
     {
     htmlDoNotTranslate();
     doGetDna1();
     }
 else if (sameWord(table, "htcGetDna2"))
     {
     htmlDoNotTranslate();
     doGetDna2();
     }
 else if (sameWord(table, "htcGetDna3"))
     {
     htmlDoNotTranslate();
     doGetDna3();
@@ -27770,42 +27794,34 @@
     }
 else if (tdb != NULL && startsWithWord("vcf", tdb->type))
     {
     doVcfDetails(tdb, item);
     }
 else if (tdb != NULL && 
         (startsWithWord("barChart", tdb->type) || startsWithWord("bigBarChart", tdb->type)))
     {
     doBarChartDetails(tdb, item);
     printTrackHtml(tdb);
     }
 else if (startsWith("hprcDeletions", table) || startsWith("hprcInserts", table) || startsWith("hprcArr", table)|| startsWith("hprcDouble", table))
     {
     doHPRCTable(tdb, item);
     }
-else if (tdb != NULL)
-    {
-    genericClickHandler(tdb, item, NULL);
-    }
 else
-    {
-    cartWebStart(cart, database, "%s", track);
-    warn("Sorry, clicking there doesn't do anything yet (%s).", track);
-    }
-/* End of 1000+ line dispatch on table involving 100+ if/elses. */
+    return FALSE;
 
-cartHtmlEnd();
+return TRUE;
 }
 
 struct hash *orgDbHash = NULL;
 
 void initOrgDbHash()
 /* Function to initialize a hash of organism names that hash to a database ID.
  * This is used to show alignments by hashing the organism associated with the
  * track to the database name where the chromInfo is stored. For example, the
  * mousBlat track in the human browser would hash to the mm2 database. */
 {
 orgDbHash = hashNew(8);
 }
 
 void cartDoMiddle(struct cart *theCart)
 /* Save cart and do main middle handler. */