Commit c7733f3d authored by Maxime Chaillet's avatar Maxime Chaillet

Fix merge conflicts

parents 83f8745d 15c86b14
Pipeline #2159 failed with stages
......@@ -25,8 +25,9 @@ module.exports = function(grunt) {
'bower_components/jquery/dist/jquery.js',
'bower_components/bootstrap/dist/js/bootstrap.js',
'bower_components/dustjs-linkedin/dist/dust-full.min.js',
'bower_components/dustjs-helpers/dist/dust-helpers.min.js' ],
'min/doi.min.js': [
'bower_components/dustjs-helpers/dist/dust-helpers.min.js',
'bower_components/lodash/dist/lodash.min.js' ],
'min/doi.min.js': [
'src/*js']
}
}
......@@ -77,6 +78,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-include-source');
grunt.registerTask('default', ['jshint', 'dustjs', 'uglify', 'cssmin', 'wiredep:prod']);
grunt.registerTask('default', ['jshint', 'dustjs', 'uglify', 'cssmin']);
grunt.registerTask('dev', ['jshint', 'includeSource:dev', 'dustjs', 'cssmin', 'wiredep:dev']);
};
......@@ -28,6 +28,7 @@
"jquery": "^3.2.1",
"dustjs-linkedin": "^2.7.5",
"bootstrap": "^3.3.7",
"dustjs-helpers": "^1.7.3"
"dustjs-helpers": "^1.7.3",
"lodash": "^4.17.5"
}
}
......@@ -10,6 +10,7 @@
<!-- Using grunt-include-source, the proper js files created by us (not minified) are included below -->
<script src="src/beamlineUrl.js"></script>
<script src="src/doicontroller.js"></script>
<script src="src/doiview.js"></script>
......@@ -21,6 +22,7 @@
<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>
<!-- endbower -->
<!-- Using grunt-include-source, the proper all dustjs templates files (not minified are included below -->
......
......@@ -7,13 +7,10 @@
<link rel="stylesheet" href="/min/output.min.css" >
</head>
<!--
<script src="/min/doi-landing-page.min.js"></script>
-->
<script src="/min/components.min.js"></script>
<script src="/min/precompiled.templates.min.js"></script>
<script src="/src/doiview.js"></script>
<script src="/src/doicontroller.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);
......@@ -26,7 +23,6 @@
}
controller.displayMainContent(doi);
});
// search the doi entered in the search box
function searchDOI(){
......
This source diff could not be displayed because it is too large. You can view the blob instead.
function DOIController(e){this.server="https://data.datacite.org/",this.sessionId=null,this.acceptedPrefix=["10.5072","10.15151"],this.view=e}function findRegExpInText(e,t){return t.search(e)}function extractFieldsFromCategories(e){var t,i=e.categories;for(t in i)0!=findRegExpInText(/id/,i[t])&&0!=findRegExpInText(/bm/,i[t])||(e.beamline=i[t]);for(t in i)0==findRegExpInText(/\D+-/,i[t])&&(e.proposalNumber=i[t]);for(t in i)-1!=findRegExpInText(/\s/,i[t])&&(e.proposalType=i[t])}function DOIView(){}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.server+e,beforeSend:function(){t.view.setLoading("Retrieving data from Server")},complete:function(){t.view.setLoading(!1)},success:function(e){e?(extractFieldsFromCategories(e),dust.render("esrf-landing-page",{data:e},function(e,t){$("#main").html(t)})):"welcome-page"==this.origin?t.view.displayMessage("doi-not-found-page","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,i,o){"welcome-page"==this.origin?t.view.displayMessage("doi-not-found-page","Sorry, there was a connexion problem with the datacite server.","error"):t.view.displayMessage("doi-not-found-page","Sorry, there was a connexion problem with the datacite server.","main"),t.view.setLoading(!1)}}):"welcome-page"==this.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 this.acceptedPrefix.includes(t)},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},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,i){dust.render(e,{message:t},function(e,t){$("#"+i).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){var t,n=e.categories;for(t in n)0!=findRegExpInText(/id/,n[t])&&0!=findRegExpInText(/bm/,n[t])||(e.beamline=n[t]);for(t in n)0==findRegExpInText(/\D+-/,n[t])&&(e.proposalNumber=n[t]);for(t in n)-1!=findRegExpInText(/\s/,n[t])&&(e.proposalType=n[t])}function DOIView(){}var BEAMLINEURL=[{name:"BM05",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/BM05"},{name:"BM29",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/BM29"},{name:"CM01",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/CM01.html"},{name:"ID01",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID01"},{name:"ID06",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MEx/id06-large-volume-press.html"},{name:"ID11",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.fr/UsersAndScience/Experiments/StructMaterials/ID11"},{name:"ID16A",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16A"},{name:"ID16B",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16B"},{name:"ID17",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.fr/UsersAndScience/Experiments/CBS/ID17"},{name:"ID19",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.fr/home/UsersAndScience/Experiments/StructMaterials/ID19.html"},{name:"ID21",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID21"},{name:"ID22",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/id22"},{name:"ID23-1",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-1"},{name:"ID23-2",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-2"},{name:"ID29",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/Beamlines/content/content/id29.html"},{name:"ID30A1",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/MASSIF1"},{name:"ID30A3",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/id30a-3--massif-3.html"},{name:"ID30B",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",url:"http://www.esrf.eu/id30b"},{name:"ID32",startDate:"01 01 2000 00:00 +0000",endDate:"01 12 2100 00:00 +0000",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);var n=e.issued["date-parts"]-3,r=new Date(n+" 01 01 00:00 +0000");e.beamlineUrl=t.findsUrl(e.beamline,r),dust.render("esrf-landing-page",{data:e},function(e,t){$("#main").html(t)})}else"welcome-page"==this.origin?t.view.displayMessage("doi-not-found-page","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"==this.origin?t.view.displayMessage("doi-not-found-page","Sorry, there was a connexion problem with the datacite server.","error"):t.view.displayMessage("doi-not-found-page","Sorry, there was a connexion problem with the datacite server.","main"),t.view.setLoading(!1)}}):"welcome-page"==this.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),s=new Date(BEAMLINEURL[r].endDate);BEAMLINEURL[r].name.toLowerCase()===e.toLowerCase()&&t>a&&t<s&&(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
This diff is collapsed.
var BEAMLINEURL = [
{
"name" : "BM05",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.fr/UsersAndScience/Experiments/XNP/BM05"
},
{
"name" : "BM29",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/BM29"
},
{
"name" : "CM01",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/CM01.html"
},
{
"name" : "ID01",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID01"
},
{
"name" : "ID06",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/home/UsersAndScience/Experiments/MEx/id06-large-volume-press.html"
},
{
"name" : "ID11",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.fr/UsersAndScience/Experiments/StructMaterials/ID11"
},
{
"name" : "ID16A",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16A"
},
{
"name" : "ID16B",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.fr/UsersAndScience/Experiments/XNP/ID16B"
},
{
"name" : "ID17",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.fr/UsersAndScience/Experiments/CBS/ID17"
},
{
"name" : "ID19",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.fr/home/UsersAndScience/Experiments/StructMaterials/ID19.html"
},
{
"name" : "ID21",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/UsersAndScience/Experiments/XNP/ID21"
},
{
"name" : "ID22",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/id22"
},
{
"name" : "ID23-1",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-1"
},
{
"name" : "ID23-2",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/UsersAndScience/Experiments/MX/About_our_beamlines/ID23-2"
},
{
"name" : "ID29",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/home/UsersAndScience/Experiments/Beamlines/content/content/id29.html"
},
{
"name" : "ID30A1",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/MASSIF1"
},
{
"name" : "ID30A3",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/home/UsersAndScience/Experiments/MX/About_our_beamlines/id30a-3--massif-3.html"
},
{
"name" : "ID30B",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/id30b"
},
{
"name" : "ID32",
"startDate" : "01 01 2000 00:00 +0000",
"endDate" : "01 12 2100 00:00 +0000",
"url" : "http://www.esrf.eu/ID32"
}
];
\ No newline at end of file
function DOIController(view) {
this.server = "https://data.datacite.org/";
this.sessionId = null;
this.acceptedPrefix = [ "10.5072", "10.15151" ];
// doiServer = the server which provides doi details from a given doi name.
this.doiServer = "https://data.datacite.org/";
// 10.5072 is the test esrf doi prefix;
// 10.15151 is the production esrf doi prefix;
this.acceptedPrefix = [ "10.5072", "10.15151" ];
this.view = view;
}
......@@ -19,24 +18,30 @@ DOIController.prototype.getData = function(doi) {
Accept : "application/vnd.citationstyles.csl+json"
},
type : "GET",
url : this.server + doi,
url : this.doiServer + doi,
beforeSend : function() {
_this.view.setLoading("Retrieving data from Server");
},
complete : function() {
_this.view.setLoading(false);
},
success : function(data) {
if (data) {
// extract fields from data.categories
extractFieldsFromCategories(data);
// send to dust render
success : function(doiData) {
if (doiData) {
// extract fields from data.categories
extractFieldsFromCategories(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 01 00:00 +0000");
doiData.beamlineUrl = _this.findsUrl(doiData.beamline, experimentalDate);
// send to dust render
dust.render('esrf-landing-page', {
data : data
}, function(err, out) {
$("#main").html(out);
});
data : doiData
}, function(err, out) {
$("#main").html(out);
}
);
} else {
if (this.origin == "welcome-page") {
_this.view.displayMessage('doi-not-found-page', "Sorry, the requested DOI was not found.", "error" );
......@@ -68,7 +73,7 @@ DOIController.prototype.getData = function(doi) {
// return false otherwise
DOIController.prototype.hasAcceptedPrefix = function(doi) {
var prefix = doi.split('/')[0];
return this.acceptedPrefix.includes(prefix);
return (_.findIndex(this.acceptedPrefix, function(o){ return prefix==o; }) != -1);
};
// Selects what will be displayed in the main id div
......@@ -91,6 +96,28 @@ DOIController.prototype.setOrigin = function(origin){
this.origin = origin;
};
// Search the corresponding url for a given beamline name
// @param: beamline, the beamline name
// @param: date, the date the experiment was performed. (Date Object)
// @return the url of the beamLine, "noLink" if it is not found
DOIController.prototype.findsUrl = function(beamline, date){
var result = "noLink";
var i = 0;
while(BEAMLINEURL[i] && result === "noLink") {
var startDate = new Date(BEAMLINEURL[i].startDate);
var endDate = new Date(BEAMLINEURL[i].endDate);
if (BEAMLINEURL[i].name.toLowerCase() === beamline.toLowerCase() &&
date > startDate &&
date < endDate
) {
result = BEAMLINEURL[i].url;
}
i++;
}
return result;
};
//HELPER FUNCTIONS
// Finds a regular expression in a text
......
......@@ -43,7 +43,11 @@
<div class="card-header text-center">
<label>Beamline </label>
</div>
<div class="card-body text-center">{data.beamline}</div>
{@eq key=data.beamlineUrl value="noLink"}
<div class="card-body text-center"> {data.beamline} </div>
{:else}
<div class="card-body text-center"><a href="{data.beamlineUrl}"> {data.beamline} </a> </div>
{/eq}
</div>
</div>
</div>
......
......@@ -31,7 +31,7 @@
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="form-row">
<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>
......
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