Commit 0d76cef6 authored by Maxime Chaillet's avatar Maxime Chaillet

fix merge conflicts after updating issue branch from master

parents f6d4b46b fe393584
Pipeline #2273 failed with stages
This diff is collapsed.
This diff is collapsed.
......@@ -32,6 +32,8 @@ DOIController.prototype.getData = function(doi) {
extractFieldsFromCategories(doiData);
//extractInvestigationId from doiData.doi
extractFieldsFromDoi(doiData);
// create citation
createCitation(doiData);
// Retrieve the URL corresponding to the beamline name. Currently, the date of the
// experiment is calculated from the publicationYear.
var experimentalYear = doiData.issued["date-parts"] - 3 ;
......@@ -169,3 +171,45 @@ function extractFieldsFromDoi(data) {
var regExp = RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);
data.investigationId = regExp.exec(data.DOI)[1];
}
// Create the citation for the current work. Citation proposes a recommendation to the reader
// on how to cite this work.
//@data: the data object, it is a reference
function createCitation(data) {
var authorList = _.transform(data.author, function(result, obj) {
if (obj.given) {
result.push(obj.family + ' ' + obj.given);
} else {
// cells of data.authors contains First Name FAMILY NAME most of the time.
// 1 - detect the words in UPPERCASE as FAMILY name
// 2 - detect the words in LOWERcase except first letter which can optionally be uppercase.
// 3 - flip them
var familyRegExp = new RegExp(/\s([^a-z]+$)/);
var firstNameRegExp = new RegExp(/^(.[^A-Z]+)+\b/);
var familyName = familyRegExp.exec(obj.literal);
var firstName = firstNameRegExp.exec(obj.literal);
// Sometime all words are uppercase or lowercase or uppercase for the first letter only. In this case we can not distinguish between family name and firstname. => string unchanged
if (!familyName || !firstName ){
result.push(obj.literal);
} else {
result.push(familyName[1] + " " + firstName[0].trim());
}
}
},[]);
var authorString = _.join(authorList,'; ');
var citation = authorString +
'. (' +
data.issued['date-parts'] +
'). ' +
data.title +
'. ' +
data.publisher +
' (ESRF). ' +
" <a href='https://doi.esrf.fr/" + data.DOI + "'> doi:" + data.DOI + "</a>";
data.citation = citation;
}
......@@ -95,7 +95,24 @@
</div>
</div>
</div>
<hr>
<div class="row">
<div class="col-12">
<div class="myBorder-left">
<label> Citation </label>
<div class="padding-left-15">
<p> Below is the recommended format for citing this work in a research publication.</p>
<div class="padding-left-15">
<cite> {data.citation|s} </cite>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-4">
<div class="row">
<div class="col-12">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment