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>
<html>
<head>
<head>
<meta charset="UTF-8">
<title> ESRF - DOI </title>
<link rel="icon" href="/src/images/favicon.ico">
......@@ -32,7 +33,6 @@
<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 -->
......@@ -40,22 +40,24 @@
<!-- 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" >
<link rel="stylesheet" href="/min/output.min.css">
<script type="text/javascript">
$(document).ready(function() {
$(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");
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>
</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-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-auto">
<div class="whiteFont font-3p2rem" id="doiValue">
......@@ -66,7 +68,7 @@
</div>
<div id="main"></div>
<div id='error' ></div>
<div id='error'></div>
<div class="modal">
<!-- nothing to write here -->
......@@ -74,17 +76,21 @@
<footer class="footer">
<div class="container-fluid">
<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>
</div>
<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>
<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>
</div>
<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>
</footer>
</body>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<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>
<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 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);
<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 !="") {
if (doi != "") {
controller.setOrigin("index");
}
else {
......@@ -28,20 +29,23 @@
});
// search the doi entered in the search box
function searchDOI(){
function searchDOI() {
var doi = $('#doiSearchBox').val();
if (!doi){doi = $('#doiSearchBox').attr('placeholder')}
if (!doi) { doi = $('#doiSearchBox').attr('placeholder') }
var controller = new DOIController(new DOIView());
controller.setOrigin("welcome-page");
controller.getData(doi);
};
</script>
</head>
<body>
</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-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-auto">
<div class="whiteFont font-3p2rem" id="doiValue">
......@@ -51,25 +55,29 @@
</div>
</div>
</div>
<div id='main' ></div>
<div id='error' ></div>
<div id='main'></div>
<div id='error'></div>
<div class="modal">
<!-- nothing to write here -->
</div>
<footer class="footer">
<div class="container-fluid">
<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>
</div>
<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>
<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>
</div>
<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>
</footer>
</body>
</body>
</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) {
_this.view.renderDOIData(doiData);
}
};
DOIController.prototype.getData = function (doi) {
var _this = this;
......@@ -131,10 +132,10 @@ DOIController.prototype.getData = function (doi) {
// 5000ms
url: _this.icatPlusServer + doi + "/json-datacite",
beforeSend: function () {
try{
try {
$("logo").fadeIn().fadeOut().fadeIn().fadeOut().fadeIn().fadeOut();
}
catch(e){}
catch (e) { }
_this.view.setLoading("Retrieving data from Server");
},
complete: function () {
......@@ -149,19 +150,48 @@ DOIController.prototype.getData = function (doi) {
_this.view.renderError(jqXHR, errorThrown, _this.origin);
_this.view.setLoading(false);
});
});
this.getDataForGoogleSearch(doi);
} else {
_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
*
* @param{string} doi The DOI number
* @return true if the prefix is an esrf prefix, false otherwise
*
*/
DOIController.prototype.hasAcceptedPrefix = function (doi) {
var prefix = doi.split('/')[0];
......
......@@ -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.
*
*/
DOIView.prototype.setDOIInTopBanner = function (doiCode) {
$("#doiValue").text("DOI > " + doiCode.toUpperCase());
......@@ -29,9 +28,7 @@ DOIView.prototype.setDOIInTopBanner = function (doiCode) {
/**
* 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) {
if (data) {
......@@ -55,7 +52,7 @@ DOIView.prototype.renderDOIData = function (doiData) {
var _this = this;
dust.render('landingpage_tpl', {
data: doiData,
constants : CONSTANTS
constants: CONSTANTS
}, function (err, out) {
$('#' + _this.mainPanelId).html(out);
_this.isDOIAlreadyRendered = true;
......@@ -76,11 +73,8 @@ DOIView.prototype.renderDOIData = function (doiData) {
/**
* Render the error message
*
* @param {string}
* error The error which was thrown
* @param {string}
* origin The page which caused this rendering. This directly
* influence the element id
* @param {string} errorThrown The error which was thrown
* @param {string} origin The page which caused this rendering. This directly influences the element id
*/
DOIView.prototype.renderError = function (jqXHR, errorThrown, origin) {
var template = ((origin === "welcome-page") ? "doinotfound2_tpl" : "doinotfound_tpl");
......@@ -142,7 +136,7 @@ DOIView.prototype.renderBadges = function (data) {
dust.render('badges_tpl', {
data: data,
constants : CONSTANTS
constants: CONSTANTS
}, function (err, out) {
$('#' + _this.badgePanelId).html(out);
});
......@@ -157,21 +151,17 @@ DOIView.prototype.renderMetadata = function (data) {
var _this = this;
dust.render('metadata_tpl', {
data: data,
constants : CONSTANTS
constants: CONSTANTS
}, function (err, out) {
$('#' + _this.metadataDivId).html(out);
});
}
};
/**
* Set the message which is displayed just above the "Access data button" in experimental data box.
*
* @param {object}
* data The json object reference.
* @return {string}
* the message to display
* @param {object} doiData json object reference.
* @return {string} message to display
*/
DOIView.prototype.setDataAccessMessage = function (doiData) {
if (doiData.accessibility === "Open access") {
......@@ -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