Skip to content
Snippets Groups Projects
Commit c816d9ed authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Merge branch 'issue_88' into 'master'

This fixes #88

Closes #88

See merge request !105
parents 338c4d09 028ddb4d
No related branches found
No related tags found
1 merge request!105This fixes icat/doi-landing-page#88
Pipeline #39842 passed
module.exports = function(grunt) { module.exports = function (grunt) {
grunt.initConfig({
grunt.initConfig({
jshint: { jshint: {
files: ['Gruntfile.js', 'src/*.js', 'test/**/*.js'], files: ["Gruntfile.js", "src/*.js", "test/**/*.js"],
options: { options: {
globals: { globals: {
jQuery: true jQuery: true,
} },
} },
}, },
watch: { watch: {
files: ['src/*.js', 'templates/*.js', 'css/*.css'], files: ["src/*.js", "templates/*.js", "css/*.css"],
tasks: [ 'uglify','dustjs','cssmin','wiredep:dev'] tasks: ["uglify", "dustjs", "cssmin", "wiredep:dev"],
}, },
uglify: { uglify: {
options: { options: {
mangle: true mangle: false,
beautify: true,
compress: false,
}, },
prod: { prod: {
files: { files: {
'min/components.min.js': [ "min/components.min.js": [
'bower_components/jquery/dist/jquery.js', "bower_components/jquery/dist/jquery.js",
'bower_components/bootstrap/dist/js/bootstrap.js', "bower_components/bootstrap/dist/js/bootstrap.js",
'bower_components/dustjs-linkedin/dist/dust-full.min.js', "bower_components/dustjs-linkedin/dist/dust-full.min.js",
'bower_components/dustjs-helpers/dist/dust-helpers.min.js', "bower_components/dustjs-helpers/dist/dust-helpers.min.js",
'bower_components/lodash/dist/lodash.min.js', "bower_components/lodash/dist/lodash.min.js",
'bower_components/moment/moment.js' ], "bower_components/moment/moment.js",
'min/doi.min.js': [ ],
'src/*js'] "min/doi.min.js": ["src/*js"],
} },
} },
}, },
wiredep: { wiredep: {
prod: { prod: {
src: 'index.html' src: "index.html",
}, },
dev: { dev: {
src: 'dev.html' src: "dev.html",
} },
}, },
cssmin: { cssmin: {
prod: { prod: {
files: { files: {
'min/output.min.css' : ['bower_components/bootstrap/dist/css/bootstrap.css', 'css/*.css' ], "min/output.min.css": ["bower_components/bootstrap/dist/css/bootstrap.css", "css/*.css"],
} },
} },
}, },
dustjs : { dustjs: {
compile : { compile: {
files : { files: {
'min/precompiled.templates.min.js' : [ 'templates/**js' ] "min/precompiled.templates.min.js": ["templates/**js"],
} },
} },
}, },
includeSource: { includeSource: {
options: { options: {
basePath: '', basePath: "",
baseUrl: 'www' baseUrl: "www",
}, },
dev: { dev: {
files: { files: {
'dev.html': 'dev.tpl.html' "dev.html": "dev.tpl.html",
} },
} },
}, },
plato : { plato: {
all : { all: {
options : { options: {
complexity : { complexity: {
logicalor : true, logicalor: true,
switchcase : true, switchcase: true,
forin : true, forin: true,
trycatch : true trycatch: true,
} },
},
files: {
reports: ["src/*.js"],
}, },
files : { },
'reports' : [ 'src/*.js' ], },
}
}
}
}); });
grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks('grunt-wiredep'); grunt.loadNpmTasks("grunt-wiredep");
grunt.loadNpmTasks('grunt-dustjs'); grunt.loadNpmTasks("grunt-dustjs");
grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks("grunt-contrib-cssmin");
grunt.loadNpmTasks('grunt-include-source'); grunt.loadNpmTasks("grunt-include-source");
grunt.loadNpmTasks('grunt-plato'); grunt.loadNpmTasks("grunt-plato");
grunt.registerTask('default', ['jshint', 'dustjs', 'uglify', 'cssmin']); grunt.registerTask("default", ["jshint", "dustjs", "uglify", "cssmin"]);
grunt.registerTask('dev', ['includeSource:dev', 'dustjs', 'cssmin', 'wiredep:dev', 'plato']); grunt.registerTask("dev", ["includeSource:dev", "dustjs", "cssmin", "wiredep:dev", "plato"]);
}; };
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<title> ESRF - DOI </title> <title> ESRF - DOI </title>
<link rel="icon" href="/src/images/favicon.ico"> <link rel="icon" href="/src/images/favicon.ico">
<script src="min/components.min.js"></script>
<!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> --> <!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> -->
<!-- Using grunt-wiredep, the proper js files from bower components are included below --> <!-- Using grunt-wiredep, the proper js files from bower components are included below -->
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<title> ESRF - DOI </title> <title> ESRF - DOI </title>
<link rel="icon" href="/src/images/favicon.ico"> <link rel="icon" href="/src/images/favicon.ico">
<script src="min/components.min.js"></script>
<!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> --> <!-- <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> -->
<!-- Using grunt-wiredep, the proper js files from bower components are included below --> <!-- Using grunt-wiredep, the proper js files from bower components are included below -->
......
This diff is collapsed.
This diff is collapsed.
Source diff could not be displayed: it is too large. Options to address this: view the blob.
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
}, },
"devDependencies": { "devDependencies": {
"browserify": "^16.2.3", "browserify": "^16.2.3",
"grunt": "^1.2.1", "grunt": "^1.3.0",
"grunt-contrib-cssmin": "^2.2.1", "grunt-contrib-cssmin": "^2.2.1",
"grunt-contrib-jshint": "^1.1.0", "grunt-contrib-jshint": "^1.1.0",
"grunt-include-source": "^1.1.0", "grunt-include-source": "^1.1.0",
......
function DOIController(view) { function DOIController(view) {
var _this = this; var _this = this;
// doiServer = the server which provides doi details from a given doi name. // doiServer = the server which provides doi details from a given doi name.
this.doiServer = "https://api.datacite.org/dois/"; this.doiServer = "https://api.datacite.org/dois/";
this.icatPlusServer = "https://icatplus.esrf.fr/doi/"; this.icatPlusServer = "https://icatplus.esrf.fr/doi/";
// contentNegicationServer retrieves the DOI metadata in another format required by google search engine // contentNegicationServer retrieves the DOI metadata in another format required by google search engine
this.contentNegociationServer = "https://data.crosscite.org/"; this.contentNegociationServer = "https://data.crosscite.org/";
// 10.5072 is the test esrf doi prefix; // 10.5072 is the test esrf doi prefix;
// 10.15151 is the production esrf doi prefix; // 10.15151 is the production esrf doi prefix;
this.acceptedPrefix = ["10.5072", "10.15151"]; this.acceptedPrefix = ["10.5072", "10.15151"];
this.view = view; this.view = view;
this.experimentalReportController = new ExperimentalReportController(); this.experimentalReportController = new ExperimentalReportController();
this.experimentalReportController.onSuccess.attach(function (sender, data) { this.experimentalReportController.onSuccess.attach(function (sender, data) {
_this.view.renderExperimentalReportData(data); _this.view.renderExperimentalReportData(data);
}); });
this.experimentalReportController.onError.attach(function (sender, data) { this.experimentalReportController.onError.attach(function (sender, data) {
console.log("Error when retrieving fileList from SMIS."); console.log("Error when retrieving fileList from SMIS.");
_this.view.renderErrorForExperimentalReport(); _this.view.renderErrorForExperimentalReport();
}); });
} }
/** /**
...@@ -30,135 +29,133 @@ function DOIController(view) { ...@@ -30,135 +29,133 @@ function DOIController(view) {
* executed. Reloading the page is treated by .fail as it should be. * executed. Reloading the page is treated by .fail as it should be.
*/ */
DOIController.prototype.isValidDOIData = function (doiData) { DOIController.prototype.isValidDOIData = function (doiData) {
return true; return true;
}; };
DOIController.prototype.render = function (doi, data) { DOIController.prototype.render = function (doi, data) {
var _this = this; var _this = this;
// Test abnormal length of the json object // Test abnormal length of the json object
if (!_this.isValidDOIData(data)) { if (!_this.isValidDOIData(data)) {
_this.view.renderError("Not Found", _this.origin); _this.view.renderError("Not Found", _this.origin);
} else { } else {
// Extract data and fill doiData with it // Extract data and fill doiData with it
var doiData = new DoiData(); var doiData = new DoiData();
var jsonExtractor = new JsonExtractor(); var jsonExtractor = new JsonExtractor();
doiData.title = jsonExtractor.getTitle(data); doiData.title = jsonExtractor.getTitle(data);
doiData.doi = jsonExtractor.getDOI(data); doiData.doi = jsonExtractor.getDOI(data);
doiData.dataciteLink = _this.doiServer + doi; doiData.dataciteLink = _this.doiServer + doi;
doiData.publisher = jsonExtractor.getPublisher(data); doiData.publisher = jsonExtractor.getPublisher(data);
doiData.creators = jsonExtractor.getCreators(data); doiData.creators = jsonExtractor.getCreators(data);
doiData.publiclyAccessibleYear = jsonExtractor.getPubliclyAccessibleYear(data); doiData.publiclyAccessibleYear = jsonExtractor.getPubliclyAccessibleYear(data);
doiData.abstract = jsonExtractor.getAbstract(data); doiData.abstract = jsonExtractor.getAbstract(data);
doiData.investigationId = jsonExtractor.getInvestigationId(data); doiData.investigationId = jsonExtractor.getInvestigationId(data);
doiData.resourceType = jsonExtractor.getResourceType(data); doiData.resourceType = jsonExtractor.getResourceType(data);
doiData.proposalType = jsonExtractor.getFieldFromSubject(data.subjects, "Proposal Type Description"); doiData.proposalType = jsonExtractor.getFieldFromSubject(data.subjects, "Proposal Type Description");
doiData.resourceTypeGeneral = jsonExtractor.getResourceTypeGeneral(data); doiData.resourceTypeGeneral = jsonExtractor.getResourceTypeGeneral(data);
doiData.sessionDate = jsonExtractor.getSessionDate(data); doiData.sessionDate = jsonExtractor.getSessionDate(data);
var proposalNames = jsonExtractor.getFieldFromSubject(data.subjects, "Proposal"); var proposalNames = jsonExtractor.getFieldFromSubject(data.subjects, "Proposal");
var beamlines = jsonExtractor.getFieldFromSubject(data.subjects, "Instrument"); var beamlines = jsonExtractor.getFieldFromSubject(data.subjects, "Instrument");
_this.experimentalReportController.requestFilenameList(proposalNames[0]); _this.experimentalReportController.requestFilenameList(proposalNames[0]);
doiData.accessibility = doiData.getAccessibilityStatus(doiData.resourceType, doiData.sessionDate, doiData.publiclyAccessibleYear); doiData.accessibility = doiData.getAccessibilityStatus(doiData.resourceType, doiData.sessionDate, doiData.publiclyAccessibleYear);
doiData.accessMessage = _this.view.setDataAccessMessage(doiData); doiData.accessMessage = _this.view.setDataAccessMessage(doiData);
doiData.citation = _this.createCitation(doiData); doiData.citation = _this.createCitation(doiData);
if (doiData.resourceType === CONSTANTS.ES_RESOURCE_TYPE) { if (doiData.resourceType === CONSTANTS.ES_RESOURCE_TYPE) {
doiData.beamlineUrls = _this.getBeamlineUrl(beamlines, doiData.sessionDate, doiData.resourceType); doiData.beamlineUrls = _this.getBeamlineUrl(beamlines, doiData.sessionDate, doiData.resourceType);
doiData.mintingYear = moment(doiData.sessionDate).year(); doiData.mintingYear = moment(doiData.sessionDate).year();
} }
if (doiData.resourceType === CONSTANTS.DC_RESOURCE_TYPE) { if (doiData.resourceType === CONSTANTS.DC_RESOURCE_TYPE) {
doiData.beamlineUrls = _this.getBeamlineUrl(beamlines, doiData.publiclyAccessibleYear, doiData.resourceType); doiData.beamlineUrls = _this.getBeamlineUrl(beamlines, doiData.publiclyAccessibleYear, doiData.resourceType);
doiData.mintingYear = doiData.publiclyAccessibleYear; doiData.mintingYear = doiData.publiclyAccessibleYear;
} }
// Create a table containing unique tuples [proposal, beamline, beamlineUrl] // Create a table containing unique tuples [proposal, beamline, beamlineUrl]
doiData.mergedProposalBeamlines = jsonExtractor.getMergedProposalAndBeamline(proposalNames, beamlines, doiData.beamlineUrls); doiData.mergedProposalBeamlines = jsonExtractor.getMergedProposalAndBeamline(proposalNames, beamlines, doiData.beamlineUrls);
// Set user specific canonical URL for this page. // Set user specific canonical URL for this page.
_this.view.addCanonicalURLToHead('https://doi.esrf.fr/' + doiData.doi); _this.view.addCanonicalURLToHead("https://doi.esrf.fr/" + doiData.doi);
// send to dust render // send to dust render
_this.view.renderDOIData(doiData); _this.view.renderDOIData(doiData);
} }
}; };
DOIController.prototype.getData = function (doi) { DOIController.prototype.getData = function (doi) {
var _this = this; var _this = this;
this.view.setDOIInTopBanner(doi); this.view.setDOIInTopBanner(doi);
if (doi.toUpperCase() == "10.15151/ESRF-DC-142893590") { if (doi.toUpperCase() == "10.15151/ESRF-DC-142893590") {
this.render(doi, ESRF_DC_142893590); this.render(doi, ESRF_DC_142893590);
return; return;
} }
if (doi.toUpperCase() == "10.15151/ESRF-DC-142915526") { if (doi.toUpperCase() == "10.15151/ESRF-DC-142915526") {
this.render(doi, ESRF_DC_142915526); this.render(doi, ESRF_DC_142915526);
return; return;
} }
if (this.hasAcceptedPrefix(doi)) { if (this.hasAcceptedPrefix(doi)) {
$.ajax({
type: "GET",
timeout: 15000, // triggers timeout when request pends longer than
// 5000ms
url: _this.icatPlusServer + doi + "/json-datacite",
beforeSend: function () {
try {
$("logo").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut();
} catch (e) {}
_this.view.setLoading("Retrieving data from Server");
},
complete: function () {
_this.view.setLoading(false);
},
})
.done(function (data) {
if (data) {
_this.render(doi, data);
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
$.ajax({ $.ajax({
headers: { headers: {
Accept: "application/vnd.datacite.datacite+json" Accept: "application/vnd.datacite.datacite+json",
}, },
type: "GET", type: "GET",
timeout: 15000, // triggers timeout when request pends longer than timeout: 15000, // triggers timeout when request pends longer than
// 5000ms // 5000ms
url: this.doiServer + doi, url: this.doiServer + doi,
beforeSend: function () { beforeSend: function () {
_this.view.setLoading("Retrieving data from Server"); _this.view.setLoading("Retrieving data from Server");
}, },
complete: function () { complete: function () {
_this.view.setLoading(false); _this.view.setLoading(false);
} },
}) })
.done(function (data) { .done(function (data) {
if (data) { if (data) {
_this.render(doi, data); _this.render(doi, data);
} }
}).fail(function (jqXHR, textStatus, errorThrown) { })
/** Try with icat server **/ .fail(function (jqXHR, textStatus, errorThrown) {
$.ajax({ _this.view.renderError(jqXHR, errorThrown, _this.origin);
type: "GET", _this.view.setLoading(false);
timeout: 15000, // triggers timeout when request pends longer than });
// 5000ms });
url: _this.icatPlusServer + doi + "/json-datacite",
beforeSend: function () { this.getDataForGoogleSearch(doi);
try { } else {
$("logo").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut(); _this.view.renderError("Bad Prefix", _this.origin);
} }
catch (e) { }
_this.view.setLoading("Retrieving data from Server");
},
complete: function () {
_this.view.setLoading(false);
}
})
.done(function (data) {
if (data) {
_this.render(doi, data);
}
}).fail(function (jqXHR, textStatus, errorThrown) {
_this.view.renderError(jqXHR, errorThrown, _this.origin);
_this.view.setLoading(false);
});
});
this.getDataForGoogleSearch(doi);
} else {
_this.view.renderError("Bad Prefix", _this.origin);
}
}; };
/** /**
...@@ -166,34 +163,34 @@ DOIController.prototype.getData = function (doi) { ...@@ -166,34 +163,34 @@ DOIController.prototype.getData = function (doi) {
* @param {string} doi in the format prefix/suffix * @param {string} doi in the format prefix/suffix
*/ */
DOIController.prototype.getDataForGoogleSearch = function (doi) { DOIController.prototype.getDataForGoogleSearch = function (doi) {
var _this = this; var _this = this;
if (doi) { if (doi) {
$.ajax({ $.ajax({
headers: { headers: {
Accept: "application/vnd.schemaorg.ld+json" Accept: "application/vnd.schemaorg.ld+json",
}, },
type: "GET", type: "GET",
timeout: 15000, timeout: 15000,
url: this.contentNegociationServer + doi, url: this.contentNegociationServer + doi,
//dataType: 'text', // don't convert JSON to Javascript object //dataType: 'text', // don't convert JSON to Javascript object
success: function (data) { success: function (data) {
if (data) { if (data) {
googleMetadataObject = new GoogleMetadataObject(data); googleMetadataObject = new GoogleMetadataObject(data);
googleMetadataObject.setDescription(); googleMetadataObject.setDescription();
googleMetadataObject.setLicense(); googleMetadataObject.setLicense();
googleMetadataObject.setPublisherLogo(); googleMetadataObject.setPublisherLogo();
_this.view.addDOIMetadataToHead(JSON.stringify(googleMetadataObject.getMetadata())); _this.view.addDOIMetadataToHead(JSON.stringify(googleMetadataObject.getMetadata()));
} else { } else {
console.log("[GOOGLE SEARCH INDEXING] - No metadata recieved from datacite."); console.log("[GOOGLE SEARCH INDEXING] - No metadata recieved from datacite.");
} }
}, },
error: function (error) { error: function (error) {
console.log("[GOOGLE SEARCH INDEXING] - Failed getting metadata from datacite."); console.log("[GOOGLE SEARCH INDEXING] - Failed getting metadata from datacite.");
console.log(error.responseJSON); console.log(error.responseJSON);
} },
}); });
} }
}; };
/** /**
...@@ -202,76 +199,77 @@ DOIController.prototype.getDataForGoogleSearch = function (doi) { ...@@ -202,76 +199,77 @@ DOIController.prototype.getDataForGoogleSearch = function (doi) {
* @return true if the prefix is an esrf prefix, false otherwise * @return true if the prefix is an esrf prefix, false otherwise
*/ */
DOIController.prototype.hasAcceptedPrefix = function (doi) { DOIController.prototype.hasAcceptedPrefix = function (doi) {
var prefix = doi.split('/')[0]; var prefix = doi.split("/")[0];
return (_.findIndex(this.acceptedPrefix, function (o) { return (
return prefix == o; _.findIndex(this.acceptedPrefix, function (o) {
}) != -1); return prefix == o;
}) != -1
);
}; };
// Selects what will be displayed in the main id div // Selects what will be displayed in the main id div
DOIController.prototype.displayMainContent = function (doi) { DOIController.prototype.displayMainContent = function (doi) {
var isDOIProvided = false; var isDOIProvided = false;
if (this.origin === "welcome-page") { if (this.origin === "welcome-page") {
dust.render('welcome_tpl', {}, function (err, out) { dust.render("welcome_tpl", {}, function (err, out) {
$("#main").html(out); $("#main").html(out);
}); });
} }
if (this.origin === "index") { if (this.origin === "index") {
this.getData(doi); this.getData(doi);
} }
}; };
/** /**
* Set the origin from where the DOI controller is created. This affects the * Set the origin from where the DOI controller is created. This affects the
* content of error messages for example depending on whether they are displayed * content of error messages for example depending on whether they are displayed
* in the "welcome-page" content or the "doi landing page" content. * in the "welcome-page" content or the "doi landing page" content.
* *
* @param {string} * @param {string}
* origin The origin page this call is made from * origin The origin page this call is made from
*/ */
DOIController.prototype.setOrigin = function (origin) { DOIController.prototype.setOrigin = function (origin) {
this.origin = origin; this.origin = origin;
}; };
/** /**
* Get the corresponding url for a given beamline name * Get the corresponding url for a given beamline name
* @param {array} beamlines The beamlines * @param {array} beamlines The beamlines
* @param {momentJS} date The date the experiment was performed. * @param {momentJS} date The date the experiment was performed.
* @param {String} resourceType the data resource type * @param {String} resourceType the data resource type
* @return {array} an array containing urls of the beamLine(s). * @return {array} an array containing urls of the beamLine(s).
*/ */
DOIController.prototype.getBeamlineUrl = function (beamlines, date, resourceType) { DOIController.prototype.getBeamlineUrl = function (beamlines, date, resourceType) {
var result = []; var result = [];
beamlines.forEach(function (beamline) { beamlines.forEach(function (beamline) {
if (date) { if (date) {
if (resourceType === CONSTANTS.ES_RESOURCE_TYPE) { if (resourceType === CONSTANTS.ES_RESOURCE_TYPE) {
date = moment(date); date = moment(date);
} }
if (resourceType === CONSTANTS.DC_RESOURCE_TYPE) { if (resourceType === CONSTANTS.DC_RESOURCE_TYPE) {
date = moment(date, "YYYY"); date = moment(date, "YYYY");
} }
var foundUrl = ""; var foundUrl = "";
for (var i = 0; i < BEAMLINEURL.length; i++) { for (var i = 0; i < BEAMLINEURL.length; i++) {
var startDate = moment(BEAMLINEURL[i].startDate); var startDate = moment(BEAMLINEURL[i].startDate);
var endDate = moment(BEAMLINEURL[i].endDate); var endDate = moment(BEAMLINEURL[i].endDate);
if (BEAMLINEURL[i].name.toLowerCase() === beamline.toLowerCase() && date >= startDate && date <= endDate) { if (BEAMLINEURL[i].name.toLowerCase() === beamline.toLowerCase() && date >= startDate && date <= endDate) {
foundUrl = BEAMLINEURL[i].url; foundUrl = BEAMLINEURL[i].url;
break; break;
}
}
if (foundUrl === "") {
result.push("noLink");
} else {
result.push(foundUrl);
}
} else {
result.push("noLink");
} }
}); }
return result; if (foundUrl === "") {
result.push("noLink");
} else {
result.push(foundUrl);
}
} else {
result.push("noLink");
}
});
return result;
}; };
/** /**
...@@ -281,18 +279,29 @@ DOIController.prototype.getBeamlineUrl = function (beamlines, date, resourceType ...@@ -281,18 +279,29 @@ DOIController.prototype.getBeamlineUrl = function (beamlines, date, resourceType
* @return {string} the citation to be displayed * @return {string} the citation to be displayed
*/ */
DOIController.prototype.createCitation = function (doiData) { DOIController.prototype.createCitation = function (doiData) {
// Authors sent in json can be in several format. The following call find // Authors sent in json can be in several format. The following call find
// first name and last name when possible. // first name and last name when possible.
var citation = new Citation(doiData); var citation = new Citation(doiData);
if (!citation.isBuildable) { if (!citation.isBuildable) {
return "The citation could not be generated."; return "The citation could not be generated.";
} else {
} else { var authorInCitation = citation.getAuthorsForCitation(doiData.creators);
var authorInCitation = citation.getAuthorsForCitation(doiData.creators); var doiRegistrationYear = citation.getDOIRegistrationYear(doiData);
var doiRegistrationYear = citation.getDOIRegistrationYear(doiData); var fullCitation =
var fullCitation = authorInCitation + ' (' + doiRegistrationYear + '). ' + doiData.title + '. ' + doiData.publisher + ' (ESRF). ' + authorInCitation +
" <a href='https://doi.esrf.fr/" + doiData.doi + "'> doi:" + doiData.doi.toUpperCase() + "</a>"; " (" +
return fullCitation; doiRegistrationYear +
} "). " +
doiData.title +
". " +
doiData.publisher +
" (ESRF). " +
" <a href='https://doi.esrf.fr/" +
doiData.doi +
"'> doi:" +
doiData.doi.toUpperCase() +
"</a>";
return fullCitation;
}
}; };
...@@ -166,6 +166,8 @@ DOIView.prototype.renderMetadata = function (data) { ...@@ -166,6 +166,8 @@ DOIView.prototype.renderMetadata = function (data) {
* @return {string} message to display * @return {string} message to display
*/ */
DOIView.prototype.setDataAccessMessage = function (doiData) { DOIView.prototype.setDataAccessMessage = function (doiData) {
alert("test");
console.log(doiData);
if (doiData.accessibility === "Open access") { if (doiData.accessibility === "Open access") {
return "The data can be accessed by clicking on the link below"; return "The data can be accessed by clicking on the link below";
} else if (doiData.accessibility === "Restricted access") { } else if (doiData.accessibility === "Restricted access") {
...@@ -195,4 +197,4 @@ DOIView.prototype.addCanonicalURLToHead = function (doiURL) { ...@@ -195,4 +197,4 @@ DOIView.prototype.addCanonicalURLToHead = function (doiURL) {
.attr('rel', 'canonical') .attr('rel', 'canonical')
.attr('href', doiURL) .attr('href', doiURL)
.appendTo('head'); .appendTo('head');
}; };
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment