eceab39324ced4bdcd632fe7a8ea41582d25701a
max
  Wed May 1 14:06:49 2013 -0700
handling explicitly specified publisher names, adding the missing nature logo
diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c
index b5d8b66..e53e6df 100644
--- src/hg/hgc/pubs.c
+++ src/hg/hgc/pubs.c
@@ -15,31 +15,32 @@
 //include "hgTrackUi.h"
 
 // cgi var to activate debug output
 static int pubsDebug = 0;
 
 // global var for printArticleInfo to indicate if article has suppl info 
 // Most publishers have supp data
 bool pubsHasSupp = TRUE; 
 // global var for printArticleInfo to indicate if article is elsevier
 bool pubsIsElsevier = FALSE; 
 // the article source is used to modify other parts of the page
 static char* articleSource;
 // we need the external article PMC Id for yif links
 static char* extId = NULL;
 
-// internal section types in mysql table
+// section types in mysql table, for all annotations tables
+// we note where the hit is located in the document
 static char *pubsSecNames[] ={
       "header", "abstract",
       "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 };
 
@@ -378,41 +379,65 @@
     printf("<SMALL>%s</SMALL>; ", authors);
     printf("<SMALL>%s ", citation);
     if (!isEmpty(pmid) && strcmp(pmid, "0")!=0 )
         printf(", <A HREF=\"http://www.ncbi.nlm.nih.gov/pubmed/%s\">PMID%s</A>\n", pmid, pmid);
     printf("</SMALL><BR>\n");
     if (pubsDebug)
         printf("articleId=%s", articleId);
     printf("<I>%s</I><P>", snippets);
     printf("<HR>");
     }
 
 freeMem(sectionList);
 sqlFreeResult(&sr);
 }
 
-static char *urlToLogoUrl(char *urlOrig)
-/* return a string with relative path of logo for publisher given the url of fulltext, has to be freed */
+static char *urlToLogoUrl(struct sqlConnection *conn, char* pubsArticleTable, 
+    char* articleId, char *urlOrig)
+/* return a string with relative path of logo for publisher given the url of
+ * fulltext or a table/articleId, has to be freed 
+*/
+{
+char* pubCode = NULL;
+if (hHasField("hgFixed", pubsArticleTable, "publisher"))
+    {
+    char query[4000];
+    safef(query, sizeof(query), "SELECT publisher from %s where articleId=%s", 
+        pubsArticleTable, articleId);
+    pubCode = sqlQuickString(conn, query);
+    }
+else 
 {
-// get top-level domain
+    // get top-level domain url if not publisher field
 char url[1024];
 memcpy(url, urlOrig, sizeof(url));
-char *urlParts[20];
-int partCount = chopString(url, ".", urlParts, ArraySize(urlParts));
-// construct path
-char *logoUrl = needMem(sizeof(url));
-safef(logoUrl, sizeof(url), "../images/pubs_%s.png", urlParts[partCount-2]);
+    char *slashParts[20];
+    // split http://www.sgi.com/test -> to [http:,www.sgi.com,test]
+    int partCount = chopString(url, "/", slashParts, ArraySize(slashParts));
+    if (partCount<3)
+        return NULL;
+    // split www.sgi.com to [www,sgi,com]
+    char *dotParts[20];
+    partCount = chopString(slashParts[1], ".", dotParts, ArraySize(dotParts));
+    if (partCount<3)
+        return NULL;
+    pubCode = dotParts[partCount-2];
+    }
+    
+// construct path to image
+char *logoUrl = needMem(512);
+safef(logoUrl, 512, "../images/pubs_%s.png", pubCode);
 return logoUrl;
 }
 
 static char *printArticleInfo(struct sqlConnection *conn, char *item, char *pubsArticleTable)
 /* Header with information about paper, return documentId */
 {
 char query[512];
 
 safef(query, sizeof(query), "SELECT articleId, url, title, authors, citation, abstract, pmid, "
     "source, extId FROM %s WHERE articleId='%s'", pubsArticleTable, item);
 
 struct sqlResult *sr = sqlGetResult(conn, query);
 char **row;
 char *articleId=NULL;
 if ((row = sqlNextRow(sr)) == NULL)
@@ -424,40 +449,41 @@
     }
 
 articleId = cloneString(row[0]);
 char *url      = row[1];
 char *title    = row[2];
 char *authors  = row[3];
 char *cit      = row[4];
 char *abstract = row[5];
 char *pmid     = row[6];
 articleSource  = row[7];
 extId          = row[8];
 
 url = mangleUrl(url);
 if (strlen(abstract)==0) 
         abstract = "(No abstract available for this article. "
-            "Please follow the link to the fulltext above.)";
+            "Please follow the link to the fulltext above by clicking on the titel or the fulltext image.)";
 
 if (stringIn("sciencedirect.com", url)) 
     {
     pubsHasSupp = FALSE;
     pubsIsElsevier = TRUE;
     }
 
 // logo of publisher
-char *logoUrl = urlToLogoUrl(url);
+char *logoUrl = urlToLogoUrl(conn, pubsArticleTable, articleId, url);
+if (logoUrl)
 printf("<a href=\"%s\"><img align=\"right\" hspace=\"20\" src=\"%s\"></a>\n", url, logoUrl);
 freeMem(logoUrl);
 
 printf("<P>%s</P>\n", authors);
 printf("<A TARGET=\"_blank\" HREF=\"%s\"><B>%s</B>\n", url, title);
 printf("</A>\n");
 
 
 printf("<P style=\"width:800px; font-size:80%%\">%s", cit);
 if (strlen(pmid)!=0 && strcmp(pmid, "0"))
     printf(", <A HREF=\"http://www.ncbi.nlm.nih.gov/pubmed/%s\">PMID%s</A>\n", pmid, pmid);
 printf("</P>\n");
 printf("<P style=\"width:800px; font-size:100%%\">%s</P>\n", abstract);
 
 if (pubsIsElsevier)