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("" "\n" + "" "\n" + "" "\n" + "" "\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(""); else puts(""); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) puts( "" "\n" "" "\n" ); printf("\t%s\n", headerText); - printf("\t" "\n" - "\t" "\n" - "\t" "\n" - "\t" "\n" - "\t" - ); + 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(" \n "); webIncludeResourceFile("HGStyle.css"); if (extraStyle != NULL) puts(extraStyle); printf("\n"); printBodyTag(stdout); htmlWarnBoxSetup(stdout);// Sets up a warning box which can be filled with errors as they occur puts(commonCssStyles()); } -puts( - "" "\n" - "" "\n" - "" "\n"); +webStartSectionTables(); if (withLogo) { puts("\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) - "" "\n" - "
"); if (isEncode) { puts("" "\"ENCODE" ""); puts("\"ENCODE"); } else { puts(""); } @@ -250,48 +256,31 @@ " " "" "" "
\n" - "
" - " \n" - "
\n" - "
\n" - "
" - ); - htmlTextOut(textOutBuf); - - puts("
\n" - " " - "\n" - "
 \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" "
" "\n" // "
" "
" "\n" "
" "\n" " " ); puts("
"); } +void webStartSectionTables() +/* Put up start of nepharious table layout stuff. (Normally done by webStartWrap). */ +{ +puts( + "" "\n" + "" "\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) + "" "\n" + "
\n" + "
" + " \n" + "
\n" + "
\n" + "
" + ); +htmlTextOut(title); + +puts("
\n" + " " + "\n" + "
 \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("
"); puts(""); puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) "
\n\n" " \n" "
\n" "
\n"); if (hasTitle)