Coder Social home page Coder Social logo

global19 / orcid-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orcid/orcid-js

0.0 2.0 0.0 166 KB

A general purpose ORCID javascript client and reference list generator, supporting CSL, citeproc-JSON and bibtex

JavaScript 98.70% HTML 1.30%

orcid-js's Introduction

ORCID-JS

A client side reference list generator for ORCID records

This library can be used to generate on the fly reference lists from ORCID records. It also exposes the entire V2.0_rc1 Public ORCID API via a swagger client (including the stats API). It can be used to generate any CSL style, Citeproc-JSON or bibtex.

Hello world example

	//write a reference list to the page in the default style (chicago)
	//fetches citations asynchronously, so order is not guarenteed
	orcid.init(function(){
		orcid.resolveCitations("0000-0003-0902-4386", function(citations, failures){
			for (c in citations){
				$("body").append(citations[c] +"<br/>");	
			}
			for (f in failures){
				$("body").append(failures[f].title + " (" + failures[f].citeprocURL+") FAILED to fetch metadata<br/>");		
			}
		});		
	});

Viewing the examples locally

Chrome and Firefox will prevent the browser from loading other resources from the file system. To test locally, you need to server the files from a webserver. This can easily be done using python. Run the following command:

python -m SimpleHTTPServer

Then access the example at http://localhost:8000/example.html

Where does the metadata come from?

To generate citations, the library does the following:

  • Obtain a public list of activites from an ORCID record
  • For each work fetch authoritative citation metadata available using the prefered source
  • For works with DOIs, citeproc metadata is obtained directly from Crossref or Datacite
  • For other works, citeproc is obtained from the ORCID registry. If there is a BibTeX citation, this is transformed into Citeproc-JSON, otherwise ORCID work metadata is used
  • For each work, attempt to create a URL based on the idenfifier
  • Apply a CSL citation style to generate reference list or BibTeX

As other services add the ability to resolve citeproc metadata, this tool will be updated to use it.

Usage

The most useful method has this signature:

function resolveCitationsFromORCIDID(orcidID, callback, oneByOne, optionalCitationStyle, returnCiteprocObjects)

There is also an example.html page

	orcid.init(callback);
	function callback(){
		//to fetch asyncronously and have the callback called once for each citation (recommended) use:
		orcid.resolveCitations("0000-0000-0000-0000", onCompleteCallback, true);
		//to get the citations an array of citation strings via a callback as a batch use:
		orcid.resolveCitations("0000-0000-0000-0000", onCompleteCallback, false);
		// the default style is Chicago, we can ask for bibtex instead like this:
		orcid.resolveCitations("0000-0000-0000-0000", onCompleteCallback, false, orcid.styleBibtex);
		// if you want an array of citeproc JSON objects instead, use this:
		orcid.resolveCitations("0000-0000-0000-0000", onCompleteCallback, true, "", true);	
	}

	//If all you need is a list of titles, identifiers and URLS, use simpleWorks
	//This also demonstrates how to access the API via swagger (full v2.0 api is supported)
	orcid.init(callback);
	function callback(){
		orcid.client.apis["Public API v2.0_rc1"].viewActivities({orcid:"0000-0000-0000-0000"}, function(data) {
			var simpleWorks = orcid.activitiesToSimpleWorks(data);
			//do whatever with the simpleWorks
		});
	}

If you would like to load a citation format that is not supplied by default (APA, Chicago, Bibtex) then use the styles.js helper to fetch it from the server. All the styles in the style repo should be available. Something like this:

	CSLStyles.fetchStyleXML("academy-of-management-review", function(styleXML){
		orcid.resolveCitations(orcidID, updatePage, true, styleXML);		
	});

Dependencies

swagger-client.js, jquery, citeproc-js transitive: xmle4x.js,xmldom.js

When cloning this repository, you must run

git submodule init
git submodule update

To fetch the dependancies

Issues

Chrome always logs the following to the console:

xmle4x.js:11 Uncaught SyntaxError: Unexpected token default

This is a citeproc dependency used by legacy browsers and does not affect function in Chrome/Firefox.

orcid-js's People

Contributors

tomdemeranville avatar vdmitriyev avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.