Skip to content

Commit

Permalink
Merge pull request #3381 from dzhw/tvillwock/issue3380-dmr-citation-doi
Browse files Browse the repository at this point in the history
#3380 Added DOI to attachment citation and BibTex download
  • Loading branch information
tilovillwock authored Nov 11, 2024
2 parents 3ad4361 + a750be0 commit ed8bae6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,24 @@ function($interpolate, LanguageService, $filter, $rootScope) {
});
};

var generateBibtexForAttachment = function(attachment) {
var generateBibtexForAttachment = function(attachment, dataPackage) {
if ($rootScope.bowser.msie) {
throw 'citation.js is not compatible with IE11';
}
var citeJson = {
title: attachment.title,
type: 'report',
DOI: dataPackage.doi,
publisher: attachment.citationDetails.institution,
'publisher-place': attachment.citationDetails.location,
issued: [{'date-parts': [attachment.citationDetails.publicationYear]}],
author: mapPeopleToCiteJson(attachment.citationDetails.authors)
};
return new Cite(citeJson).format('bibtex')
return new Cite(citeJson).format('biblatex') // use biblatex to include the doi and map fields back to bibtex names
.replace('@report', '@techreport')
.replace('date =', 'year =')
.replace('location =', 'address =')
.replace('publisher =', 'institution =')
// remove spaces in latex code for umlauts
.replace(/{\\.\s./g, function(match) {
return match.replace(' ', '');
Expand Down Expand Up @@ -118,14 +123,17 @@ function($interpolate, LanguageService, $filter, $rootScope) {
};
};

var generateCitationHintForAttachment = function(attachment) {
var generateCitationHintForAttachment = function(attachment, dataPackage) {
var citationHint =
'{{attachment.citationDetails.authors | displayPersons}} ' +
'({{attachment.citationDetails.publicationYear}}). ' +
'{{attachment.title}}. ' +
'{{attachment.citationDetails.location}}: ' +
'{{attachment.citationDetails.institution}}.';
return $interpolate(citationHint)({attachment: attachment});
if (!!dataPackage.doi) {
citationHint += ' https://doi.org/{{dataPackage.doi}}';
}
return $interpolate(citationHint)({attachment: attachment, dataPackage: dataPackage});
};

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ angular.module('metadatamanagementApp')
ctrl.methodReportsCitationHint = {
de: germanMethodReports.length > 0 ?
CitationHintGeneratorService.generateCitationHintForAttachment(
germanMethodReports[0]) : null,
germanMethodReports[0], dataPackage) : null,
en: englishMethodReports.length > 0 ?
CitationHintGeneratorService.generateCitationHintForAttachment(
englishMethodReports[0]) : null,
englishMethodReports[0], dataPackage) : null,
};
ctrl.methodReports = {
de: germanMethodReports.length > 0 ? germanMethodReports[0] : null,
Expand Down Expand Up @@ -74,7 +74,7 @@ angular.module('metadatamanagementApp')
}
if (methodReport) {
ctrl.saveBibtex(CitationHintGeneratorService
.generateBibtexForAttachment(methodReport));
.generateBibtexForAttachment(methodReport, dataPackage));
}
};

Expand Down

0 comments on commit ed8bae6

Please sign in to comment.