7d00e349c4438a7b7aa63ffe0f5d74ac075211ea larrym Tue May 8 11:39:59 2012 -0700 fix problem in setThemeFromCart (assumed order of style, background didn't match what was in hg.conf (#7867) diff --git src/hg/lib/cart.c src/hg/lib/cart.c index bebf67d..e8a1c8e 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -1507,59 +1507,71 @@ void cartHtmlEnd() /* Write out HTML footer and get rid or error handler. */ { if (inWeb) webEnd(); /* this does googleAnalytics for a lot of CGIs */ else cartFooter(); popWarnHandler(); } void setThemeFromCart(struct cart *cart) /* If 'theme' variable is set in cart: overwrite background with the one from * defined for this theme Also set the "styleTheme", with additional styles * that can overwrite the main style settings */ { -// get theme from cart and use it to get background file from config +// Get theme from cart and use it to get background file from config; +// format is browser.theme.=[,] + +char **options; +int optionCount; char *cartTheme = cartOptionalString(cart, "theme"); if (cartTheme==NULL) return; char *themeKey = catTwoStrings("browser.theme.", cartTheme); char *themeDefLine = cfgOption(themeKey); -freeMem(themeKey); +freez(&themeKey); if (themeDefLine == NULL) return; -char * background = cloneString(themeDefLine); -chopSuffixAt(background, ','); -htmlSetBackground(background); - -// set css style (optional, after ',' in hg.conf line) -if (! stringIn(",", themeDefLine)) +sqlStringDynamicArray(themeDefLine, &options, &optionCount); +if(options == NULL) return; -char * styleFile = cloneString(themeDefLine); -styleFile = chopPrefixAt(styleFile, ','); +char *styleFile = options[0]; +if(isNotEmpty(styleFile)) + { char * link = webTimeStampedLinkToResourceOnFirstCall(styleFile,TRUE); // resource file link wrapped in html if (link) { htmlSetStyleTheme(link); // for htmshell.c, used by hgTracks webSetStyle(link); // for web.c, used by hgc } } +if(optionCount >= 2) + { + char *background = options[1]; + if(isNotEmpty(background)) + htmlSetBackground(background); + } + +freeMem(options[0]); +freez(&options); +} + 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, *clade=NULL; char titlePlus[128]; char extra[128]; pushWarnHandler(cartEarlyWarningHandler); cart = cartAndCookie(cookieName, exclude, oldVars); getDbAndGenome(cart, &db, &org, oldVars);