Commit 5d7a48d0 authored by Maxime Chaillet's avatar Maxime Chaillet

change the header on the ajax call to retrieve all the data from datacite....

change the header on the ajax call to retrieve all the data from datacite. Ajust the reading of the data from the JSON because the fields have different name and the json structure is different.
parent 2fbb5f8e
function DOIController(e){this.doiServer="https://data.datacite.org/",this.acceptedPrefix=["10.5072","10.15151"],this.view=e}function findRegExpInText(e,t){return t.search(e)}function extractFieldsFromCategories(e){var t,n=e.categories;for(t in n)0==findRegExpInText(/^id/,n[t])||0==findRegExpInText(/^bm/,n[t])?e.beamline=n[t]:0==findRegExpInText(/^\D+-/,n[t])?e.proposalNumber=n[t]:e.proposalType=n[t]}function extractFieldsFromDoi(e){var t=RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);e.investigationId=t.exec(e.DOI)[1]}function createCitation(e){var t=_.transform(e.author,function(e,t){if(t.given)e.push(t.family+" "+t.given);else{var n=new RegExp(/\s([^a-z]+$)/),r=new RegExp(/^(.[^A-Z]+)+\b/),a=n.exec(t.literal),i=r.exec(t.literal);a&&i?e.push(a[1]+" "+i[0].trim()):e.push(t.literal)}},[]),n=_.join(t,"; ")+". ("+e.issued["date-parts"]+"). "+e.title+". "+e.publisher+" (ESRF). <a href='https://doi.esrf.fr/"+e.DOI+"'> doi:"+e.DOI+"</a>";e.citation=n}function DOIView(){}var BEAMLINEURL=[{name:"BM05",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/BM05"},{name:"BM29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/BM29"},{name:"CM01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/CM01.html"},{name:"ID01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID01"},{name:"ID06",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MEx/id06-large-volume-press.html"},{name:"ID11",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/StructMaterials/ID11"},{name:"ID16A",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16A"},{name:"ID16B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16B"},{name:"ID17",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/CBS/ID17"},{name:"ID19",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/home/UsersAndScience/Experiments/StructMaterials/ID19.html"},{name:"ID21",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID21"},{name:"ID22",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id22"},{name:"ID23-1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-1"},{name:"ID23-2",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-2"},{name:"ID29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/Beamlines/content/content/id29.html"},{name:"ID30A1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/MASSIF1"},{name:"ID30A3",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/id30a-3--massif-3.html"},{name:"ID30B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id30b"},{name:"ID32",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/ID32"}];DOIController.prototype.getData=function(e){var t=this;this.view.setDOI(e),this.hasAcceptedPrefix(e)?$.ajax({headers:{Accept:"application/vnd.citationstyles.csl+json"},type:"GET",url:this.doiServer+e,beforeSend:function(){t.view.setLoading("Retrieving data from Server")},complete:function(){t.view.setLoading(!1)},success:function(e){if(e){extractFieldsFromCategories(e),extractFieldsFromDoi(e),createCitation(e);var n=e.issued["date-parts"]-3,r=new Date(n+"-01-01T00:00+00:00");e.beamlineUrl=t.findsUrl(e.beamline,r),dust.render("esrf-landing-page",{data:e},function(e,t){$("#main").html(t)})}else"welcome-page"===t.origin?t.view.displayMessage("doi-not-found-page2","Sorry, the requested DOI was not found.","error"):t.view.displayMessage("doi-not-found-page","Sorry, the requested DOI was not found.","main")},error:function(e,n,r){"welcome-page"===t.origin?t.view.displayMessage("doi-not-found-page2","<h3> Not found ! </h3> <p> Sorry, there was a connexion problem with the datacite server. </p>","error"):t.view.displayMessage("doi-not-found-page","<h2> Not found ! </h2> <p> Sorry, there was a connexion problem with the datacite server. </p>","main"),t.view.setLoading(!1)}}):"welcome-page"===t.origin?t.view.displayMessage("doi-not-found-page2","<h3> Not found ! </h3> <p> The DOI <b>"+e+'</b> was not found at ESRF because its prefix is not ESRF specific. Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>',"error"):t.view.displayMessage("doi-not-found-page","<h2> Not found ! </h2> <p> The DOI <b>"+e+'</b> was not found at ESRF because its prefix is not ESRF specific. </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>.</p>',"main")},DOIController.prototype.hasAcceptedPrefix=function(e){var t=e.split("/")[0];return-1!=_.findIndex(this.acceptedPrefix,function(e){return t==e})},DOIController.prototype.displayMainContent=function(e){"welcome-page"===this.origin&&dust.render("welcome-page",{},function(e,t){$("#main").html(t)}),"index"===this.origin&&this.getData(e)},DOIController.prototype.setOrigin=function(e){this.origin=e},DOIController.prototype.findsUrl=function(e,t){for(var n="noLink",r=0;BEAMLINEURL[r]&&"noLink"===n;){var a=new Date(BEAMLINEURL[r].startDate),i=new Date(BEAMLINEURL[r].endDate);BEAMLINEURL[r].name.toLowerCase()===e.toLowerCase()&&t>a&&t<i&&(n=BEAMLINEURL[r].url),r++}return n},DOIView.prototype.setLoading=function(e){0!=e?$("body").addClass("loading"):$("body").removeClass("loading")},DOIView.prototype.setDOI=function(e){$("#doiPanel").html(e)},DOIView.prototype.displayMessage=function(e,t,n){dust.render(e,{message:t},function(e,t){$("#"+n).html(t)})};
\ No newline at end of file
function DOIController(e){this.doiServer="https://data.datacite.org/",this.acceptedPrefix=["10.5072","10.15151"],this.view=e}function findRegExpInText(e,t){return t.search(e)}function extractFieldsFromCategories(e){_.forEach(e.subject[0],function(t){switch(t.subject_scheme){case"Proposal Type Description":e.proposalType=t.text;break;case"Proposal":e.proposalNumber=t.text;break;case"instrument":e.beamline=t.text}})}function extractFieldsFromDoi(e){var t=RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);e.investigationId=t.exec(e.doi)[1]}function createCitation(e){var t=_.transform(e.creator,function(e,t){if(t.givenName)e.push(t.familyName+" "+t.givenName);else{var r=new RegExp(/\s([^a-z]+$)/),n=new RegExp(/^(.[^A-Z]+)+\b/),a=r.exec(t.name),s=n.exec(t.name);a&&s?e.push(a[1]+" "+s[0].trim()):e.push(t.name)}},[]),r=_.join(t,"; ")+". ("+e.date_registered+"). "+e.title+". "+e.publisher+" (ESRF). <a href='https://doi.esrf.fr/"+e.DOI+"'> doi:"+e.doi+"</a>";e.citation=r}function DOIView(){}var BEAMLINEURL=[{name:"BM05",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/BM05"},{name:"BM29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/BM29"},{name:"CM01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/CM01.html"},{name:"ID01",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID01"},{name:"ID06",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MEx/id06-large-volume-press.html"},{name:"ID11",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/StructMaterials/ID11"},{name:"ID16A",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16A"},{name:"ID16B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16B"},{name:"ID17",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/UsersAndScience/Experiments/CBS/ID17"},{name:"ID19",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.fr/home/UsersAndScience/Experiments/StructMaterials/ID19.html"},{name:"ID21",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID21"},{name:"ID22",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id22"},{name:"ID23-1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-1"},{name:"ID23-2",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-2"},{name:"ID29",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/Beamlines/content/content/id29.html"},{name:"ID30A1",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/MASSIF1"},{name:"ID30A3",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/id30a-3--massif-3.html"},{name:"ID30B",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/id30b"},{name:"ID32",startDate:"2000-01-01T00:00+00:00",endDate:"2100-12-31T00:00+00:00",url:"http://www.esrf.eu/ID32"}];DOIController.prototype.getData=function(e){var t=this;this.view.setDOI(e),this.hasAcceptedPrefix(e)?$.ajax({headers:{Accept:"application/vnd.datacite.datacite+json"},type:"GET",url:this.doiServer+e,beforeSend:function(){t.view.setLoading("Retrieving data from Server")},complete:function(){t.view.setLoading(!1)},success:function(e){if(e){extractFieldsFromCategories(e),extractFieldsFromDoi(e),createCitation(e);var r=new Date(e.date_collected+"T00:00+00:00");e.beamlineUrl=t.findsUrl(e.beamline,r),dust.render("esrf-landing-page",{data:e},function(e,t){$("#main").html(t)})}else"welcome-page"===t.origin?t.view.displayMessage("doi-not-found-page2","Sorry, the requested DOI was not found.","error"):t.view.displayMessage("doi-not-found-page","Sorry, the requested DOI was not found.","main")},error:function(e,r,n){"welcome-page"===t.origin?t.view.displayMessage("doi-not-found-page2","<h3> Not found ! </h3> <p> Sorry, there was a connexion problem with the datacite server. </p>","error"):t.view.displayMessage("doi-not-found-page","<h2> Not found ! </h2> <p> Sorry, there was a connexion problem with the datacite server. </p>","main"),t.view.setLoading(!1)}}):"welcome-page"===t.origin?t.view.displayMessage("doi-not-found-page2","<h3> Not found ! </h3> <p> The DOI <b>"+e+'</b> was not found at ESRF because its prefix is not ESRF specific. Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>. </p>',"error"):t.view.displayMessage("doi-not-found-page","<h2> Not found ! </h2> <p> The DOI <b>"+e+'</b> was not found at ESRF because its prefix is not ESRF specific. </br> Please use the DOI search engine at <a href="https://www.doi.org"> doi.org</a>.</p>',"main")},DOIController.prototype.hasAcceptedPrefix=function(e){var t=e.split("/")[0];return-1!=_.findIndex(this.acceptedPrefix,function(e){return t==e})},DOIController.prototype.displayMainContent=function(e){"welcome-page"===this.origin&&dust.render("welcome-page",{},function(e,t){$("#main").html(t)}),"index"===this.origin&&this.getData(e)},DOIController.prototype.setOrigin=function(e){this.origin=e},DOIController.prototype.findsUrl=function(e,t){for(var r="noLink",n=0;BEAMLINEURL[n]&&"noLink"===r;){var a=new Date(BEAMLINEURL[n].startDate),s=new Date(BEAMLINEURL[n].endDate);BEAMLINEURL[n].name.toLowerCase()===e.toLowerCase()&&t>a&&t<s&&(r=BEAMLINEURL[n].url),n++}return r},DOIView.prototype.setLoading=function(e){0!=e?$("body").addClass("loading"):$("body").removeClass("loading")},DOIView.prototype.setDOI=function(e){$("#doiPanel").html(e)},DOIView.prototype.displayMessage=function(e,t,r){dust.render(e,{message:t},function(e,t){$("#"+r).html(t)})};
\ No newline at end of file
(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-3\"><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-3\"><div class=\"myBorder-left\"><label> Release year </label><div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","issued","date-parts"]),ctx,"h").w("</div></div></div> <div class=\"col-6\"><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-6\"><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-6\"> <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\" >The data is currently only available to download if you are a member of the proposal team.</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\"> <span class=\"fa fa-download whiteFont\"></span> Download </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","author"]),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("\"> ").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, ["given"]),ctx,{"else":body_4,"block":body_5},{}).w(" ");}body_3.__dustBody=!0;function body_4(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["literal"]),ctx,"h").w(" </br> ");}body_4.__dustBody=!0;function body_5(chk,ctx){return chk.w(" ").f(ctx.getPath(true, ["given"]),ctx,"h").w(" ").f(ctx.getPath(true, ["family"]),ctx,"h").w(" </br> ");}body_5.__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-3\"><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-3\"><div class=\"myBorder-left\"><label> Publication year </label><div class=\"padding-left-15\">").f(ctx.getPath(false, ["data","publication_year"]),ctx,"h").w("</div></div></div> <div class=\"col-6\"><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-6\"><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-6\"> <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\" >The data is currently only available to download if you are a member of the proposal team.</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\"> <span class=\"fa fa-download whiteFont\"></span> Download </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("\"> ").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
......@@ -15,7 +15,7 @@ DOIController.prototype.getData = function(doi) {
if (this.hasAcceptedPrefix(doi)) {
$.ajax({
headers : {
Accept : "application/vnd.citationstyles.csl+json"
Accept : "application/vnd.datacite.datacite+json"
},
type : "GET",
url : this.doiServer + doi,
......@@ -34,10 +34,9 @@ DOIController.prototype.getData = function(doi) {
extractFieldsFromDoi(doiData);
// create citation
createCitation(doiData);
// Retrieve the URL corresponding to the beamline name. Currently, the date of the
// experiment is calculated from the publicationYear.
var experimentalYear = doiData.issued["date-parts"] - 3 ;
var experimentalDate = new Date(experimentalYear + "-01-01T00:00+00:00");
// Retrieve the URL corresponding to the beamline name.
var experimentalDate = new Date(doiData.date_collected + "T00:00+00:00");
doiData.beamlineUrl = _this.findsUrl(doiData.beamline, experimentalDate);
// send to dust render
......@@ -134,24 +133,22 @@ function findRegExpInText(regExp, text) {
}
// Extract beamline, proposal number and proposal type from the data.categories fields as received from the json response.
// Extract beamline, proposal number and proposal type from the data fields as received from the json response.
// Add the corresponding fields in the data object
// @data: the data object, it is a reference
function extractFieldsFromCategories(data) {
var catArray = data.categories;
var index;
for (index in catArray) {
// extract beamline from data.categories
if ((findRegExpInText(/^id/, catArray[index]) == 0) || (findRegExpInText(/^bm/, catArray[index]) == 0)) {
data.beamline = catArray[index];
} else if (findRegExpInText(/^\D+-/, catArray[index]) == 0) {
// extract proposal number from data.categories
data.proposalNumber = catArray[index];
} else {
// catArray[index] is the proposal type. Note that proposal type can be composed of several words separated by spaces or a single word.
data.proposalType = catArray[index];
}
}
function extractFieldsFromCategories(data) {
_.forEach(data.subject[0], function(value){
switch (value.subject_scheme ) {
case "Proposal Type Description":
data.proposalType = value.text;
break;
case "Proposal":
data.proposalNumber = value.text;
break;
case "instrument":
data.beamline = value.text;
}
});
}
//Extract investigationId from the data.doi field as received from the json response.
......@@ -160,31 +157,31 @@ function extractFieldsFromCategories(data) {
function extractFieldsFromDoi(data) {
//extract the investigationId from the doi.
var regExp = RegExp(/\/\w*-*[Ee][Ss][Rr][Ff]-[Ee][Ss]-(\d+)$/);
data.investigationId = regExp.exec(data.DOI)[1];
data.investigationId = regExp.exec(data.doi)[1];
}
// Create the citation for the current work. Citation proposes a recommendation to the reader
// on how to cite this work.
//@data: the data object, it is a reference
function createCitation(data) {
var authorList = _.transform(data.author, function(result, obj) {
if (obj.given) {
result.push(obj.family + ' ' + obj.given);
var authorList = _.transform(data.creator, function(result, obj) {
if (obj.givenName) {
result.push(obj.familyName + ' ' + obj.givenName);
} else {
// cells of data.authors contains First Name FAMILY NAME most of the time.
// cells of data.creator.name contains First Name FAMILY NAME most of the time.
// 1 - detect the words in UPPERCASE as FAMILY name
// 2 - detect the words in LOWERcase except first letter which can optionally be uppercase.
// 2 - detect the words in lowercase except first letter which can optionally be uppercase.
// 3 - flip them
var familyRegExp = new RegExp(/\s([^a-z]+$)/);
var firstNameRegExp = new RegExp(/^(.[^A-Z]+)+\b/);
var familyName = familyRegExp.exec(obj.literal);
var firstName = firstNameRegExp.exec(obj.literal);
var familyName = familyRegExp.exec(obj.name);
var firstName = firstNameRegExp.exec(obj.name);
// Sometime all words are uppercase or lowercase or uppercase for the first letter only. In this case we can not distinguish between family name and firstname. => string unchanged
if (!familyName || !firstName ){
result.push(obj.literal);
result.push(obj.name);
} else {
result.push(familyName[1] + " " + firstName[0].trim());
}
......@@ -195,12 +192,12 @@ function createCitation(data) {
var citation = authorString +
'. (' +
data.issued['date-parts'] +
data.date_registered +
'). ' +
data.title +
'. ' +
data.publisher +
' (ESRF). ' +
" <a href='https://doi.esrf.fr/" + data.DOI + "'> doi:" + data.DOI + "</a>";
" <a href='https://doi.esrf.fr/" + data.DOI + "'> doi:" + data.doi + "</a>";
data.citation = citation;
}
......@@ -17,8 +17,8 @@
</div>
<div class="col-3">
<div class="myBorder-left">
<label> Release year </label>
<div class="padding-left-15">{data.issued.date-parts}</div>
<label> Publication year </label>
<div class="padding-left-15">{data.publication_year}</div>
</div>
</div>
<div class="col-6">
......@@ -121,7 +121,7 @@
<label>Authors </label>
</div>
<div class="card-body text-center">
{#data.author} {?.given} {.given} {.family} </br> {:else} {.literal} </br> {/.given} {/data.author}
{#data.creator} {?.givenName} {.givenName} {.familyName} </br> {:else} {.name} </br> {/.givenName} {/data.creator}
</div>
</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