fd4ad89497897588748069e8d181d3cb78ab7496 kent Fri Feb 13 13:20:28 2015 -0800 Refactored a few routines out of the webStartInternal demon for reuse in cdwWebBrowse. diff --git src/hg/lib/web.c src/hg/lib/web.c index 1040c8d..f78ac63 100644 --- src/hg/lib/web.c +++ src/hg/lib/web.c @@ -78,30 +78,41 @@ void webPopErrHandlers(void) /* Pop warn and abort handler for errAbort(). */ { popWarnHandler(); hDumpStackPopAbortHandler(); popAbortHandler(); } void webSetStyle(char *style) /* set a style to add to the header */ { extraStyle = style; } +void webPragmasEtc() +/* Print out stuff that tells people not to cache us, and that we use the + * usual character set and scripting langauge. (Normally done by webStartWrap) */ +{ +printf("<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;CHARSET=iso-8859-1\">" "\n" + "<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\">" "\n" + "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" "\n" + "<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">" "\n" + ); +} + void webStartText() /* output the head for a text page */ { /*printf("Content-Type: text/plain\n\n");*/ webHeadAlreadyOutputed = TRUE; webInTextMode = TRUE; webPushErrHandlers(); } static void webStartWrapperDetailedInternal(struct cart *theCart, char *db, char *headerText, char *textOutBuf, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ @@ -154,64 +165,59 @@ { char *newString, *ptr1, *ptr2; char *browserVersion; if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8') puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"); else puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " "\"http://www.w3.org/TR/html4/loose.dtd\">"); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) puts( "<HTML>" "\n" "<HEAD>" "\n" ); printf("\t%s\n", headerText); - printf("\t<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;CHARSET=iso-8859-1\">" "\n" - "\t<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\">" "\n" - "\t<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" "\n" - "\t<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">" "\n" - "\t<TITLE>" - ); + webPragmasEtc(); + + printf("\t<TITLE>"); + /* we need to take any HTML formatting out of the titlebar string */ newString = cloneString(textOutBuf); for(ptr1=newString, ptr2=textOutBuf; *ptr2 ; ptr2++) { if (*ptr2 == '<') { for(; *ptr2 && (*ptr2 != '>'); ptr2++) ; } else *ptr1++ = *ptr2; } *ptr1 = 0; htmlTextOut(newString); printf(" </TITLE>\n "); webIncludeResourceFile("HGStyle.css"); if (extraStyle != NULL) puts(extraStyle); printf("</HEAD>\n"); printBodyTag(stdout); htmlWarnBoxSetup(stdout);// Sets up a warning box which can be filled with errors as they occur puts(commonCssStyles()); } -puts( - "<A NAME=\"TOP\"></A>" "\n" - "" "\n" - "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100%\">" "\n"); +webStartSectionTables(); if (withLogo) { puts("<TR><TH COLSPAN=1 ALIGN=\"left\">"); if (isEncode) { puts("<A HREF=\"http://www.genome.gov/10005107\" TARGET=\"_BLANK\">" "<IMG SRC=\"../images/ENCODE_scaleup_logo.png\" height=50 ALT=\"ENCODE Project at NHGRI\">" "</A>"); puts("<IMG SRC=\"../images/encodeDcc.jpg\" ALT=\"ENCODE Project at UCSC\">"); } else { puts("<IMG SRC=\"../images/title.jpg\">"); } @@ -250,48 +256,31 @@ "</h3> " "<ul style=\"margin:5px;\">" "<li>Take me back to <a href=\"%s\">%s</a>" "<idiv style=\"float:right;\"><a href=\"../goldenPath/help/genomeEuro.html\">What is this?</a></idiv>" "</li>" "</ul>" "</div>" "</TD></TR>\n" , domain, newUri, source ); } } if(!skipSectionHeader) /* this HTML must be in calling code if skipSectionHeader is TRUE */ { - puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) - "<!-- +++++++++++++++++++++ CONTENT TABLES +++++++++++++++++++ -->" "\n" - "<TR><TD COLSPAN=3>\n" - "<div id=firstSection>" - " <!--outer table is for border purposes-->\n" - " <TABLE WIDTH='100%' BGCOLOR='#" HG_COL_BORDER "' BORDER='0' CELLSPACING='0' " - "CELLPADDING='1'><TR><TD>\n" - " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' BORDER='0' CELLSPACING='0' " - "CELLPADDING='0'><TR><TD>\n" - " <div class='subheadingBar'><div class='windowSize' id='sectTtl'>" - ); - htmlTextOut(textOutBuf); - - puts(" </div></div>\n" - " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0>" - "<TR><TH HEIGHT=10></TH></TR>\n" - " <TR><TD WIDTH=10> </TD><TD>\n\n" - ); + webFirstSection(textOutBuf); }; webPushErrHandlers(); /* set the flag */ webHeadAlreadyOutputed = TRUE; } /* static void webStartWrapperDetailedInternal() */ void webStartWrapperDetailedArgs(struct cart *theCart, char *db, char *headerText, char *format, va_list args, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ { char textOutBuf[1024]; va_list argscp; va_copy(argscp,args); @@ -360,30 +349,61 @@ void webEndSection() /* Close down a section */ { puts( "" "\n" " </TD><TD WIDTH=15></TD></TR></TABLE>" "\n" // "<BR>" " </TD></TR></TABLE>" "\n" " </TD></TR></TABLE>" "\n" " " ); puts("</div>"); } +void webStartSectionTables() +/* Put up start of nepharious table layout stuff. (Normally done by webStartWrap). */ +{ +puts( + "<A NAME=\"TOP\"></A>" "\n" + "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100%\">" "\n"); +} + +void webFirstSection(char *title) +/* Put up the first section (normally done by webStartWrap). */ +{ +puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) + "<!-- +++++++++++++++++++++ CONTENT TABLES +++++++++++++++++++ -->" "\n" + "<TR><TD COLSPAN=3>\n" + "<div id=firstSection>" + " <!--outer table is for border purposes-->\n" + " <TABLE WIDTH='100%' BGCOLOR='#" HG_COL_BORDER "' BORDER='0' CELLSPACING='0' " + "CELLPADDING='1'><TR><TD>\n" + " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' BORDER='0' CELLSPACING='0' " + "CELLPADDING='0'><TR><TD>\n" + " <div class='subheadingBar'><div class='windowSize' id='sectTtl'>" + ); +htmlTextOut(title); + +puts(" </div></div>\n" + " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0>" + "<TR><TH HEIGHT=10></TH></TR>\n" + " <TR><TD WIDTH=10> </TD><TD>\n\n" + ); +} + void webNewSectionHeaderStart(boolean hasTitle) /* Start the header for a new section on the web page. * May be used to maintain table layout without a proper section header */ { webEndSection(); puts("<div>"); puts("<!-- +++++++++++++++++++++ START NEW SECTION +++++++++++++++++++ -->"); puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) "<BR>\n\n" " <!--outer table is for border purposes-->\n" " <TABLE WIDTH='100%' BGCOLOR='#" HG_COL_BORDER "' BORDER='0' CELLSPACING='0' CELLPADDING='1'><TR><TD>\n" " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' BORDER='0' CELLSPACING='0' CELLPADDING='0'><TR><TD>\n"); if (hasTitle)