Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doi-landing-page
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alejandro De Maria Antolinos
doi-landing-page
Commits
58a814ff
Commit
58a814ff
authored
Apr 24, 2018
by
Maxime Chaillet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement accessibility and content badge. It fixes #50.
parent
63c4aae7
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
119 additions
and
28 deletions
+119
-28
www/dev.html
www/dev.html
+1
-0
www/min/doi.min.js
www/min/doi.min.js
+1
-1
www/min/precompiled.templates.min.js
www/min/precompiled.templates.min.js
+2
-2
www/src/doiData.js
www/src/doiData.js
+23
-0
www/src/doicontroller.js
www/src/doicontroller.js
+5
-1
www/src/doiview.js
www/src/doiview.js
+29
-8
www/src/jsonextractor.js
www/src/jsonextractor.js
+36
-9
www/templates/badges_tpl.js
www/templates/badges_tpl.js
+20
-4
www/templates/landingpage_tpl.js
www/templates/landingpage_tpl.js
+2
-3
No files found.
www/dev.html
View file @
58a814ff
...
...
@@ -12,6 +12,7 @@
<script
src=
"src/beamlineurl.js"
></script>
<script
src=
"src/citation.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>
...
...
www/min/doi.min.js
View file @
58a814ff
This diff is collapsed.
Click to expand it.
www/min/precompiled.templates.min.js
View file @
58a814ff
This diff is collapsed.
Click to expand it.
www/src/doiData.js
0 → 100644
View file @
58a814ff
function
DoiData
()
{
}
/**
* Get the accessibility status
*
* */
DoiData
.
prototype
.
getAccessibilityStatus
=
function
(
sessionDate
,
publiclyAccessibleYear
)
{
if
(
publiclyAccessibleYear
&&
sessionDate
)
{
var
publiclyAvailableDate
=
moment
(
publiclyAccessibleYear
,
"
YYYY
"
);
var
now
=
moment
();
if
(
now
>
publiclyAvailableDate
)
{
return
"
Open access
"
;
}
else
if
(
now
<=
publiclyAvailableDate
)
{
return
"
Under embargo
"
;
}
}
console
.
log
(
"
Failed to determine whether the accessibility of the DOI.
"
);
return
"
Accessibility status could not be determined
"
;
};
www/src/doicontroller.js
View file @
58a814ff
...
...
@@ -63,7 +63,7 @@ DOIController.prototype.getData = function(doi) {
if
(
!
_this
.
isValidDOIData
(
data
))
{
_this
.
view
.
renderError
(
"
Not Found
"
,
_this
.
origin
);
}
else
{
var
doiData
=
{}
;
var
doiData
=
new
DoiData
()
;
doiData
.
title
=
data
.
title
;
doiData
.
publisher
=
data
.
publisher
;
doiData
.
creator
=
data
.
creator
;
...
...
@@ -71,6 +71,7 @@ DOIController.prototype.getData = function(doi) {
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
"
);
...
...
@@ -82,6 +83,9 @@ DOIController.prototype.getData = function(doi) {
doiData
.
investigationId
=
jsonExtractor
.
extractInvestigationId
(
data
);
doiData
.
accessMessage
=
_this
.
view
.
setDataAccessMessage
(
data
);
doiData
.
citation
=
_this
.
createCitation
(
data
);
doiData
.
resourceTypeGeneral
=
jsonExtractor
.
getResourceTypeGeneral
(
data
);
doiData
.
resourceType
=
jsonExtractor
.
getResourceType
(
data
);
doiData
.
accessibility
=
doiData
.
getAccessibilityStatus
(
doiData
.
sessionDate
,
doiData
.
publiclyAccessibleYear
);
// Set the URL corresponding to the beamline name.
if
(
data
.
date_collected
)
{
...
...
www/src/doiview.js
View file @
58a814ff
...
...
@@ -2,6 +2,7 @@ function DOIView() {
this
.
mainPanelId
=
"
main
"
;
this
.
reportPanelId
=
"
expReport
"
;
this
.
badgePanelId
=
"
badges
"
;
this
.
reportExperimentFileNames
=
null
;
this
.
failedRecievingExpReport
=
false
;
...
...
@@ -24,11 +25,11 @@ DOIView.prototype.setLoading = function( message ) {
DOIView
.
prototype
.
setDOI
=
function
(
doiCode
)
{
// $( "#doiPanel" ).text( doiCode.toUpperCase() );
$
(
"
#doiPanel
"
).
html
(
"
<div class='col'> </div>
"
+
"
<div class='col-auto mr-3 borderRadius-5 whiteBackground' style='padding:10px;'>
"
+
"
<span class='doiBadge borderRadius-5 fontSize-20'> <a id='doiLink' href=''>
"
+
doiCode
.
toUpperCase
()
+
"
</a> </span> </div>
"
);
"
<div class='col'> </div>
"
+
"
<div class='col-auto mr-3 borderRadius-5 whiteBackground' style='padding:10px;'>
"
+
"
<span class='doiBadge borderRadius-5 fontSize-20'> <a id='doiLink' href=''>
"
+
doiCode
.
toUpperCase
()
+
"
</a> </span> </div>
"
);
};
/**
...
...
@@ -36,7 +37,7 @@ DOIView.prototype.setDOI = function( doiCode ) {
*
*/
DOIView
.
prototype
.
setDOILink
=
function
(
doiLink
)
{
$
(
"
#doiLink
"
).
attr
(
"
href
"
,
doiLink
.
toUpperCase
()
);
$
(
"
#doiLink
"
).
attr
(
"
href
"
,
doiLink
.
toUpperCase
()
);
};
/**
...
...
@@ -63,14 +64,14 @@ DOIView.prototype.renderExperimentalReportData = function( data ) {
}
};
DOIView
.
prototype
.
renderDOIData
=
function
(
doiData
,
target
)
{
DOIView
.
prototype
.
renderDOIData
=
function
(
doiData
)
{
var
_this
=
this
;
dust
.
render
(
'
landingpage_tpl
'
,
{
data
:
doiData
},
function
(
err
,
out
)
{
$
(
'
#
'
+
_this
.
mainPanelId
).
html
(
out
);
_this
.
isDOIAlreadyRendered
=
true
;
_this
.
renderBadges
(
doiData
);
/**
* If there are experimental reports already retrieved then render them after
* the rendering of the DOI
...
...
@@ -135,6 +136,26 @@ DOIView.prototype.renderErrorForExperimentalReport = function() {
$
(
'
#
'
+
this
.
reportPanelId
).
html
(
out
);
};
/**
* Render the badge template in the corresponding div
*
* */
DOIView
.
prototype
.
renderBadges
=
function
(
data
)
{
if
(
data
)
{
var
_this
=
this
;
dust
.
render
(
'
badges_tpl
'
,
{
data
:
data
},
function
(
err
,
out
)
{
$
(
'
#
'
+
_this
.
badgePanelId
).
html
(
out
);
}
);
}
};
/**
* Set the message which is displayed just above the "Access data button" in experimental data box.
*
...
...
www/src/jsonextractor.js
View file @
58a814ff
...
...
@@ -6,8 +6,7 @@ function JsonExtractor( json ) {
* response.
*
* @param {string}
* data The data object reference which is sent to the dustjs
* template
* data The data object provided by datacite
* @return {string}
* investigationId The investigationID requested for accessing data in ICAT.
*/
...
...
@@ -42,9 +41,9 @@ JsonExtractor.prototype.getFieldFromSubject = function( subject, field ) {
* Get minting year from the data object.
*
* @param {object}
* data The data object
reference which is sent to the dustjs
*
template
*
@return {string}
The minting year. Null if it does not exist.
* data The data object
provided by datacite template
*
@return {string}
*
The minting year. Null if it does not exist.
*/
JsonExtractor
.
prototype
.
getMintingYear
=
function
(
data
)
{
if
(
data
)
{
...
...
@@ -59,10 +58,9 @@ JsonExtractor.prototype.getMintingYear = function( data ) {
* Get session date from the data object.
*
* @param {object}
* data The data object reference which is sent to the dustjs
* template
* @return {string} The formatted (YYY-M-D) session date. Null if it does not
* exist.
* data The data object provided by datacite
* @return {string}
* The formatted (YYY-M-D) session date. Null if it does not exist.
*/
JsonExtractor
.
prototype
.
getSessionDate
=
function
(
data
)
{
if
(
data
)
{
...
...
@@ -72,3 +70,32 @@ JsonExtractor.prototype.getSessionDate = function( data ) {
}
return
null
;
};
/**
* Get the resource type general
* @param {object}
* data The data object provided by datacite
* @return {string}
* The resource tyoe general. Null if it does not exist.
* */
JsonExtractor
.
prototype
.
getResourceTypeGeneral
=
function
(
data
)
{
if
(
data
&&
data
.
resource_type_general
)
{
return
data
.
resource_type_general
;
}
return
null
;
};
/**
* Get the resource type
* @param {object}
* data The data object provided by datacite
* @return {string}
* The resource tyoe. Null if it does not exist.
* */
JsonExtractor
.
prototype
.
getResourceType
=
function
(
data
)
{
if
(
data
&&
data
.
resource_type
)
{
return
data
.
resource_type
;
}
return
null
;
};
www/templates/badges_tpl.js
View file @
58a814ff
<
div
class
=
"
col-12
"
>
<
div
>
<
span
class
=
"
badge badge-success
"
style
=
"
font-size:14px;
"
>
open
Access
<
/span
>
{@
eq
key
=
data
.
resourceTypeGeneral
value
=
"
Dataset
"
}
{@
eq
key
=
data
.
resourceType
value
=
"
Experiment Session
"
}
<
div
class
=
"
col-auto
"
>
<
span
class
=
"
badge badge-secondary
"
style
=
"
font-size:14px;
"
>
Dataset
(
s
)
/
session
<
/span
>
<
/div
>
{
/eq
}
{
/eq
}
{@
eq
key
=
data
.
accessibility
value
=
"
Open access
"
}
<
div
class
=
"
col-auto
"
>
<
span
class
=
"
badge badge-success
"
style
=
"
font-size:14px;
"
>
Open
access
<
/span
>
<
/div
>
<
/div>
\ No newline at end of file
{
/eq
}
{@
eq
key
=
data
.
accessibility
value
=
"
Under embargo
"
}
<
div
class
=
"
col-auto
"
>
<
span
class
=
"
badge badge-warning
"
style
=
"
font-size:14px;
"
>
Under
embargo
<
/span
>
<
/div
>
{
/eq}
\ No newline at end of file
www/templates/landingpage_tpl.js
View file @
58a814ff
<
div
class
=
"
container-fluid
"
>
<
br
/>
<
div
class
=
"
row padding-top-15
"
>
<
div
class
=
"
col-8
"
>
<
div
class
=
"
row
"
>
<
div
class
=
"
col-12 fontSize-20 text-center text-uppercase font-weight-bold
"
>
{
data
.
title
}
<
/div
>
<
div
class
=
"
col-12 fontSize-20 text-center text-uppercase font-weight-bold
py-3
"
>
{
data
.
title
}
<
/div
>
<
/div
>
<
hr
>
...
...
@@ -135,7 +134,7 @@
<
/div
>
<
div
class
=
"
col-4
"
>
<
div
id
=
"
badge
"
class
=
"
row
"
>
<
/div>
<
div
id
=
"
badge
s
"
class
=
"
row py-4
"
>
<
/div>
<
br
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment