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>
<head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title> ESRF - DOI </title> <title> ESRF - DOI </title>
<link rel="icon" href="/src/images/favicon.ico"> <link rel="icon" href="/src/images/favicon.ico">
...@@ -32,7 +33,6 @@ ...@@ -32,7 +33,6 @@
<script src="src/jsonextractor.js"></script> <script src="src/jsonextractor.js"></script>
<script src="src/metadataTableHelper.js"></script> <script src="src/metadataTableHelper.js"></script>
<!-- bower:css --> <!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" /> <link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower --> <!-- endbower -->
...@@ -40,22 +40,24 @@ ...@@ -40,22 +40,24 @@
<!-- Using grunt-include-source, the proper all dustjs templates files (not minified are included below --> <!-- Using grunt-include-source, the proper all dustjs templates files (not minified are included below -->
<script src="min/precompiled.templates.min.js"></script> <script src="min/precompiled.templates.min.js"></script>
<link rel="stylesheet" href="/min/output.min.css" > <link rel="stylesheet" href="/min/output.min.css">
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function () {
var doi = document.location.search.substring(5); var doi = document.location.search.substring(5);
if (doi==="") { if (doi === "") {
alert ("Please use dev.html page as follow .../dev.html?DOI=prefix/suffix"); alert("Please use dev.html page as follow .../dev.html?DOI=prefix/suffix");
} else { } else {
new DOIController(new DOIView()).getData(doi); new DOIController(new DOIView()).getData(doi);
} }
}); });
</script> </script>
</head> </head>
<body>
<body>
<div class="container-fluid"> <div class="container-fluid">
<div class="row align-items-center blueBackground"> <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-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">
...@@ -66,7 +68,7 @@ ...@@ -66,7 +68,7 @@
</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 -->
...@@ -74,17 +76,21 @@ ...@@ -74,17 +76,21 @@
<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"
style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a>
</div> </div>
<div class="col-12 col-md-5"> <div class="col-12 col-md-5">
<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> <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> </div>
</footer> </footer>
</body> </body>
</html> </html>
\ No newline at end of file
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head>
<head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="icon" href="/src/images/favicon.ico"> <link rel="icon" href="/src/images/favicon.ico">
<title> ESRF - DOI </title> <title> ESRF - DOI </title>
<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">
<link rel="stylesheet" href="/min/output.min.css" > <link rel="stylesheet" href="/min/output.min.css">
</head> </head>
<script src="/min/components.min.js"></script> <script src="/min/components.min.js"></script>
<script src="/min/precompiled.templates.min.js"></script> <script src="/min/precompiled.templates.min.js"></script>
<script src="/min/doi.min.js"></script> <script src="/min/doi.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function() { $(document).ready(function () {
var doi = document.location.pathname.substring(1,document.location.pathname.length); var doi = document.location.pathname.substring(1, document.location.pathname.length);
var controller = new DOIController(new DOIView()); var controller = new DOIController(new DOIView());
if (doi !="") { if (doi != "") {
controller.setOrigin("index"); controller.setOrigin("index");
} }
else { else {
...@@ -28,20 +29,23 @@ ...@@ -28,20 +29,23 @@
}); });
// search the doi entered in the search box // search the doi entered in the search box
function searchDOI(){ function searchDOI() {
var doi = $('#doiSearchBox').val(); var doi = $('#doiSearchBox').val();
if (!doi){doi = $('#doiSearchBox').attr('placeholder')} if (!doi) { doi = $('#doiSearchBox').attr('placeholder') }
var controller = new DOIController(new DOIView()); var controller = new DOIController(new DOIView());
controller.setOrigin("welcome-page"); controller.setOrigin("welcome-page");
controller.getData(doi); controller.getData(doi);
}; };
</script> </script>
</head> </head>
<body>
<body>
<div class="container-fluid"> <div class="container-fluid">
<div class="row align-items-center blueBackground"> <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-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">
...@@ -51,25 +55,29 @@ ...@@ -51,25 +55,29 @@
</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"
style="border-width:0" src="https://i.creativecommons.org/l/by/4.0/88x31.png" /></a>
</div> </div>
<div class="col-12 col-md-5"> <div class="col-12 col-md-5">
<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> <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> </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.
...@@ -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;
...@@ -131,10 +132,10 @@ DOIController.prototype.getData = function (doi) { ...@@ -131,10 +132,10 @@ DOIController.prototype.getData = function (doi) {
// 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 () {
...@@ -149,19 +150,48 @@ DOIController.prototype.getData = function (doi) { ...@@ -149,19 +150,48 @@ DOIController.prototype.getData = function (doi) {
_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];
......
...@@ -21,7 +21,6 @@ DOIView.prototype.setLoading = function (message) { ...@@ -21,7 +21,6 @@ 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) {
...@@ -55,7 +52,7 @@ DOIView.prototype.renderDOIData = function (doiData) { ...@@ -55,7 +52,7 @@ 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