Commit fd2c6b6f authored by Maxime Chaillet's avatar Maxime Chaillet

Merge branch 'issue63' into 'master'

Issue63

Closes #63

See merge request !74
parents 79f5bc72 fe6686c3
Pipeline #7888 passed with stages
in 1 minute and 13 seconds
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<meta charset="UTF-8">
<title> ESRF - DOI </title>
<link rel="icon" href="/src/images/favicon.ico">
<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 -->
<!-- bower:js -->
<script src="bower_components/jquery/dist/jquery.js"></script>
<script src="bower_components/dustjs-linkedin/dist/dust-full.min.js"></script>
<script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
<script src="bower_components/dustjs-helpers/dist/dust-helpers.min.js"></script>
<script src="bower_components/lodash/lodash.js"></script>
<script src="bower_components/moment/moment.js"></script>
<!-- endbower -->
<!-- Using grunt-include-source, the proper js files created by us (not minified) are included below -->
<script src="src/author.js"></script>
<script src="src/beamlineurl.js"></script>
<script src="src/citation.js"></script>
<script src="src/constants.js"></script>
<script src="src/doicontroller.js"></script>
<script src="src/doiData.js"></script>
<script src="src/doiview.js"></script>
<script src="src/ESRF-DC-142893590.js"></script>
<script src="src/ESRF-DC-142915526.js"></script>
<script src="src/event.js"></script>
<script src="src/experimentalreportcontroller.js"></script>
<script src="src/jsonextractor.js"></script>
<script src="src/metadataTableHelper.js"></script>
<!-- bower:css --> <head>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" /> <meta charset="UTF-8">
<!-- endbower --> <title> ESRF - DOI </title>
<link rel="icon" href="/src/images/favicon.ico">
<!-- Using grunt-include-source, the proper all dustjs templates files (not minified are included below --> <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script src="min/precompiled.templates.min.js"></script>
<!-- Using grunt-wiredep, the proper js files from bower components are included below -->
<link rel="stylesheet" href="/min/output.min.css" > <!-- bower:js -->
<script type="text/javascript"> <script src="bower_components/jquery/dist/jquery.js"></script>
$(document).ready(function() { <script src="bower_components/dustjs-linkedin/dist/dust-full.min.js"></script>
var doi = document.location.search.substring(5); <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
if (doi==="") { <script src="bower_components/dustjs-helpers/dist/dust-helpers.min.js"></script>
alert ("Please use dev.html page as follow .../dev.html?DOI=prefix/suffix"); <script src="bower_components/lodash/lodash.js"></script>
} else { <script src="bower_components/moment/moment.js"></script>
new DOIController(new DOIView()).getData(doi); <!-- endbower -->
}
}); <!-- Using grunt-include-source, the proper js files created by us (not minified) are included below -->
</script> <script src="src/author.js"></script>
</head> <script src="src/beamlineurl.js"></script>
<body> <script src="src/citation.js"></script>
<div class="container-fluid"> <script src="src/constants.js"></script>
<div class="row align-items-center blueBackground"> <script src="src/doicontroller.js"></script>
<div class="col-12 col-sm-4" > <img id="logo" style="height:80px;" src="/src/images/esrflogo.png" alt="the ESRF logo"> </img> </div> <script src="src/doiData.js"></script>
<script src="src/doiview.js"></script>
<script src="src/ESRF-DC-142893590.js"></script>
<script src="src/ESRF-DC-142915526.js"></script>
<script src="src/event.js"></script>
<script src="src/experimentalreportcontroller.js"></script>
<script src="src/jsonextractor.js"></script>
<script src="src/metadataTableHelper.js"></script>
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- Using grunt-include-source, the proper all dustjs templates files (not minified are included below -->
<script src="min/precompiled.templates.min.js"></script>
<link rel="stylesheet" href="/min/output.min.css">
<script type="text/javascript">
$(document).ready(function () {
var doi = document.location.search.substring(5);
if (doi === "") {
alert("Please use dev.html page as follow .../dev.html?DOI=prefix/suffix");
} else {
new DOIController(new DOIView()).getData(doi);
}
});
</script>
</head>
<body>
<div class="container-fluid">
<div class="row align-items-center blueBackground">
<div class="col-12 col-sm-4"> <img id="logo" style="height:80px;" src="/src/images/esrflogo.png" alt="the ESRF logo">
</img> </div>
<div class="col"> </div> <div class="col"> </div>
<div class="col-auto"> <div class="col-auto">
<div class="whiteFont font-3p2rem" id="doiValue"> <div class="whiteFont font-3p2rem" id="doiValue">
<!-- filled by the js code --> <!-- filled by the js code -->
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="main"></div> <div id="main"></div>
<div id='error' ></div> <div id='error'></div>
<div class="modal"> <div class="modal">
<!-- nothing to write here --> <!-- nothing to write here -->
</div> </div>
<footer class="footer"> <footer class="footer">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-12 col-md-5" > <div class="col-12 col-md-5">
<p><a style='font-weight:bold;' href="http://www.esrf.eu">European Synchrotron Radiation Facility</a></p> <p><a style='font-weight:bold;' href="http://www.esrf.eu">European Synchrotron Radiation Facility</a></p>
</div> </div>
<div class="col-12 col-md-2" > <div class="col-12 col-md-2">
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a> <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License"
</div> style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a>
<div class="col-12 col-md-5"> </div>
<p class="float-right" style="font-size:12px;display:block;" > Access to data is governed by the <a href="http://www.esrf.eu/files/live/sites/www/files/about/organisation/ESRF%20data%20policy-web.pdf" target="_blank">ESRF data policy</a>.</p> <div class="col-12 col-md-5">
</div> <p class="float-right" style="font-size:12px;display:block;"> Access to data is governed by the <a
href="http://www.esrf.eu/files/live/sites/www/files/about/organisation/ESRF%20data%20policy-web.pdf"
target="_blank">ESRF data policy</a>.</p>
</div>
</div> </div>
</div> </div>
</footer> </footer>
</body> </body>
</html>
</html>
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<meta charset="UTF-8">
<link rel="icon" href="/src/images/favicon.ico">
<title> ESRF - DOI </title>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="/min/output.min.css" >
</head>
<script src="/min/components.min.js"></script>
<script src="/min/precompiled.templates.min.js"></script>
<script src="/min/doi.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var doi = document.location.pathname.substring(1,document.location.pathname.length);
var controller = new DOIController(new DOIView());
if (doi !="") {
controller.setOrigin("index");
}
else {
controller.setOrigin("welcome-page");
}
controller.displayMainContent(doi);
});
// search the doi entered in the search box <head>
function searchDOI(){ <meta charset="UTF-8">
var doi = $('#doiSearchBox').val(); <link rel="icon" href="/src/images/favicon.ico">
if (!doi){doi = $('#doiSearchBox').attr('placeholder')}
var controller = new DOIController(new DOIView()); <title> ESRF - DOI </title>
controller.setOrigin("welcome-page");
controller.getData(doi); <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
}; <link rel="stylesheet" href="/min/output.min.css">
</head>
</script>
</head> <script src="/min/components.min.js"></script>
<body> <script src="/min/precompiled.templates.min.js"></script>
<div class="container-fluid"> <script src="/min/doi.min.js"></script>
<div class="row align-items-center blueBackground">
<div class="col-12 col-sm-4" > <img id="logo" style="height:80px;" src="/src/images/esrflogo.png" alt="the ESRF logo"> </img> </div> <script type="text/javascript">
$(document).ready(function () {
var doi = document.location.pathname.substring(1, document.location.pathname.length);
var controller = new DOIController(new DOIView());
if (doi != "") {
controller.setOrigin("index");
}
else {
controller.setOrigin("welcome-page");
}
controller.displayMainContent(doi);
});
// search the doi entered in the search box
function searchDOI() {
var doi = $('#doiSearchBox').val();
if (!doi) { doi = $('#doiSearchBox').attr('placeholder') }
var controller = new DOIController(new DOIView());
controller.setOrigin("welcome-page");
controller.getData(doi);
};
</script>
</head>
<body>
<div class="container-fluid">
<div class="row align-items-center blueBackground">
<div class="col-12 col-sm-4">
<img id="logo" style="height:80px;" src="/src/images/esrflogo.png" alt="the ESRF logo">
</div>
<div class="col"> </div> <div class="col"> </div>
<div class="col-auto"> <div class="col-auto">
<div class="whiteFont font-3p2rem" id="doiValue"> <div class="whiteFont font-3p2rem" id="doiValue">
<!-- filled by the js code --> <!-- filled by the js code -->
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id='main' ></div> <div id='main'></div>
<div id='error' ></div> <div id='error'></div>
<div class="modal"> <div class="modal">
<!-- nothing to write here --> <!-- nothing to write here -->
</div> </div>
<footer class="footer"> <footer class="footer">
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-12 col-md-5" > <div class="col-12 col-md-5">
<p><a style='font-weight:bold;' href="http://www.esrf.eu">European Synchrotron Radiation Facility</a></p> <p><a style='font-weight:bold;' href="http://www.esrf.eu">European Synchrotron Radiation Facility</a></p>
</div> </div>
<div class="col-12 col-md-2" > <div class="col-12 col-md-2">
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a> <a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License"
</div> style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a>
<div class="col-12 col-md-5"> </div>
<p class="float-right" style="font-size:12px;display:block;" > Access to data is governed by the <a href="http://www.esrf.eu/files/live/sites/www/files/about/organisation/ESRF%20data%20policy-web.pdf" target="_blank">ESRF data policy</a>.</p> <div class="col-12 col-md-5">
</div> <p class="float-right" style="font-size:12px;display:block;"> Access to data is governed by the <a
href="http://www.esrf.eu/files/live/sites/www/files/about/organisation/ESRF%20data%20policy-web.pdf"
target="_blank">ESRF data policy</a>.</p>
</div>
</div> </div>
</div> </div>
</footer> </footer>
</body> </body>
</html>
</html>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -56,7 +56,7 @@ DOIController.prototype.render = function (doi, data) { ...@@ -56,7 +56,7 @@ DOIController.prototype.render = function (doi, 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");
...@@ -88,6 +88,7 @@ DOIController.prototype.render = function (doi, data) { ...@@ -88,6 +88,7 @@ DOIController.prototype.render = function (doi, data) {
_this.view.renderDOIData(doiData); _this.view.renderDOIData(doiData);
} }
}; };
DOIController.prototype.getData = function (doi) { DOIController.prototype.getData = function (doi) {
var _this = this; var _this = this;
...@@ -104,64 +105,93 @@ DOIController.prototype.getData = function (doi) { ...@@ -104,64 +105,93 @@ DOIController.prototype.getData = function (doi) {
} }
if (this.hasAcceptedPrefix(doi)) { if (this.hasAcceptedPrefix(doi)) {
$.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) { }).fail(function (jqXHR, textStatus, errorThrown) {
/** Try with icat server **/ /** Try with icat server **/
$.ajax({ $.ajax({
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.icatPlusServer + doi + "/json-datacite", url: _this.icatPlusServer + doi + "/json-datacite",
beforeSend: function () { beforeSend: function () {
try{ try {
$("logo").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut(); $("logo").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut();
} }
catch(e){} catch (e) { }
_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) { }).fail(function (jqXHR, textStatus, errorThrown) {
_this.view.renderError(jqXHR, errorThrown, _this.origin); _this.view.renderError(jqXHR, errorThrown, _this.origin);
_this.view.setLoading(false); _this.view.setLoading(false);
}); });
}); });
this.getDataForGoogleSearch(doi);
} else { } else {
_this.view.renderError("Bad Prefix", _this.origin); _this.view.renderError("Bad Prefix", _this.origin);
} }
}; };
/**
* Get the DOI metadata in the ld+Json format as requested by google search engine for datasets.
* @param {string} doi in the format prefix/suffix
*/
DOIController.prototype.getDataForGoogleSearch = function (doi) {
var _this = this;
if (doi) {
$.ajax({
headers: {
Accept: "application/vnd.schemaorg.ld+json"
},
type: "GET",
timeout: 15000,
url: 'https://data.datacite.org/' + doi,
dataType: 'text', // don't convert JSON to Javascript object
success: function (data) {
if (data) {
_this.view.addDOIMetadataToHead(data);
}
console.log("[GOOGLE SEARCH INDEXING] - No metadata recieved from datacite.");
},
error: function (error) {
console.log("[GOOGLE SEARCH INDEXING] - Failed getting metadata from datacite.");
console.log(error.responseJSON);
}
});
}
};
/** /**
* Checks whether the requested doi prefix is an esrf prefix * Checks whether the requested doi prefix is an esrf prefix
*
* @param{string} doi The DOI number * @param{string} doi The DOI number
* @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];
......
...@@ -20,8 +20,7 @@ DOIView.prototype.setLoading = function (message) { ...@@ -20,8 +20,7 @@ DOIView.prototype.setLoading = function (message) {
}; };
/** /**
* Set the doi prefix/suffix text in the top banner of the doi landing page. This is done before the template is rendered. * Set the doi prefix/suffix text in the top banner of the doi landing page. This is done before the template is rendered.
*
*/ */
DOIView.prototype.setDOIInTopBanner = function (doiCode) { DOIView.prototype.setDOIInTopBanner = function (doiCode) {
$("#doiValue").text("DOI > " + doiCode.toUpperCase()); $("#doiValue").text("DOI > " + doiCode.toUpperCase());
...@@ -29,9 +28,7 @@ DOIView.prototype.setDOIInTopBanner = function (doiCode) { ...@@ -29,9 +28,7 @@ DOIView.prototype.setDOIInTopBanner = function (doiCode) {
/** /**
* Render experimental Report data * Render experimental Report data
* * @param {array} data The filename list to be displayed
* @param {array}
* data The filename list to be displayed
*/ */
DOIView.prototype.renderExperimentalReportData = function (data) { DOIView.prototype.renderExperimentalReportData = function (data) {
if (data) { if (data) {
...@@ -52,10 +49,10 @@ DOIView.prototype.renderExperimentalReportData = function (data) { ...@@ -52,10 +49,10 @@ DOIView.prototype.renderExperimentalReportData = function (data) {
}; };
DOIView.prototype.renderDOIData = function (doiData) { DOIView.prototype.renderDOIData = function (doiData) {
var _this = this; var _this = this;
dust.render('landingpage_tpl', { dust.render('landingpage_tpl', {
data: doiData, data: doiData,
constants : CONSTANTS constants: CONSTANTS
}, function (err, out) { }, function (err, out) {
$('#' + _this.mainPanelId).html(out); $('#' + _this.mainPanelId).html(out);
_this.isDOIAlreadyRendered = true; _this.isDOIAlreadyRendered = true;
...@@ -76,11 +73,8 @@ DOIView.prototype.renderDOIData = function (doiData) { ...@@ -76,11 +73,8 @@ DOIView.prototype.renderDOIData = function (doiData) {
/** /**
* Render the error message * Render the error message
* *
* @param {string} * @param {string} errorThrown The error which was thrown
* error The error which was thrown * @param {string} origin The page which caused this rendering. This directly influences the element id
* @param {string}
* origin The page which caused this rendering. This directly
* influence the element id
*/ */
DOIView.prototype.renderError = function (jqXHR, errorThrown, origin) { DOIView.prototype.renderError = function (jqXHR, errorThrown, origin) {
var template = ((origin === "welcome-page") ? "doinotfound2_tpl" : "doinotfound_tpl"); var template = ((origin === "welcome-page") ? "doinotfound2_tpl" : "doinotfound_tpl");
...@@ -142,7 +136,7 @@ DOIView.prototype.renderBadges = function (data) { ...@@ -142,7 +136,7 @@ DOIView.prototype.renderBadges = function (data) {
dust.render('badges_tpl', { dust.render('badges_tpl', {
data: data, data: data,
constants : CONSTANTS constants: CONSTANTS
}, function (err, out) { }, function (err, out) {
$('#' + _this.badgePanelId).html(out); $('#' + _this.badgePanelId).html(out);
}); });
...@@ -157,21 +151,17 @@ DOIView.prototype.renderMetadata = function (data) { ...@@ -157,21 +151,17 @@ DOIView.prototype.renderMetadata = function (data) {
var _this = this; var _this = this;
dust.render('metadata_tpl', { dust.render('metadata_tpl', {
data: data, data: data,
constants : CONSTANTS constants: CONSTANTS
}, function (err, out) { }, function (err, out) {
$('#' + _this.metadataDivId).html(out); $('#' + _this.metadataDivId).html(out);
}); });
} }
}; };
/** /**
* Set the message which is displayed just above the "Access data button" in experimental data box. * Set the message which is displayed just above the "Access data button" in experimental data box.
* * @param {object} doiData json object reference.
* @param {object} * @return {string} message to display
* data The json object reference.
* @return {string}
* the message to display
*/ */
DOIView.prototype.setDataAccessMessage = function (doiData) { DOIView.prototype.setDataAccessMessage = function (doiData) {
if (doiData.accessibility === "Open access") { if (doiData.accessibility === "Open access") {
...@@ -182,3 +172,14 @@ DOIView.prototype.setDataAccessMessage = function (doiData) { ...@@ -182,3 +172,14 @@ DOIView.prototype.setDataAccessMessage = function (doiData) {
} }
}; };
/**
* Add JSON LD metadata to the head of the page such that google search engine can index this page.
* @param {string} data doi metadata in Json+LD format as provided by datacite.
*/
DOIView.prototype.addDOIMetadataToHead = function (data) {
$('<script>')
.attr('type', 'application/ld+json')
.text(data)
.appendTo('head');
};
\ No newline at end of file
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