6e2e27d593cd3c4bdaddb5e5634b7d1f2196a6e6 max Thu Oct 4 15:59:08 2012 -0700 adding logos to article pages (preparing for upcoming license change by elsevier) diff --git src/hg/hgc/pubs.c src/hg/hgc/pubs.c index ccf6f9b..be6da5a 100644 --- src/hg/hgc/pubs.c +++ src/hg/hgc/pubs.c @@ -345,30 +345,44 @@ 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 */ +{ +// get top-level domain +char url[1024]; +memcpy(url, urlOrig, 1024); +char *urlParts[20]; +int partCount = chopString(url, ".", urlParts, ArraySize(urlParts)); +// construct path +char *logoUrl = needMem(1024); +safef(logoUrl, 1024, "../images/pubs_%s.png", urlParts[partCount-2]); +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 FROM %s WHERE articleId='%s'", pubsArticleTable, item); struct sqlResult *sr = sqlGetResult(conn, query); char **row; char *articleId=NULL; if ((row = sqlNextRow(sr)) == NULL) { printf("Could not resolve articleId %s, this is an internal error.\n", item); printf("Please send an email to max@soe.ucsc.edu\n"); sqlFreeResult(&sr); @@ -382,38 +396,49 @@ char *cit = row[4]; char *abstract = row[5]; char *pmid = row[6]; url = mangleUrl(url); if (strlen(abstract)==0) abstract = "(No abstract available for this article. " "Please follow the link to the fulltext above.)"; if (stringIn("sciencedirect.com", url)) { pubsHasSupp = FALSE; pubsIsElsevier = TRUE; } +// logo of publisher +char *logoUrl = urlToLogoUrl(url); +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></A>\n", url, title); +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) + printf("<P><SMALL>Copyright 2012 Elsevier B.V. All rights reserved.</SMALL></P>"); + sqlFreeResult(&sr); return articleId; } static struct hash *getSeqIdHash(struct sqlConnection *conn, char *trackTable, \ char *articleId, char *item, char *seqName, int start) /* return a hash with the sequence IDs for a given chain of BLAT matches */ { char query[512]; /* check first if the column exists (some debugging tables on hgwdev don't have seqIds) */ safef(query, sizeof(query), "SHOW COLUMNS FROM %s LIKE 'seqIds';", trackTable); char *seqIdPresent = sqlQuickString(conn, query); if (!seqIdPresent) { return NULL; } @@ -653,32 +678,30 @@ /* 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>"); 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), \