Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for figshare sources #8

Merged
merged 1 commit into from
May 11, 2017
Merged

Conversation

faokryn
Copy link
Collaborator

@faokryn faokryn commented Feb 24, 2017

  • Adds a URL resolver and source handler for figshare sources, allowing figshare URLs to be cited by CitationCore.
  • Adds FigshareHandler to the UrlResolverManager
  • Adds a test to the UrlResolverManager test to test that the FigshareHandler is returned for a figshare URL.

This resolves mozillascience/software-citation-tools#20


result.email = null;
result.lastName = (namePieces.length > 0) ? namePieces.pop() : null;
result.middleName = (namePieces.length > 1) ? namePieces.splice(1 - namePieces.length).join(' ') : null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is copied from the GitHub API Handler. Maybe we can create a utility to handle parsing a name?

}

/**
* Fetches data to be used in the citation from the API, stores it in a SourceData object, and returns that object to
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the @Augments on the class will inherit function comments in the documentation from the super class. Not sure if it is necessary to do that here. Also looking at the documentation on the super class comments looks like I made a mistake and they are incorrect. We should probably fix that.

const parsedBody = (body != null) ? JSON.parse(body) : null;

if (error == null && response.statusCode !== 200) {
error = new Error('Received a ' + response.statusCode + ' when making a request to ' + options.url);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reassigning the error callback parameter seems a little weird. Can we just do:

if(error == null && response.statusCode !== 200) {
  callback(null, [new Error('Received a ' + response.statusCode + ' when making a request to ' + options.url)]);
}
else if(error != null) {
  callback(null, [error]);
}
else {
// Create the source data object
}

sourceData.url = parsedBody.url_public_html;
sourceData.licence = parsedBody.license.name;
sourceData.description = parsedBody.description;
sourceData.uid = parsedBody.doi;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is supposed to be a UID object which contains the value and the type of UID it is like a DOI, ISBN, etc. Because this is the only handler that uses this for the moment this can be up for discussion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sourceData.uid = parsedBody.doi;

sourceData.authors = [];
parsedBody.authors.forEach((author) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use the map function here instead?

sourceData.authors = parsedBody.authors.map((author) => {
  return this._createAuthorObject(author);
});

/**
* Creates a FigshareAPIHandler.
* @param baseUrl {String} - The Base URL to the API.
* @param articleID {String} - The article ID."
Copy link
Collaborator

@sam1360 sam1360 Mar 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the " at the end of the description of the articleID.

@sam1360
Copy link
Collaborator

sam1360 commented Mar 7, 2017

Once Erics changes are in I would say this looks like it will be good to go.

@faokryn faokryn force-pushed the issue20 branch 2 times, most recently from e390cf5 to 66f8ba6 Compare May 11, 2017 17:10
@sam1360
Copy link
Collaborator

sam1360 commented May 11, 2017

👍

@faokryn faokryn merged commit 52578e6 into mozillascience:dev May 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants