Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doi-landing-page
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
7
Issues
7
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ICAT
doi-landing-page
Commits
ed833524
Commit
ed833524
authored
Jan 28, 2019
by
Maxime Chaillet
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue65' into 'master'
Issue65 Closes
#65
See merge request
!75
parents
fd2c6b6f
9a94f8dd
Pipeline
#7893
passed with stages
in 1 minute and 16 seconds
Changes
8
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
56 additions
and
27 deletions
+56
-27
doi.min.js
www/min/doi.min.js
+1
-1
package.json
www/package.json
+1
-1
citation.js
www/src/citation.js
+8
-8
doicontroller.js
www/src/doicontroller.js
+2
-1
doiview.js
www/src/doiview.js
+2
-0
jsonextractor.js
www/src/jsonextractor.js
+1
-15
citation.test.js
www/tests/citation.test.js
+40
-0
jsonExtractor.test.js
www/tests/jsonExtractor.test.js
+1
-1
No files found.
www/min/doi.min.js
View file @
ed833524
This diff is collapsed.
Click to expand it.
www/package.json
View file @
ed833524
...
...
@@ -28,7 +28,7 @@
"watchify"
:
"^3.11.0"
},
"scripts"
:
{
"test"
:
"
./node_modules/jest/bin/jest.js
"
"test"
:
"
karma start
"
},
"repository"
:
{
"type"
:
"git"
,
...
...
www/src/citation.js
View file @
ed833524
...
...
@@ -17,14 +17,9 @@ function Citation(doiData) {
}
/**
* Construct the author list for the citation. Authors name are composed of the
* familyName in titleCase followed by the first letter of the first name
*
* @param {arrayOrObj}
* The creator(s). When there is a single author, it is an
* object. When there are several authors, it is an array.
* @return {string} The formated list of authors to be used for the citation. An
* empty string when the list could not be generated.
* Construct the author list for the citation. Authors name are composed of the familyName in titleCase followed by the first letter of the first name
* @param {arrayOrObj} theCreator(s). When there is a single author, it is an object. When there are several authors, it is an array.
* @return {string} The formated list of authors to be used for the citation. An empty string when the list could not be generated.
*/
Citation
.
prototype
.
getAuthorsForCitation
=
function
(
creator
)
{
if
(
this
.
isBuildable
)
{
...
...
@@ -67,6 +62,11 @@ Citation.prototype.getAuthorsForCitation = function (creator) {
}
};
/**
* Get the DOI registration year
* @param doiData doimetadata as constructed by the json exctrator
* @returns registration year. Empty string when t is not available.
*/
Citation
.
prototype
.
getDOIRegistrationYear
=
function
(
doiData
)
{
if
(
doiData
.
resourceType
===
CONSTANTS
.
ES_RESOURCE_TYPE
)
{
return
moment
(
doiData
.
sessionDate
).
year
();
...
...
www/src/doicontroller.js
View file @
ed833524
...
...
@@ -177,8 +177,9 @@ DOIController.prototype.getDataForGoogleSearch = function (doi) {
success
:
function
(
data
)
{
if
(
data
)
{
_this
.
view
.
addDOIMetadataToHead
(
data
);
}
else
{
console
.
log
(
"[GOOGLE SEARCH INDEXING] - No metadata recieved from datacite."
);
}
console
.
log
(
"[GOOGLE SEARCH INDEXING] - No metadata recieved from datacite."
);
},
error
:
function
(
error
)
{
console
.
log
(
"[GOOGLE SEARCH INDEXING] - Failed getting metadata from datacite."
);
...
...
www/src/doiview.js
View file @
ed833524
...
...
@@ -149,6 +149,8 @@ DOIView.prototype.renderBadges = function (data) {
DOIView
.
prototype
.
renderMetadata
=
function
(
data
)
{
if
(
data
)
{
var
_this
=
this
;
data
.
sessionDate
=
moment
(
data
.
sessionDate
).
format
(
'YYYY-M-D'
);
dust
.
render
(
'metadata_tpl'
,
{
data
:
data
,
constants
:
CONSTANTS
...
...
www/src/jsonextractor.js
View file @
ed833524
...
...
@@ -107,19 +107,6 @@ JsonExtractor.prototype.getInvestigationId = function (data) {
return
null
;
};
/**
* Extract field value (beamline, proposal number and proposal type) from the
* data json object. Returns null if the field is not found.
...
...
@@ -168,12 +155,11 @@ JsonExtractor.prototype.getSessionDate = function (data) {
var
sessionDate
=
_
.
find
(
data
.
dates
,
function
(
item
)
{
if
(
item
.
dateType
)
{
return
item
.
dateType
.
toLowerCase
()
===
"collected"
;
}
});
if
(
sessionDate
&&
sessionDate
.
date
)
{
return
moment
(
sessionDate
.
date
).
format
(
'YYYY-M
-
D'
);
return
moment
(
sessionDate
.
date
).
format
(
'YYYY-M
M-D
D'
);
}
}
}
...
...
www/tests/citation.test.js
0 → 100644
View file @
ed833524
import
Citation
from
'../src/citation'
;
describe
(
'citation'
,
()
=>
{
describe
(
'getDOIRegistrationYear'
,
()
=>
{
it
(
'Returns the year for experimental session'
,
()
=>
{
let
actualDoiData
=
{
resourceType
:
"experimental session resource type"
,
sessionDate
=
"2017-12-31"
,
publiclyAccessibleYear
=
"2018"
};
let
expectedYear
=
2017
;
let
myCitation
=
new
Citation
();
expect
(
myCitation
.
getDOIRegistrationYear
(
actualDoiData
)).
toEqual
(
expectedYear
);
})
it
(
'Returns the year for datacollection session'
,
()
=>
{
// thre is no sessionDate for this kind of DOI
let
actualDoiData
=
{
resourceType
:
"dataset collection resource type"
,
publiclyAccessibleYear
=
"2018"
};
let
expectedYear
=
2018
;
let
myCitation
=
new
Citation
();
expect
(
myCitation
.
getDOIRegistrationYear
(
actualDoiData
)).
toEqual
(
expectedYear
);
})
it
(
'Returns an empty string when sessionDate is not provided'
,
()
=>
{
let
actualDoiData
=
{
};
let
expectedYear
=
""
;
let
myCitation
=
new
Citation
();
expect
(
myCitation
.
getDOIRegistrationYear
(
actualDoiData
)).
toEqual
(
expectedYear
);
})
})
})
\ No newline at end of file
www/tests/jsonExtractor.test.js
View file @
ed833524
...
...
@@ -116,7 +116,7 @@ describe("jsonExtractor", () => {
describe
(
'getSessionDate'
,
()
=>
{
it
(
"returns the session date when the doi resource type is 'experiment session'"
,
()
=>
{
let
actualDoiData
=
require
(
'./resources/doi_ES.js'
)
let
expectedSessionDate
=
moment
(
'2018-03-26'
).
format
(
'YYYY-M-D'
)
;
let
expectedSessionDate
=
'2018-03-26'
;
let
myJsonExtractor
=
new
JsonExtractor
();
expect
(
myJsonExtractor
.
getSessionDate
(
actualDoiData
)).
toEqual
(
expectedSessionDate
);
...
...
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