Skip to content

Commit

Permalink
Merge pull request #202 from apriltuesday/EVA-3462
Browse files Browse the repository at this point in the history
EVA-3462: Support DOIs in study view
  • Loading branch information
apriltuesday authored Jan 11, 2024
2 parents ec2be8f + b003580 commit 3a7ffd0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function (grunt) {
// Metadata.
meta: {
version: {
eva: '4.4.12'
eva: '4.4.13'
},
submissionTemplate: {
version: 'V1.1.5'
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eva-web",
"version": "4.4.12",
"version": "4.4.13",
"homepage": "https://github.com/EBIvariation/eva-web",
"authors": [
"EVA development team <[email protected]>"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "commons",
"version": "4.4.12",
"version": "4.4.13",
"description": "javascript commons",
"repository": {
"type": "git",
Expand Down
34 changes: 24 additions & 10 deletions src/js/eva.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,24 @@ Eva.prototype = {
});
},
_getPublications: function() {
$('.pubmed-id').each(function(i, obj) {
$('.publication-id').each(function(i, obj) {
obj = $(obj);
var pubmedId = obj.html();
obj.html('<p>Attempting to retrieve publication information for PubMed ID <a class="external publication" href="http://europepmc.org/abstract/MED/' + pubmedId + '">' + pubmedId + '...</p>');
if(pubmedId && pubmedId != '-') {
var url = 'https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=ext_id:' + pubmedId + ' src:med&format=json';
var curie = obj.html();
if (curie && curie != '-') {
obj.html('<p>Attempting to retrieve publication information for ' + curie + '...</p>');
var splitCurie = curie.split(":");
if (splitCurie.length < 2) {
var datasource = "PUBMED";
var identifier = splitCurie[0];
} else {
var datasource = splitCurie[0].toUpperCase();
var identifier = splitCurie[1];
}
// Assume this is a PubMed ID or DOI
var url = 'https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=ext_id:' + identifier + ' src:med&format=json';
if (datasource === "DOI") {
url = 'https://www.ebi.ac.uk/europepmc/webservices/rest/search?query=DOI:' + identifier + '&format=json';
}
// Make the actual AJAX call...
$.ajax({
type: 'GET',
Expand All @@ -429,28 +441,30 @@ Eva.prototype = {
success: function (response) {
var data = response.resultList.result[0];
if (data) {
var id = data.id;
var source = data.source;
var title = data.title;
var authors = data.authorString;
var journal = data.journalTitle;
var volume = data.journalVolume;
var year = data.pubYear;
var pages = data.pageInfo;
var pmid = data.pmid;

var paper_output = '<p class="publications"><a class="external publication" href="http://europepmc.org/abstract/MED/' + pmid + '">' + title + '</a><br />';
var paper_output = '<p class="publications"><a class="external publication" href="http://europepmc.org/abstract/' + source + '/' + id + '">' + title + '</a><br />';
paper_output += authors + '<br />';
paper_output += '<em>' + journal + '</em> <strong>' + volume + '</strong>:' + year + ' ' + pages + '</p>';
obj.html(paper_output);
}
},
error: function (x, y, z) {
obj.html('PubMed:<a class="external publication" href="http://www.ncbi.nlm.nih.gov/pubmed/?term=' + pubmedId + '" target="_blank">' + pubmedId + '</a><br />');
// Don't necessarily know where this CURIE comes from, so just output it without link
obj.html(curie+'<br />');
// x.responseText should have what's wrong
}
});

}else{
obj.html(pubmedId);
} else {
obj.html(curie);
}
});
return;
Expand Down
4 changes: 2 additions & 2 deletions src/js/views/eva-study-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@ EvaStudyView.prototype = {
var pubLinks = '';
if(!_.isEmpty(publications) && publications != '-') {
for (i = 0; i < publications.length; i++) {
pubLinks += '<a class="pubmed-id" href="http://www.ncbi.nlm.nih.gov/pubmed/?term=' + publications[i] + '" target="_blank">' + publications[i] + '</a><br />'
pubLinks += '<span class="publication-id">' + publications[i] + '</span><br />'
}
} else {
pubLinks = '<span class="pubmed-id">-</span>';
pubLinks = '<span class="publication-id">-</span>';
}

// Links to taxonomies
Expand Down
4 changes: 2 additions & 2 deletions tests/acceptance/study_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ function dgvaCheckSummaryTable(driver){
}

function checkPublications(driver){
driver.wait(until.elementLocated(By.className("pubmed-id")), config.wait()).then(function(text) {
driver.findElement(By.className('pubmed-id')).getText().then(function(text){
driver.wait(until.elementLocated(By.className("publication-id")), config.wait()).then(function(text) {
driver.findElement(By.className('publication-id')).getText().then(function(text){
var regExp = /^-$|^\w+/;
if(text != '-'){
text = text.split("\n");
Expand Down

0 comments on commit 3a7ffd0

Please sign in to comment.