Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Maxime Chaillet
doi-landing-page
Commits
e695453e
Commit
e695453e
authored
Oct 11, 2018
by
Maxime Chaillet
Browse files
work in progress
parent
459a58d1
Pipeline
#5885
failed with stages
Changes
17
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
www/dev.html
View file @
e695453e
...
...
@@ -7,26 +7,29 @@
<link
href=
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel=
"stylesheet"
>
<!-- Using grunt-wiredep, the proper js files from bower components are included below -->
<!-- bower:js -->
<script
src=
"bower_components/jquery/dist/jquery.js"
></script>
<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>
<script
src=
"bower_components/moment/moment.js"
></script>
<!-- endbower -->
<!-- Using grunt-include-source, the proper js files created by us (not minified) are included below -->
<script
src=
"src/author.js"
></script>
<script
src=
"src/beamlineurl.js"
></script>
<script
src=
"src/citation.js"
></script>
<script
src=
"src/constants.js"
></script>
<script
src=
"src/doicontroller.js"
></script>
<script
src=
"src/doiData.js"
></script>
<script
src=
"src/doiview.js"
></script>
<script
src=
"src/event.js"
></script>
<script
src=
"src/experimentalreportcontroller.js"
></script>
<script
src=
"src/jsonextractor.js"
></script>
<script
src=
"src/metadataTableHelper.js"
></script>
<!-- Using grunt-wiredep, the proper js files from bower components are included below -->
<!-- bower:js -->
<script
src=
"bower_components/jquery/dist/jquery.js"
></script>
<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>
<script
src=
"bower_components/moment/moment.js"
></script>
<!-- endbower -->
<!-- bower:css -->
<link
rel=
"stylesheet"
href=
"bower_components/bootstrap/dist/css/bootstrap.css"
/>
...
...
www/dev.tpl.html
View file @
e695453e
...
...
@@ -7,12 +7,13 @@
<link
href=
"https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
rel=
"stylesheet"
>
<!-- Using grunt-include-source, the proper js files created by us (not minified) are included below -->
<!-- include: "type": "js", "files": "src/*.js" -->
<!-- Using grunt-wiredep, the proper js files from bower components are included below -->
<!-- bower:js -->
<!-- endbower -->
<!-- Using grunt-include-source, the proper js files created by us (not minified) are included below -->
<!-- include: "type": "js", "files": "src/*.js" -->
<!-- bower:css -->
<!-- endbower -->
...
...
www/index.html
View file @
e695453e
...
...
@@ -72,4 +72,4 @@
</div>
</footer>
</body>
</html>
\ No newline at end of file
</html>
www/min/components.min.js
View file @
e695453e
This diff is collapsed.
Click to expand it.
www/min/doi.min.js
View file @
e695453e
This diff is collapsed.
Click to expand it.
www/min/precompiled.templates.min.js
View file @
e695453e
This diff is collapsed.
Click to expand it.
www/src/constants.js
0 → 100644
View file @
e695453e
var
CONSTANTS
=
{
ES_RESOURCE_TYPE
:
"
experimental session resource type
"
,
DC_RESOURCE_TYPE
:
"
dataset collection resource type
"
};
//module.exports = CONSTANTS;
www/src/doiData.js
View file @
e695453e
...
...
@@ -3,6 +3,7 @@ function DoiData() {
}
/**
* Get the accessibility status
* @param {string} resourceType the resource type for this DOI
* @param {string} sessionDate The timeStamp the experiment was started
* @param {string} publiclyAccessibleYear The year the data will be publicly accesssible.
* @return {string}
...
...
@@ -10,19 +11,24 @@ function DoiData() {
* "Restricted access" : the data is still under embargo. Only accessible to experimental team members
*
* */
DoiData
.
prototype
.
getAccessibilityStatus
=
function
(
sessionDate
,
publiclyAccessibleYear
)
{
DoiData
.
prototype
.
getAccessibilityStatus
=
function
(
resourceType
,
sessionDate
,
publiclyAccessibleYear
)
{
if
(
resourceType
)
{
if
(
resourceType
===
CONSTANTS
.
ES_RESOURCE_TYPE
)
{
if
(
publiclyAccessibleYear
&&
sessionDate
)
{
var
publiclyAvailableDate
=
moment
(
publiclyAccessibleYear
,
"
YYYY
"
);
var
now
=
moment
();
if
(
publiclyAccessibleYear
&&
sessionDate
)
{
var
publiclyAvailableDate
=
moment
(
publiclyAccessibleYear
,
"
YYYY
"
);
var
now
=
moment
();
if
(
now
>
publiclyAvailableDate
)
{
if
(
now
>
publiclyAvailableDate
)
{
return
"
Open access
"
;
}
else
if
(
now
<=
publiclyAvailableDate
)
{
return
"
Restricted access
"
;
}
}
}
else
if
(
resourceType
===
CONSTANTS
.
DC_RESOURCE_TYPE
){
return
"
Open access
"
;
}
else
if
(
now
<=
publiclyAvailableDate
)
{
return
"
Restricted access
"
;
}
}
console
.
log
(
"
Failed to determine whether the accessibility of the DOI.
"
);
console
.
log
(
"
Failed to determine whether the accessibility of the DOI.
"
);
return
"
Accessibility status could not be determined
"
;
};
www/src/doicontroller.js
View file @
e695453e
function
DOIController
(
view
)
{
var
_this
=
this
;
// doiServer = the server which provides doi details from a given doi name.
//this.doiServer = "https://data.datacite.org/";
this
.
doiServer
=
"
https://api.test.datacite.org/
"
var
_this
=
this
;
// doiServer = the server which provides doi details from a given doi name.
//this.doiServer = "https://data.datacite.org/";
this
.
doiServer
=
"
https://api.test.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
;
// 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
;
this
.
experimentalReportController
=
new
ExperimentalReportController
();
this
.
experimentalReportController
=
new
ExperimentalReportController
();
this
.
experimentalReportController
.
onSuccess
.
attach
(
function
(
sender
,
data
)
{
_this
.
view
.
renderExperimentalReportData
(
data
);
});
this
.
experimentalReportController
.
onSuccess
.
attach
(
function
(
sender
,
data
)
{
_this
.
view
.
renderExperimentalReportData
(
data
);
});
this
.
experimentalReportController
.
onError
.
attach
(
function
(
sender
,
data
)
{
console
.
log
(
"
Error when retrieving fileList from SMIS.
"
);
_this
.
view
.
renderErrorForExperimentalReport
();
});
this
.
experimentalReportController
.
onError
.
attach
(
function
(
sender
,
data
)
{
console
.
log
(
"
Error when retrieving fileList from SMIS.
"
);
_this
.
view
.
renderErrorForExperimentalReport
();
});
}
...
...
@@ -28,91 +28,94 @@ function DOIController(view) {
* fields when the doi does not exist. In this case the following code is
* executed. Reloading the page is treated by .fail as it should be.
*/
DOIController
.
prototype
.
isValidDOIData
=
function
(
doiData
)
{
if
(
_
.
keysIn
(
doiData
).
length
>
3
)
{
return
_
.
find
(
_
.
keysIn
(
doiData
),
function
(
value
)
{
return
value
===
"
title
"
;
}).
length
>
0
;
}
return
false
;
DOIController
.
prototype
.
isValidDOIData
=
function
(
doiData
)
{
if
(
_
.
keysIn
(
doiData
).
length
>
3
)
{
return
_
.
find
(
_
.
keysIn
(
doiData
),
function
(
value
)
{
return
value
===
"
title
"
;
}).
length
>
0
;
}
return
false
;
};
DOIController
.
prototype
.
getData
=
function
(
doi
)
{
var
_this
=
this
;
this
.
view
.
setDOIInTopBanner
(
doi
);
if
(
this
.
hasAcceptedPrefix
(
doi
))
{
$
.
ajax
({
headers
:
{
Accept
:
"
application/vnd.datacite.datacite+json
"
},
type
:
"
GET
"
,
timeout
:
15000
,
// triggers timeout when request pends longer than
// 5000ms
url
:
this
.
doiServer
+
doi
,
beforeSend
:
function
(
xhr
)
{
_this
.
view
.
setLoading
(
"
Retrieving data from Server
"
);
xhr
.
setRequestHeader
(
"
Authorization
"
,
"
Basic
"
+
btoa
(
"
DATACITE.ESRF
"
+
"
:
"
+
"
datacyte1
"
));
// to be removed as well as the parameter
},
complete
:
function
()
{
_this
.
view
.
setLoading
(
false
);
}
})
.
done
(
function
(
data
)
{
if
(
data
)
{
// Test abnormal length of the json object
if
(
!
_this
.
isValidDOIData
(
data
))
{
_this
.
view
.
renderError
(
"
Not Found
"
,
_this
.
origin
);
}
else
{
var
doiData
=
new
DoiData
();
doiData
.
title
=
data
.
title
;
doiData
.
doi
=
data
.
doi
.
toUpperCase
();
doiData
.
dataciteLink
=
_this
.
doiServer
+
doi
;
doiData
.
publisher
=
data
.
publisher
;
doiData
.
creator
=
data
.
creator
;
var
jsonExtractor
=
new
JsonExtractor
();
doiData
.
mintingYear
=
jsonExtractor
.
getMintingYear
(
data
);
doiData
.
sessionDate
=
jsonExtractor
.
getSessionDate
(
data
);
doiData
.
publiclyAccessibleYear
=
data
.
publication_year
;
doiData
.
proposalType
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
Proposal Type Description
"
);
doiData
.
proposalNumber
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
Proposal
"
);
_this
.
experimentalReportController
.
requestFilenameList
(
doiData
.
proposalNumber
);
doiData
.
beamline
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
instrument
"
);
doiData
.
investigationId
=
jsonExtractor
.
extractInvestigationId
(
data
);
doiData
.
accessibility
=
doiData
.
getAccessibilityStatus
(
doiData
.
sessionDate
,
doiData
.
publiclyAccessibleYear
);
doiData
.
accessMessage
=
_this
.
view
.
setDataAccessMessage
(
doiData
);
doiData
.
citation
=
_this
.
createCitation
(
data
);
doiData
.
resourceTypeGeneral
=
jsonExtractor
.
getResourceTypeGeneral
(
data
);
doiData
.
resourceType
=
jsonExtractor
.
getResourceType
(
data
);
// Set the URL corresponding to the beamline name.
if
(
data
.
date_collected
)
{
var
experimentalDate
=
moment
(
data
.
date_collected
);
doiData
.
beamlineUrl
=
_this
.
getBeamlineUrl
(
doiData
.
beamline
,
experimentalDate
);
}
else
{
doiData
.
beamlineUrl
=
"
noLink
"
;
}
// send to dust render
_this
.
view
.
renderDOIData
(
doiData
);
}
}
}).
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
_this
.
view
.
renderError
(
jqXHR
,
errorThrown
,
_this
.
origin
);
_this
.
view
.
setLoading
(
false
);
});
}
else
{
_this
.
view
.
renderError
(
"
Bad Prefix
"
,
_this
.
origin
);
}
DOIController
.
prototype
.
getData
=
function
(
doi
)
{
var
_this
=
this
;
this
.
view
.
setDOIInTopBanner
(
doi
);
if
(
this
.
hasAcceptedPrefix
(
doi
))
{
$
.
ajax
({
headers
:
{
Accept
:
"
application/vnd.datacite.datacite+json
"
},
type
:
"
GET
"
,
timeout
:
15000
,
// triggers timeout when request pends longer than
// 5000ms
url
:
this
.
doiServer
+
doi
,
beforeSend
:
function
(
xhr
)
{
_this
.
view
.
setLoading
(
"
Retrieving data from Server
"
);
xhr
.
setRequestHeader
(
"
Authorization
"
,
"
Basic
"
+
btoa
(
"
DATACITE.ESRF
"
+
"
:
"
+
"
datacyte1
"
));
// to be removed as well as the parameter
},
complete
:
function
()
{
_this
.
view
.
setLoading
(
false
);
}
})
.
done
(
function
(
data
)
{
if
(
data
)
{
// Test abnormal length of the json object
if
(
!
_this
.
isValidDOIData
(
data
))
{
_this
.
view
.
renderError
(
"
Not Found
"
,
_this
.
origin
);
}
else
{
var
doiData
=
new
DoiData
();
doiData
.
title
=
data
.
title
;
doiData
.
doi
=
data
.
doi
.
toUpperCase
();
doiData
.
dataciteLink
=
_this
.
doiServer
+
doi
;
doiData
.
publisher
=
data
.
publisher
;
doiData
.
creator
=
data
.
creator
;
var
jsonExtractor
=
new
JsonExtractor
();
doiData
.
mintingYear
=
jsonExtractor
.
getMintingYear
(
data
);
doiData
.
sessionDate
=
jsonExtractor
.
getSessionDate
(
data
);
doiData
.
publiclyAccessibleYear
=
data
.
publication_year
;
doiData
.
proposalType
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
Proposal Type Description
"
);
doiData
.
proposalName
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
Proposal
"
);
_this
.
experimentalReportController
.
requestFilenameList
(
doiData
.
proposalName
);
doiData
.
beamline
=
jsonExtractor
.
getFieldFromSubject
(
data
.
subject
,
"
Instrument
"
);
doiData
.
investigationId
=
jsonExtractor
.
extractInvestigationId
(
data
);
doiData
.
resourceType
=
jsonExtractor
.
getResourceType
(
data
);
doiData
.
accessibility
=
doiData
.
getAccessibilityStatus
(
doiData
.
resourceType
,
doiData
.
sessionDate
,
doiData
.
publiclyAccessibleYear
);
doiData
.
accessMessage
=
_this
.
view
.
setDataAccessMessage
(
doiData
);
doiData
.
citation
=
_this
.
createCitation
(
data
);
doiData
.
resourceTypeGeneral
=
jsonExtractor
.
getResourceTypeGeneral
(
data
);
// constants passed for tests in the templates
doiData
.
DC_RESOURCE_TYPE
=
CONSTANTS
.
DC_RESOURCE_TYPE
;
doiData
.
ES_RESOURCE_TYPE
=
CONSTANTS
.
ES_RESOURCE_TYPE
;
// Set the URL corresponding to the beamline name.
if
(
data
.
date_collected
)
{
var
experimentalDate
=
moment
(
data
.
date_collected
);
doiData
.
beamlineUrl
=
_this
.
getBeamlineUrl
(
doiData
.
beamline
,
experimentalDate
);
}
else
{
doiData
.
beamlineUrl
=
"
noLink
"
;
}
// send to dust render
_this
.
view
.
renderDOIData
(
doiData
);
}
}
}).
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
_this
.
view
.
renderError
(
jqXHR
,
errorThrown
,
_this
.
origin
);
_this
.
view
.
setLoading
(
false
);
});
}
else
{
_this
.
view
.
renderError
(
"
Bad Prefix
"
,
_this
.
origin
);
}
};
/**
...
...
@@ -122,25 +125,25 @@ DOIController.prototype.getData = function(doi) {
* @return true if the prefix is an esrf prefix, false otherwise
*
*/
DOIController
.
prototype
.
hasAcceptedPrefix
=
function
(
doi
)
{
var
prefix
=
doi
.
split
(
'
/
'
)[
0
];
return
(
_
.
findIndex
(
this
.
acceptedPrefix
,
function
(
o
)
{
return
prefix
==
o
;
})
!=
-
1
);
DOIController
.
prototype
.
hasAcceptedPrefix
=
function
(
doi
)
{
var
prefix
=
doi
.
split
(
'
/
'
)[
0
];
return
(
_
.
findIndex
(
this
.
acceptedPrefix
,
function
(
o
)
{
return
prefix
==
o
;
})
!=
-
1
);
};
// Selects what will be displayed in the main id div
DOIController
.
prototype
.
displayMainContent
=
function
(
doi
)
{
var
isDOIProvided
=
false
;
DOIController
.
prototype
.
displayMainContent
=
function
(
doi
)
{
var
isDOIProvided
=
false
;
if
(
this
.
origin
===
"
welcome-page
"
)
{
dust
.
render
(
'
welcome_tpl
'
,
{},
function
(
err
,
out
)
{
$
(
"
#main
"
).
html
(
out
);
});
}
if
(
this
.
origin
===
"
index
"
)
{
this
.
getData
(
doi
);
}
if
(
this
.
origin
===
"
welcome-page
"
)
{
dust
.
render
(
'
welcome_tpl
'
,
{},
function
(
err
,
out
)
{
$
(
"
#main
"
).
html
(
out
);
});
}
if
(
this
.
origin
===
"
index
"
)
{
this
.
getData
(
doi
);
}
};
/**
...
...
@@ -151,8 +154,8 @@ DOIController.prototype.displayMainContent = function(doi) {
* @param {string}
* origin The origin page this call is made from
*/
DOIController
.
prototype
.
setOrigin
=
function
(
origin
)
{
this
.
origin
=
origin
;
DOIController
.
prototype
.
setOrigin
=
function
(
origin
)
{
this
.
origin
=
origin
;
};
/**
...
...
@@ -164,16 +167,16 @@ DOIController.prototype.setOrigin = function(origin) {
* date The date the experiment was performed.
* @return the url of the beamLine, null if it is not found
*/
DOIController
.
prototype
.
getBeamlineUrl
=
function
(
beamline
,
date
)
{
for
(
var
i
=
0
;
i
<
BEAMLINEURL
.
length
;
i
++
)
{
var
startDate
=
moment
(
BEAMLINEURL
[
i
].
startDate
);
var
endDate
=
moment
(
BEAMLINEURL
[
i
].
endDate
);
if
(
BEAMLINEURL
[
i
].
name
.
toLowerCase
()
===
beamline
.
toLowerCase
()
&&
date
>=
startDate
&&
date
<=
endDate
)
{
return
BEAMLINEURL
[
i
].
url
;
DOIController
.
prototype
.
getBeamlineUrl
=
function
(
beamline
,
date
)
{
for
(
var
i
=
0
;
i
<
BEAMLINEURL
.
length
;
i
++
)
{
var
startDate
=
moment
(
BEAMLINEURL
[
i
].
startDate
);
var
endDate
=
moment
(
BEAMLINEURL
[
i
].
endDate
);
if
(
BEAMLINEURL
[
i
].
name
.
toLowerCase
()
===
beamline
.
toLowerCase
()
&&
date
>=
startDate
&&
date
<=
endDate
)
{
return
BEAMLINEURL
[
i
].
url
;
}
}
}
return
null
;
return
null
;
};
/**
...
...
@@ -185,19 +188,19 @@ DOIController.prototype.getBeamlineUrl = function(beamline, date) {
* @return {string}
* citation : the citation to be displayed
*/
DOIController
.
prototype
.
createCitation
=
function
(
data
)
{
// Authors sent in json can be in several format. The following call find
// first name and last name when possible.
var
citation
=
new
Citation
(
data
);
if
(
!
citation
.
isBuildable
)
{
return
"
The citation could not be generated.
"
;
}
else
{
var
authorInCitation
=
citation
.
getAuthorsForCitation
(
data
.
creator
);
var
doiRegistrationYear
=
moment
(
data
.
date_registered
).
year
();
var
fullCitation
=
authorInCitation
+
'
(
'
+
doiRegistrationYear
+
'
).
'
+
data
.
title
+
'
.
'
+
data
.
publisher
+
'
(ESRF).
'
+
"
<a href='https://doi.esrf.fr/
"
+
data
.
doi
+
"
'> doi:
"
+
data
.
doi
.
toUpperCase
()
+
"
</a>
"
;
return
fullCitation
;
}
DOIController
.
prototype
.
createCitation
=
function
(
data
)
{
// Authors sent in json can be in several format. The following call find
// first name and last name when possible.
var
citation
=
new
Citation
(
data
);
if
(
!
citation
.
isBuildable
)
{
return
"
The citation could not be generated.
"
;
}
else
{
var
authorInCitation
=
citation
.
getAuthorsForCitation
(
data
.
creator
);
var
doiRegistrationYear
=
moment
(
data
.
date_registered
).
year
();
var
fullCitation
=
authorInCitation
+
'
(
'
+
doiRegistrationYear
+
'
).
'
+
data
.
title
+
'
.
'
+
data
.
publisher
+
'
(ESRF).
'
+
"
<a href='https://doi.esrf.fr/
"
+
data
.
doi
+
"
'> doi:
"
+
data
.
doi
.
toUpperCase
()
+
"
</a>
"
;
return
fullCitation
;
}
};
www/src/doiview.js
View file @
e695453e
...
...
@@ -3,6 +3,7 @@ function DOIView() {
this
.
mainPanelId
=
"
main
"
;
this
.
reportPanelId
=
"
expReport
"
;
this
.
badgePanelId
=
"
badges
"
;
this
.
metadataDivId
=
'
metadata
'
;
this
.
reportExperimentFileNames
=
null
;
this
.
failedRecievingExpReport
=
false
;
...
...
@@ -58,6 +59,7 @@ DOIView.prototype.renderDOIData = function (doiData) {
$
(
'
#
'
+
_this
.
mainPanelId
).
html
(
out
);
_this
.
isDOIAlreadyRendered
=
true
;
_this
.
renderBadges
(
doiData
);
_this
.
renderMetadata
(
doiData
);
/**
* If there are experimental reports already retrieved then render them after
* the rendering of the DOI
...
...
@@ -131,9 +133,8 @@ DOIView.prototype.renderErrorForExperimentalReport = function () {
/**
* Render the badge template in the corresponding div
*
* */
* @param {object} data : the doiData object as constructed by the doiController
*/
DOIView
.
prototype
.
renderBadges
=
function
(
data
)
{
if
(
data
)
{
var
_this
=
this
;
...
...
@@ -143,10 +144,25 @@ DOIView.prototype.renderBadges = function (data) {
},
function
(
err
,
out
)
{
$
(
'
#
'
+
_this
.
badgePanelId
).
html
(
out
);
});
}
};
/**
* Render the badge template in the corresponding div
*/
DOIView
.
prototype
.
renderMetadata
=
function
(
data
)
{
if
(
data
)
{
var
_this
=
this
;
dust
.
render
(
'
metadata_tpl
'
,
{
data
:
data
},
function
(
err
,
out
)
{
$
(
'
#
'
+
_this
.
metadataDivId
).
html
(
out
);
});
}
};
/**
* Set the message which is displayed just above the "Access data button" in experimental data box.
*
...
...
www/src/jsonextractor.js
View file @
e695453e
...
...
@@ -14,7 +14,7 @@ function JsonExtractor(json) {
JsonExtractor
.
prototype
.
extractInvestigationId
=
function
(
data
)
{
var
regExp
=
RegExp
(
/
\/\w
*-*
[
Ee
][
Ss
][
Rr
][
Ff
]
-
[
Ee
][
Ss
]
-
(\d
+
)
$/
);
//return regExp.exec( data.doi )[1];
return
"
investigationId
"
return
"
investigationId
"
;
};
/**
...
...
@@ -28,9 +28,12 @@ JsonExtractor.prototype.extractInvestigationId = function (data) {
JsonExtractor
.
prototype
.
getFieldFromSubject
=
function
(
subject
,
field
)
{
if
(
subject
)
{
if
(
subject
[
0
])
{
var
regExp
=
new
RegExp
(
"
^
"
+
field
,
'
i
'
);
for
(
var
i
=
0
;
i
<
subject
[
0
].
length
;
i
++
)
{
if
(
subject
[
0
][
i
].
subject_scheme
===
field
)
{
return
_
.
split
(
subject
[
0
][
i
].
text
,
'
,
'
);
if
(
regExp
.
test
(
subject
[
0
][
i
].
subject_scheme
))
{
if
(
subject
[
0
][
i
].
text
)
{
return
_
.
split
(
subject
[
0
][
i
].
text
,
'
,
'
);
}
}
}
}
...
...
@@ -89,14 +92,19 @@ JsonExtractor.prototype.getResourceTypeGeneral = function (data) {
/**
* Get the resource type
* @param {object}
* data The data object provided by datacite
* @return {string}
* The resource tyoe. Null if it does not exist.
* @param {object} data The data object provided by datacite
* @return {string} Resource tyoe. Null if it does not exist.
* */
JsonExtractor
.
prototype
.
getResourceType
=
function
(
data
)
{
if
(
data
&&
data
.
resource_type
)
{
return
data
.
resource_type
;
if
(
data
.
resource_type
===
"
Experiment Session
"
)
{
return
CONSTANTS
.
ES_RESOURCE_TYPE
;
}
if
(
data
.
resource_type
===
"
Datacollection
"
)
{
return
CONSTANTS
.
DC_RESOURCE_TYPE
;
}
}
return
null
;
};
//module.exports = JsonExtractor;
\ No newline at end of file
www/src/metadataTableHelper.js
0 → 100644
View file @
e695453e
function
yell
(
chunk
,
context
,
bodies
,
params
)
{
return
chunk
.
tap
(
function
(
data
)
{
return
data
.
toUpperCase
();
}).
render
(
bodies
.
block
,
context
).
untap
();
}
dust
.
helpers
.
yell
=
yell
;
www/templates/badges_tpl.js
View file @
e695453e
<
div
class
=
"
row margin-left-0 margin-right-0
"
>
{@
eq
key
=
data
.
resourceType
value
=
"
Experiment Session
"
}
{@
eq
key
=
data
.
resourceType
value
=
CONSTANTS
.
ES_RESOURCE_TYPE
}
<
div
class
=
"
col-auto padding-right-2 padding-left-2
"
>
<
span
class
=
"
badge badge-secondary font-1p4rem
"
>
Session
<
/span
>
<
/div>
<
/div
>
{
/eq}
{@
eq
key
=
data
.
resourceType
value
=
CONSTANTS
.
DC_RESOURCE_TYPE
}
<
div
class
=
"
col-auto padding-right-2 padding-left-2
"
>
<
span
class
=
"
badge badge-secondary font-1p4rem
"
>
Collection
<
/span
>
<
/div
>
{
/eq}
<
div
class
=
"
col
"
>
<
/div
>
...
...
www/templates/landingpage_tpl.js
View file @
e695453e
...
...
@@ -54,67 +54,7 @@
<
hr
>
<
div
class
=
"
row
"
>
<
div
class
=
"
col
"
>
<
div
class
=
"
myBorder-left
"
>
<
label
>
Proposal
<
/label
>
{?
data
.
proposalNumber
}
<
div
class
=
"
padding-left-15
"
>
{
data
.
proposalNumber
}
<
/div
>
{:
else
}
<
div
class
=
"
padding-left-15
"
>
Not
available
<
/div
>
{
/data.proposalNumber
}
<
/div
>
<
/div
>
<
div
class
=
"
col
"
>
<
div
class
=
"
myBorder-left
"
>
<
label
>
Publication
year
<
/label
>
{?
data
.
mintingYear
}
<
div
class
=
"
padding-left-15
"
>
{
data
.
mintingYear
}
<