Commit 74bbeecf authored by Maxime Chaillet's avatar Maxime Chaillet

Revisit the code and add more tests on the data object.

parent c5260719
Pipeline #2356 canceled with stages
......@@ -53,11 +53,14 @@
<footer class="footer">
<div class="container-fluid">
<div class="row">
<div class="col-12 col-md-6" >
<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-6">
<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 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>
</div>
</div>
</div>
......
This diff is collapsed.
(function(dust){dust.register("doi-not-found-page",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid \" style=\"color:black;\"><div class=\"row\"><div class=\"col-3\"> </div><div class=\"col-6 lightRedBackground text-center rounded\"> <p> ").f(ctx.get(["message"], false),ctx,"h",["s"]).w(" </p> </div></div><div class=\"col-3\"> </div></div> ");}body_0.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("doi-not-found-page2",body_0);function body_0(chk,ctx){return chk.f(ctx.get(["message"], false),ctx,"h",["s"]);}body_0.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("esrf-landing-page",body_0);function body_0(chk,ctx){return chk.w("<div class=\"container-fluid\"><br /><div class=\"row padding-top-15\"><div class=\"col-8\"><div class=\"row\"><div class=\"col-12 h2 text-center text-uppercase font-weight-bold\">").f(ctx.getPath(false, ["data","title"]),ctx,"h").w("</div></div><hr><div class=\"row\"><div class=\"col-4\"><div class=\"myBorder-left\"><label> Proposal </label><div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","proposalNumber"]),ctx,"h").w("</div></div></div><div class=\"col-4\"><div class=\"myBorder-left\"><label> Publication year </label><div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","mintingYear"]),ctx,"h").w("</div></div></div> <div class=\"col-4\"><div class=\"myBorder-left\"><label> Beamline </label> ").h("eq",ctx,{"else":body_1,"block":body_2},{"key":ctx.getPath(false, ["data","beamlineUrl"]),"value":"noLink"},"h").w("</div></div></div><div class=\"padding-top-15\"></div><div class=\"row\"><div class=\"col-4\"><div class=\"myBorder-left\"><label> Session date </label><div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","sessionDate"]),ctx,"h").w("</div></div></div> <div class=\"col-4\"><div class=\"myBorder-left\"><label>Category </label><div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","proposalType"]),ctx,"h").w("</div></div></div> <div class=\"col-4\"> <div class=\"myBorder-left\"><label>Publisher </label> <div class=\"padding-left-15\"><a href=\"http://www.esrf.fr\"> ").f(ctx.getPath(false, ["data","publisher"]),ctx,"h").w(" </a> </div></div></div> </div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"myBorder-left\"><label> Abstract </label><div class=\"padding-left-15\">There is no abstract for this DOI</div></div> </div></div><hr><div class=\"row\"><div class=\"col-12\"><div class=\"card-deck\"><div class=\"card\"><div class=\"card-header text-center\"><label>Experimental report </label></div><div class=\"card-body padding10\"> </div><div class=\"card-footer\"> <button type=\"button\" class=\"btn btn-primary btn-lg btn-block disabled\"> <span class=\"fa fa-download whiteFont\"></span> Download</button></div></div><div class=\"card\"><div class=\"card-header text-center\"><label>Experimental data </label></div><div class=\"card-body padding10\"><p class=\"card-text\" >").f(ctx.getPath(false, ["data","accessMessage"]),ctx,"h",["s"]).w("</p></div><div class=\"card-footer\"><form action=\"https://icat.esrf.fr/#/browse/facility/ESRF/proposal/").f(ctx.getPath(false, ["data","proposalNumber"]),ctx,"h").w("/investigation/").f(ctx.getPath(false, ["data","investigationId"]),ctx,"h").w("/dataset\" target=\"_blank\"><button type=\"submit\" class=\"btn btn-primary btn-lg btn-block\"> Access data </button></form></div></div></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> ").f(ctx.getPath(false, ["data","citation"]),ctx,"h",["s"]).w(" </cite></div></div></div> </div></div> </div><div class=\"col-4\"><div class=\"row\"><div class=\"col-12\"><div class=\"card\"><div class=\"card-header text-center\"><label>Authors </label></div><div class=\"card-body text-center\">").s(ctx.getPath(false, ["data","creator"]),ctx,{"block":body_3},{}).w("</div></div></div></div></div></div> </div>");}body_0.__dustBody=!0;function body_1(chk,ctx){return chk.w("<div class=\"padding-left-15\"><a href=\"").f(ctx.getPath(false, ["data","beamlineUrl"]),ctx,"h").w("\" target=\"_blank\"> ").f(ctx.getPath(false, ["data","beamline"]),ctx,"h").w(" </a></div>");}body_1.__dustBody=!0;function body_2(chk,ctx){return chk.w("<div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","beamline"]),ctx,"h").w("</div>");}body_2.__dustBody=!0;function body_3(chk,ctx){return chk.w(" ").x(ctx.getPath(true, ["givenName"]),ctx,{"else":body_4,"block":body_5},{}).w(" ");}body_3.__dustBody=!0;function body_4(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["name"]),ctx,"h").w(" </br> ");}body_4.__dustBody=!0;function body_5(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["givenName"]),ctx,"h").w(" ").f(ctx.getPath(true, ["familyName"]),ctx,"h").w(" </br> ");}body_5.__dustBody=!0;return body_0}(dust));
(function(dust){dust.register("welcome-page",body_0);function body_0(chk,ctx){return chk.w(" <div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 flexCentered whiteFont\" style=\"color:#132577; font-size: 4rem; height: 200px; margin-top: 10px; margin-bottom: 10px;\">ESRF Data Portal</div></div></div><div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center\"><h2>About the portal</h2></div><div class=\"card-body padding10\">This page centralizes the services offered by the ESRF to access data stored at the facility as part of its data policy.<ul><li>DOI search engine</li><li>Data catalogue <a href=\"https://icat.esrf.fr\"> icat.esrf.fr</a></li></ul></div></div></div><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center \"><h2>DOI resolver</h2></div><div class=\"card-body padding10\"><p>The search engine below only finds DOI which have been minted at ESRF. </br> Use <a href=\"https://doi.org\">doi.org </a> search engine for any other DOI.</p><div class=\"row\"><div class=\"col-xl-9 padding-0\"><input id=\"doiSearchBox\" class=\"form-control\" placeholder=\"10.5072/...\" type=\"text\" required/><div class=\"text-danger\" id=\"error\"> </div> </div><div class=\"col padding-0\"> <input class=\"btn btn-primary\" type=\"submit\" value=\"Search\" onclick=\"searchDOI()\" /> </div></div> </div> </div></div><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center\"><h2>About DOI</h2></div><div class=\"card-body padding10\">The Digital Object Identifier (<a href=\"https://www.doi.org/\">DOI</a>) is a code composed of digits and characters. It identifies data in aunique and perennial way thus referencing this data worldwide. The DOI has two parts namely the DOI prefixand the DOI suffix separated by a slash (\"/\") as depicted below :</p><pre>prefix/suffix </pre></div></div></div></div></div>");}body_0.__dustBody=!0;return body_0}(dust));
\ No newline at end of file
(function(dust){dust.register("welcome-page",body_0);function body_0(chk,ctx){return chk.w(" <div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 flexCentered whiteFont\" style=\"color:#132577; font-size: 4rem; height: 200px; margin-top: 10px; margin-bottom: 10px;\">ESRF Data Portal</div></div></div><div class=\"container-fluid\"><div class=\"row\"><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center\"><h2>About the portal</h2></div><div class=\"card-body padding10\">This page centralizes the services offered by the ESRF to access data stored at the facility as part of its data policy.<ul><li>DOI search engine</li><li>Data catalogue <a href=\"https://icat.esrf.fr\" target=\"_blank\"> icat.esrf.fr</a></li></ul></div></div></div><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center \"><h2>DOI resolver</h2></div><div class=\"card-body padding10\"><p>The search engine below only finds DOI which have been minted at ESRF. </br> Use <a href=\"https://doi.org\">doi.org </a> search engine for any other DOI.</p><div class=\"row\"><div class=\"col-xl-9 padding-0\"><input id=\"doiSearchBox\" class=\"form-control\" placeholder=\"10.5072/...\" type=\"text\" required/><div class=\"text-danger\" id=\"error\"> </div> </div><div class=\"col padding-0\"> <input class=\"btn btn-primary\" type=\"submit\" value=\"Search\" onclick=\"searchDOI()\" /> </div></div> </div> </div></div><div class=\"col-12 col-md-4\"><div class=\"padding10\"><div class=\"card-header text-center\"><h2>About DOI</h2></div><div class=\"card-body padding10\">The Digital Object Identifier (<a href=\"https://www.doi.org/\">DOI</a>) is a code composed of digits and characters. It identifies data in aunique and perennial way thus referencing this data worldwide. The DOI has two parts namely the DOI prefixand the DOI suffix separated by a slash (\"/\") as depicted below :</p><pre>prefix/suffix </pre></div></div></div></div></div>");}body_0.__dustBody=!0;return body_0}(dust));
\ No newline at end of file
......@@ -79,7 +79,7 @@ Author.prototype.getRawFirstName = function(){
var firstNameRegExp = new RegExp(/^(.[^A-Z]+)+\b/);
var result = firstNameRegExp.exec(this.singleName); // null if not found
if (result){
this.firstName = result[1];
this.firstName = result[0];
}
return result; //returns null if it not found
}
......
This diff is collapsed.
function JsonExtractor() {
function JsonExtractor(json) {
}
/**
......@@ -15,31 +15,26 @@ JsonExtractor.prototype.extractInvestigationId = function(data) {
};
/**
* Extract fields value (beamline, proposal number and proposal type) from the
* data json object. Handles the possibility that the this fields are not found.
* Store the found fields in a new field which eases the use in the template.
* Extract field value (beamline, proposal number and proposal type) from the
* data json object. Returns nullif the field is not found.
*
* @param {object}
* data The data object reference which is sent to the dustjs
* @param {array}
* subject The array containing objects of interest
* template
* @param {string}
* field The text field which is searched
* @param {string}
* newField The new field name the result is stored in.
*/
JsonExtractor.prototype.extractFromSubject = function(field, data, newField) {
var counter = 0;
var found = false;
while (counter < data.subject[0].length && found === false) {
if (data.subject[0][counter].subject_scheme === field) {
data[newField] = data.subject[0][counter].text;
found = true;
JsonExtractor.prototype.getFieldFromSubject = function(subject, field ) {
if (subject){
if (subject[0]){
for (var i=0; subject[0].length; i++){
if (subject[0][i].subject_scheme === field) {
return subject[0][i].text;
}
}
}
counter++;
}
if (!found) {
data[newField] = "Not available";
}
}
return null;
};
/**
......
......@@ -15,7 +15,7 @@
This page centralizes the services offered by the ESRF to access data stored at the facility as part of its data policy.
<ul>
<li>DOI search engine</li>
<li>Data catalogue <a href="https://icat.esrf.fr"> icat.esrf.fr</a></li>
<li>Data catalogue <a href="https://icat.esrf.fr" target="_blank"> icat.esrf.fr</a></li>
</ul>
</div>
</div>
......
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