a2e996babf1ad91f08f6a1a3ceca8ec9af0fe2cf
max
  Thu Apr 19 16:16:58 2012 -0700
changed almost all html in pubs hgc page to get rid of unnecessary tables (this part does not conform to kent style but really looks better)
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index b2a0cf1..3616e83 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -28,57 +28,190 @@
       "intro", "methods",
       "results", "discussion",
       "conclusions", "ack",
       "refs", "unknown" };
 //
 // whether a checkbox is checked by default, have to correspond to pubsSecNames
 static int pubsSecChecked[] ={
       1, 1,
       1, 1,
       1, 1,
       1, 0,
       0, 1 };
 
 static char* pubsSequenceTable;
 
+
+/* ------  START based on QA's suggestions, functions to replace old HTML tables */
+
+
+/* Suffix -S for  "function accepts style parameter"
+ * Suffix -C for  "function accepts class parameter"
+ * Suffix -CI for "function accepts class and id parameter"
+ */
+
+static void web2Start(char* tag)
+{
+printf("<%s>\n", tag);
+}
+
+static void web2End(char* tag)
+{
+printf("</%s>\n", tag);
+}
+
+static void web2StartS(char* style, char* tag)
+{
+printf("<%s style=\"%s\">\n", tag, style);
+}
+
+static void web2StartC(char* class, char* tag)
+{
+printf("<%s class=\"%s\">\n", tag, class);
+}
+
+static void web2StartCI(char* class, char* id, char* tag)
+{
+if ((id==NULL) && (class==NULL))
+    web2Start(tag);
+else if (id==NULL)
+    web2StartC(class, tag);
+else
+    printf("<%s class=\"%s\" id=\"%s\">\n", tag, class, id);
+}
+
+static void web2PrintS(char* style, char* tag, char* label)
+{
+printf("<%s style=\"%s\">%s</%s>\n", tag, style, label, tag);
+}
+
+//static void web2PrintC(char* class, char* tag, char* label)
+//{
+//printf("<%s class=\"%s\">%s</%s>\n", tag, class, label, tag);
+//}
+
+//static void web2Print(char* tag, char* label)
+//{
+//printf("<%s>%s</%s>\n", tag, label, tag);
+//}
+
+static void web2StartTableC(char* class)             { web2StartC(class, "table"); }
+
+static void web2StartTheadC(char* class)             { web2StartC(class, "thead"); }
+static void web2EndThead()                           { web2End("thead"); }
+
+static void web2StartTbodyS(char* style)             { web2StartS(style, "tbody"); }
+
+static void web2StartCell()                          { web2Start("td"); }
+static void web2EndCell()                            { web2End("td"); }
+static void web2StartCellS(char* style)              { web2StartS(style, "td"); }
+//static void web2PrintCell(char* label)               { web2Print("td", label); }
+static void web2PrintCellS(char* style, char *label) { web2PrintS(style, "td", label); }
+
+static void web2StartRow()                           { web2Start("tr"); }
+static void web2EndRow()                             { web2End("tr"); }
+
+//static void web2StartTbody()                         { web2Start("tbody"); }
+static void web2EndTbody()                           { web2End("tbody"); }
+
+//static void web2StartTable()                         { web2Start("table"); }
+static void web2EndTable()                           { web2EndTbody(); web2End("table"); }
+
+static void web2StartDivCI(char* class, char* id)    { web2StartCI(class, id, "div"); }
+static void web2StartDivC(char* class)               { web2StartC(class, "div"); }
+
+static void web2EndDiv(char* comment) 
+{
+printf("</div> <!-- %s -->\n", comment);
+}
+
+static void web2PrintHeaderCell(char *label, int width)
+/* Print th heading cell with given width in percent */
+{
+printf("<th width=\"%d%%\">", width);
+printf("%s</th>", label);
+}
+
+static void web2PrintCellF(char* format, ...)
+/* print a td with format */
+{
+va_list args;
+va_start(args, format);
+
+web2StartCell();
+vprintf(format, args);
+web2EndCell();
+va_end(args);
+}
+
+
+
+static void web2StartSection(char* id, char* format, ...)
+/* create a new section on the web page */
+{
+va_list args;
+va_start(args, format);
+
+puts("<!-- START NEW SECTION -->\n");
+web2StartDivCI("section", id);
+web2StartDivC("subheadingBar windowSize");
+vprintf(format, args);
+web2EndDiv("subheadingBar");
+va_end(args);
+}
+
+static void web2EndSection()
+/* end section */
+{
+web2EndDiv("section");
+}
+
+/* ------  END based on QA's suggestions, functions to replace old HTML tables */
+
 static char* mangleUrl(char* url) 
 /* add publisher specific parameters to url and return new url*/
 {
 if (!stringIn("sciencedirect.com", url))
     return url;
     
 // cgi param to add the "UCSC matches" sciverse application to elsevier's sciencedirect
 char* sdAddParam = "?svAppaddApp=298535"; 
 char* longUrl = catTwoStrings(url, sdAddParam);
 char* newUrl = replaceChars(longUrl, "article", "svapps");
 return newUrl;
 }
 
 static void printFilterLink(char* pslTrack, char* articleId, char* articleTable)
 /* print a link to hgTracks with an additional cgi param to activate the single article filter */
 {
     int start = cgiInt("o");
     int end = cgiInt("t");
     char qBuf[1024];
     struct sqlConnection *conn = hAllocConn(database);
     safef(qBuf, sizeof(qBuf), "SELECT CONCAT(firstAuthor, year) FROM %s WHERE articleId='%s';", articleTable, articleId);
     char* dispId = sqlQuickString(conn, qBuf);
 
-    printf("<P><A HREF=\"%s&amp;db=%s&amp;position=%s%%3A%d-%d&amp;pubsFilterArticleId=%s&amp;%s=pack&amp;hgFind.matches=%s\">",
+    printf(
+        "      <div class=\"subsection\">");
+    printf(
+        "      <P><A HREF=\"%s&amp;db=%s&amp;position=%s%%3A%d-%d&amp;pubsFilterArticleId=%s&amp;%s=pack&amp;hgFind.matches=%s\">",
                       hgTracksPathAndSettings(), database, seqName, start+1, end, articleId, pslTrack, dispId);
+
     printf("Show these sequence matches individually on genome browser</A> (activates track \""
         "Individual matches for article\")</P>");
+    printf(
+        "      </div> <!-- class: subsection --> \n");
     hFreeConn(&conn);
     
 }
 
 static char* makeSqlMarkerList(void)
 /* return list of sections from cgi vars, format like "'abstract','header'" */
 {
 int secCount = sizeof(pubsSecNames)/sizeof(char *);
 struct slName* names = NULL;
 int i;
 for (i=0; i<secCount; i++) 
 {
     // add ' around name and add to list
     char* secName = pubsSecNames[i];
     if (cgiOptionalInt(secName, pubsSecChecked[i]))
@@ -295,41 +428,43 @@
 int i;
 
 struct hash *seqIdHash = NULL;
 seqIdHash = newHash(0);
 for (i=0; i<partCount; i++) 
     {
     hashAdd(seqIdHash, seqIdCoords[i], NULL);
     }
 return seqIdHash;
 }
 
 
 static void printSeqHeaders(bool showDesc, bool isClickedSection) 
 /* print table and headers */
 {
-printf("<TABLE style=\"margin: 10px auto; width: 98%%\" class=\"stdTbl\">\n");
-printf("<THEAD style=\"background-color: #fcecc0\">\n");
+//style=\"margin: 10px auto; width: 98%%\"style=\"background-color: #fcecc0\"
+web2StartTableC("stdTbl centeredStdTbl");
+web2StartTheadC("stdTblHead");
 if (showDesc)
-    puts("  <TH style=\"width: 10%\">Article file</TH>\n");
-puts("  <TH style=\"width: 60%\">One row per sequence, with flanking text, sequence in bold</TH>\n");
+    web2PrintHeaderCell("Article file", 10);
+web2PrintHeaderCell("One row per sequence, with flanking text, sequence in bold", 60);
 if (pubsDebug)
-    puts("  <TH style=\"width: 30%\">Identifiers</TH>\n");
+    web2PrintHeaderCell("Identifiers", 30);
 
 if (!isClickedSection && !pubsDebug)
-    puts("  <TH style=\"width: 20%\">Chained matches with this sequence</TH>\n");
-puts("</THEAD>\n");
+    web2PrintHeaderCell("Chained matches with this sequence", 20);
+web2EndThead();
+web2StartTbodyS("font-family: Arial, Helvetica, sans-serif; line-height: 1.5em; font-size: 0.9em;");
 }
 
 static void printAddWbr(char* text, int distance) 
 /* a crazy hack for firefox/mozilla that is unable to break long words in tables
  * We need to add a <wbr> tag every x characters in the text to make text breakable.
  */
 {
 int i;
 i = 0;
 char* c;
 c = text;
 bool doNotBreak = FALSE;
 while (*c != 0) 
     {
     if ((*c=='&') || (*c=='<'))
@@ -367,176 +502,180 @@
 void printGbLinks(struct slName* locs) 
 /* print hash keys in format hg19/chr1:1-1000 as links */
 {
 struct slName *el;
 for (el = locs; el != NULL; el = el->next) 
     {
     char* locString = el->name;
     char* db       = cloneNextWordByDelimiter(&locString, '/');
     char* chrom    = cloneNextWordByDelimiter(&locString, ':');
     char* startStr = cloneNextWordByDelimiter(&locString, '-');
     char* endStr   = cloneString(locString);
 
     int start = atoi(startStr);
     int end = atoi(endStr);
     printHgTracksLink(db, chrom, start, end, NULL, NULL);
-    printf("<BR>");
+    printf("<br>");
     freeMem(endStr); //XX why can't I free these?
     freeMem(chrom);
     freeMem(startStr);
     freeMem(db);
     }
 }
 
+
+
+
 static bool printSeqSection(char* articleId, char* title, bool showDesc, struct sqlConnection* conn, struct hash* clickedSeqs, bool isClickedSection, bool fasta, char* pslTable, char* articleTable)
-/* print a table of sequences, show only sequences with IDs in hash,
+/* print a section with a table of sequences, show only sequences with IDs in hash,
  * There are two sections, respective sequences are shown depending on isClickedSection and clickedSeqs 
  *   - seqs that were clicked on (isClickedSection=True) -> show only seqs in clickedSeqs
  *   - other seqs (isClickedSection=False) -> show all other seqs
  * 
  * */
 {
 // get data from mysql
 char query[4096];
 safef(query, sizeof(query), 
 "SELECT fileDesc, snippet, locations, articleId, fileId, seqId, sequence "
 "FROM %s WHERE articleId='%s';", pubsSequenceTable, articleId);
 if (pubsDebug)
     puts(query);
 struct sqlResult *sr = sqlGetResult(conn, query);
 
 // construct title for section
 char* otherFormat = NULL;
 if (fasta)
     otherFormat = "table";
 else
     otherFormat = "fasta";
 
 char fullTitle[5000];
 safef(fullTitle, sizeof(fullTitle), 
-"%s&nbsp;<A HREF=\"../cgi-bin/hgc?%s&o=%s&t=%s&g=%s&i=%s&fasta=%d\"><SMALL>(%s format)</SMALL></A>", 
+"%s&nbsp;<A HREF=\"../cgi-bin/hgc?%s&o=%s&t=%s&g=%s&i=%s&fasta=%d\"><SMALL>(%s format)</SMALL></A>\n", 
 title, cartSidUrlString(cart), cgiString("o"), cgiString("t"), cgiString("g"), cgiString("i"), 
 !fasta, otherFormat);
 
-webNewSection("%s", fullTitle);
+web2StartSection("pubsSection", "%s", fullTitle);
 
+// print filtering link at start of table & table headers
 if (isClickedSection)
-    {
     printFilterLink(pslTable, articleId, articleTable);
-    printf("</TD></TR>");
-    }
-else
-    printf("</TD><TR><TD>");
 
 if (!fasta) 
     printSeqHeaders(showDesc, isClickedSection);
 
+// output rows
 char **row;
 bool foundSkippedRows = FALSE;
 while ((row = sqlNextRow(sr)) != NULL)
     {
     char* fileDesc = row[0];
     char* snippet  = row[1];
     char* locString= row[2];
     char* artId    = row[3];
     char* fileId   = row[4];
     char* seqId    = row[5];
     char* seq      = row[6];
 
     // annotation (=sequence) ID is a 64 bit int with 10 digits for 
     // article, 3 digits for file, 5 for annotation
     char annotId[100];
     safef(annotId, 100, "%010d%03d%05d", atoi(artId), atoi(fileId), atoi(seqId));
     if (pubsDebug)
         printf("%s", annotId);
 
     // only display this sequence if we're in the right section
     if (clickedSeqs!=NULL && ((hashLookup(clickedSeqs, annotId)!=NULL) != isClickedSection)) {
         foundSkippedRows = TRUE;
         continue;
     }
 
-    printf("<TBODY style=\"font-family: Arial, Helvetica, sans-serif; line-height: 1.5em; font-size: 0.9em;\">");
-
     if (fasta)
-        printf("<TR><TD><TT>>%s<BR>%s<BR></TT></TD></TR></TABLE>", annotId, seq);
+        printf(">%s<br>%s<br>", annotId, seq);
     else
         {
-        printf("<TR>\n");
+        web2StartRow();
+
+        // column 1: type of file (main or supp)
         if (showDesc)
-            printf("<TD style=\"word-break:break-all\">%s\n", fileDesc);
-        //printf("<TD>%s</I></TD>\n", snippet); 
-        printf("<TD style=\"word-break:break-all;\">");
+            web2PrintCellS(fileDesc, "word-break:break-all");
+        
+        // column 2: snippet
+        web2StartCellS("word-break:break-all");
         printAddWbr(snippet, 40);
-        printf("</I></TD>\n"); 
+        web2EndCell();
+
+        // optional debug info column
         if (pubsDebug) 
-            printf("<TD>article %s, file %s, seq %s, annotId %s", artId, fileId, seqId, annotId);
+            web2PrintCellF("article %s, file %s, seq %s, annotId %s", artId, fileId, seqId, annotId);
 
-        // print links to locations 
+        // column 3: print links to locations, only print this in the 2nd section
         if (!isClickedSection && !pubsDebug) 
             {
             // format: hg19/chr1:300-400,mm9/chr1:60006-23234
             // split on "," then split on "/"
             //locs = charSepToSlNames(locString, ',');
 
+            web2StartCell();
             char* locArr[1024];
             int partCount = chopString(locString, ",", locArr, ArraySize(locArr));
-            printf("<TD>");
             if (partCount==0)
                 printf("No matches");
             else
                 {
                 struct slName *locs;
                 locs = slNameListFromStringArray(locArr, partCount);
                 slUniqify(&locs, slNameCmp, slNameFree);
                 printGbLinks(locs);
-                printf("<BR>");
-                printf("</TD>\n");
+                printf("<br>");
                 slFreeList(&locs);
                 }
-
+            web2EndCell();
             }
-        printf("</TR>\n");
+        web2EndRow();
         }
     }
-printf("</TR></TBODY></TABLE>\n"); // finish section
 
-webEndSectionTables();
+if (!fasta)
+    web2EndTable();
+
+web2EndSection();
 sqlFreeResult(&sr);
 return foundSkippedRows;
 }
 
 static void printSeqInfo(struct sqlConnection* conn, char* trackTable,
     char* pslTable, char* articleId, char* item, char* seqName, int start, 
     bool fileDesc, bool fasta, char* articleTable)
     /* print sequences, split into two sections 
      * two sections: one for sequences that were clicked, one for all others*/
 {
 struct hash* clickedSeqs = getSeqIdHash(conn, trackTable, articleId, item, seqName, start);
 
 bool skippedRows;
 if (clickedSeqs) 
     skippedRows = printSeqSection(articleId, "Sequences used to construct this feature", \
         fileDesc, conn, clickedSeqs, 1, fasta, pslTable, articleTable);
 else 
     skippedRows=1;
 
 if (skippedRows)
     printSeqSection(articleId, "Other Sequences in this article", \
         fileDesc, conn, clickedSeqs, 0, fasta, pslTable, articleTable);
 if (pubsIsElsevier)
-    printf("<P><SMALL>Copyright 2012 Elsevier B.V. All rights reserved.</SMALL><P>");
+    printf("<P><SMALL>Copyright 2012 Elsevier B.V. All rights reserved.</SMALL></P>");
 freeHash(&clickedSeqs);
 }
 
 static void printTrackVersion(struct trackDb *tdb, struct sqlConnection* conn, char* item) 
 {
 char versionString[256];
 char dateReference[256];
 char headerTitle[512];
 /* see if hgFixed.trackVersion exists */
 boolean trackVersionExists = hTableExists("hgFixed", "trackVersion");
 
 if (trackVersionExists)
     {
     char query[256];
     safef(query, sizeof(query), \