384695a6009b3ac64e0205d6a5cd8bc02269d149 larrym Thu Jun 7 13:40:35 2012 -0700 support browser.style diff --git src/hg/lib/cart.c src/hg/lib/cart.c index 4371e6c..6e89d2d 100644 --- src/hg/lib/cart.c +++ src/hg/lib/cart.c @@ -1514,57 +1514,58 @@ popWarnHandler(); } void setThemeFromCart(struct cart *cart) /* If 'theme' variable is set in cart: overwrite background with the one * defined for this theme in hg.conf. Also set the "styleTheme", with additional * styles that can overwrite the main style settings * config syntax in hg.conf is: * browser.theme.= * or: * browser.theme.=, * */ { // get theme from cart and use it to get style/background file from config char *cartTheme = cartOptionalString(cart, "theme"); -if (cartTheme==NULL) - return; +// XXXX which setting should take precedence? Currently browser.theme does. + +char *styleFile = cfgOption("browser.style"); +if(styleFile != NULL) + { + char buf[512]; + safef(buf, sizeof(buf), "", styleFile); + char *copy = cloneString(buf); + htmlSetStyleTheme(copy); // for htmshell.c, used by hgTracks + webSetStyle(copy); // for web.c, used by hgc + } + +if(isNotEmpty(cartTheme)) + { char *themeKey = catTwoStrings("browser.theme.", cartTheme); -char *themeDefLine = cfgOption(themeKey); + styleFile = cfgOption(themeKey); freeMem(themeKey); -if (themeDefLine == NULL) + if (isEmpty(styleFile)) return; -// set style file -char * styleFile = cloneString(themeDefLine); -chopSuffixAt(styleFile, ','); -if (strlen(styleFile)==0) - return; char * link = webTimeStampedLinkToResourceOnFirstCall(styleFile,TRUE); // resource file link wrapped in html if (link!=NULL) { htmlSetStyleTheme(link); // for htmshell.c, used by hgTracks webSetStyle(link); // for web.c, used by hgc } - -// set background file (optional, after ',' in hg.conf line) -if (! stringIn(",", themeDefLine)) - return; -char * backgroundFile = cloneString(themeDefLine); -backgroundFile = chopPrefixAt(backgroundFile, ','); -htmlSetBackground(backgroundFile); + } } 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);