0e001cd4379962ce9af6daa4a6ea710c85bc21c6 max Mon Jan 15 07:25:19 2024 -0800 accept verbose=x on any CGI URL so we can see what UDC is doing, email with Brian/Mark diff --git src/hg/lib/cart.c src/hg/lib/cart.c index 08de27e..dec0d6e 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -22,30 +22,31 @@ #ifndef GBROWSE #include "customFactory.h" #include "googleAnalytics.h" #include "wikiLink.h" #endif /* GBROWSE */ #include "hgMaf.h" #include "hui.h" #include "geoMirror.h" #include "hubConnect.h" #include "trackHub.h" #include "cgiApoptosis.h" #include "customComposite.h" #include "regexHelper.h" #include "windowsToAscii.h" #include "jsonWrite.h" +#include "verbose.h" static char *sessionVar = "hgsid"; /* Name of cgi variable session is stored in. */ static char *positionCgiName = "position"; DbConnector cartDefaultConnector = hConnectCart; DbDisconnect cartDefaultDisconnector = hDisconnectCart; static boolean cartDidContentType = FALSE; struct slPair *httpHeaders = NULL; // A list of headers to output before the content-type static void hashUpdateDynamicVal(struct hash *hash, char *name, void *val) /* Val is a dynamically allocated (freeMem-able) entity to put * in hash. Override existing hash item with that name if any. * Otherwise make new hash item. */ { @@ -2719,74 +2720,83 @@ } void cartSetLastPosition(struct cart *cart, char *position, struct hash *oldVars) /* If position and oldVars are non-NULL, and oldVars' position is different, add it to the cart * as lastPosition. This is called by cartHtmlShell{,WithHead} but not other cart openers; * it should be called after cartGetPosition or equivalent. */ { if (position != NULL && oldVars != NULL) { struct hashEl *oldPos = hashLookup(oldVars, positionCgiName); if (oldPos != NULL && differentString(position, oldPos->val)) cartSetString(cart, "lastPosition", oldPos->val); } } +static void cartGenericStartup(struct cart *cart) +/* generic startup code to initialize settings from the cart when using either -WithHead or -MaybeContent cartShell functions */ +{ +setThemeFromCart(cart); +googleAnalyticsSetGa4Key(); + +int verbose = cgiOptionalInt("verbose", -1); +if (verbose != -1) + verboseSetLevel(verbose); +} + void cartHtmlShellWithHead(char *head, char *title, void (*doMiddle)(struct cart *cart), char *cookieName, char **exclude, struct hash *oldVars) /* Load cart from cookie and session cgi variable. Write web-page * preamble including head and title, call doMiddle with cart, and write end of web-page. * Exclude may be NULL. If it exists it's a comma-separated list of * variables that you don't want to save in the cart between * invocations of the cgi-script. */ { struct cart *cart; char *db, *org, *pos; char titlePlus[2048]; pushWarnHandler(cartEarlyWarningHandler); cart = cartAndCookie(cookieName, exclude, oldVars); getDbAndGenome(cart, &db, &org, oldVars); pos = cartGetPosition(cart, db, NULL); pos = addCommasToPos(db, stripCommas(pos)); cartSetLastPosition(cart, pos, oldVars); safef(titlePlus, sizeof(titlePlus), "%s %s %s %s", org ? trackHubSkipHubName(org) : "", db ? db : "", pos ? pos : "", title); popWarnHandler(); -setThemeFromCart(cart); -googleAnalyticsSetGa4Key(); +cartGenericStartup(cart); htmStartWithHead(stdout, head, titlePlus); cartWarnCatcher(doMiddle, cart, htmlVaWarn); cartCheckout(&cart); cartFooter(); } static void cartEmptyShellMaybeContent(void (*doMiddle)(struct cart *cart), char *cookieName, char **exclude, struct hash *oldVars, boolean doContentType) /* Get cart and cookies and set up error handling. * If doContentType, print out Content-type:text/html * but don't start writing any html yet. * The doMiddleFunction has to call cartHtmlStart(title), and * cartHtmlEnd(), as well as writing the body of the HTML. * oldVars - those in cart that are overlayed by cgi-vars are * put in optional hash oldVars. */ { struct cart *cart = cartAndCookieWithHtml(cookieName, exclude, oldVars, doContentType); -setThemeFromCart(cart); -googleAnalyticsSetGa4Key(); +cartGenericStartup(cart); cartWarnCatcher(doMiddle, cart, cartEarlyWarningHandler); cartCheckout(&cart); } void cartEmptyShell(void (*doMiddle)(struct cart *cart), char *cookieName, char **exclude, struct hash *oldVars) /* Get cart and cookies and set up error handling, but don't start writing any * html yet. The doMiddleFunction has to call cartHtmlStart(title), and * cartHtmlEnd(), as well as writing the body of the HTML. * oldVars - those in cart that are overlayed by cgi-vars are * put in optional hash oldVars. */ { cartEmptyShellMaybeContent(doMiddle, cookieName, exclude, oldVars, TRUE); }