Citoid

Citoid is a node.js service which currently locates citation data given an URL. It has a companion extension of the same name which aims to provide use of the citoid service to VisualEditor. Neither the service nor the extension are presently production ready. Ultimately, the goal is for the citoid service to provide citations given any search term, such as URL, DOI, title of the work, etc.

Installation
Citoid requires a working installation of Zotero's translation server.

Install and configure Zotero's translation server
See: Translation-server installation instructions

Get the code
If you want to do an anonymous checkout:

Or if you plan to hack citoid, then please follow the Gerrit 'getting started' docs and use an authenticated checkout url instead, such as:

Nodejs
Install nodejs 0.10 and npm. When you are using Ubuntu and depending on OS version you will not end up with the most recent version of nodejs.

For other systems, see:
 * http://nodejs.org/download/
 * https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
 * (debian squeeze, wheezy) https://gist.github.com/x-Code-x/2562576

JS dependencies
Install the JS dependencies. Run this command in the citoid directory:

Create localsettings.js file
Copy localsettings.js.sample to localsettings.js

Run the server
You should be able to start the citoid web service from the citoid directory using:

This will start the citoid service on port 1970. To test it, try a sample query:

Install and configure Citoid user scripts
Users can make use of citoid user scripts if user javascript is enabled on your wiki using the $wgAllowUserJs option. You can also install VisualEditor gadgets on a site-wide basis.

There is currently one user script than can be used on English Wikipedia in conjunction with VisualEditor and a citoid service running on labs: CiteFromURL user script.

There is one user script for wikitext editing that can be used on English Wikipedia, also using the labs instance: Citoid Wikitext citations.

Install and configure Citoid extension
Warning: This feature is currently awaiting changes to Extension:TemplateData to work on all wikis. It currently only works on wikis using the following English Wikipedia templates: Wikipedia:Template:Citation, Wikipedia:Template:Cite web, Wikipedia:Template:Cite book, Wikipedia:Template:Cite journal, and Wikipedia:Template:Cite news.

In order to have citoid functioning on your wiki in conjunction with VisualEditor, you'll need the following: VisualEditor and Parsoid, VisualEditor's Citation Tool, and the Citoid extension.

It is recommended that you have the following extensions in your extension folder: Extension:VisualEditor, Extension:Scribunto, Extension:Cite, Extension:TemplateData, and Extension:ParserFunctions, and Extension:Citoid.

VisualEditor and Citation Tool

 * 1) Set up MediaWiki: Manual:Installation_guide
 * 2) Set up Parsoid: Parsoid/Setup
 * 3) Set up VisualEditor: Extension:VisualEditor
 * 4) Set up Citation Tool: VisualEditor/Citation tool

Citoid extension
If you want to do an anonymous checkout:

Or if you plan to hack citoid, then please follow the Gerrit 'getting started' docs and use an authenticated checkout url instead, such as:

Then add the following line to your wiki's  after you have downloaded the extension:

Set the location to your citoid service instance in your wiki's

API
Currently, to request metadata about a url, use the url endpoint and provide the parameters "url" and "format". "url" will take any URI, including those without protocol (urls with no protocol specified are queried as http). "Format" will take "zotero", "mediawiki" and "mwDeprecated."

For more, see Citoid/API

Current design

 * 1) Queries Zotero translator-server for translator.
 * 2) If no translator found, follow a single redirect (for the case of shortened URLs- this is not done initially because in many cases the redirect will be to a log-in url).
 * 3) Query Zotero translator-server for translators again.
 * 4) If no translator found, send to a naive scraper that pulls out the title only.

Roadmap
For more, see Citoid/Roadmap

Planned service improvements
A number of improvements to the service are planned. Contributions are welcome! If any of these strike your fancy, please go ahead and do it! Development speed is generally slow so it's unlikely you'll overlap, but if you are worried about overlap feel free to use the talk page, or ping User:Mvolz, on IRC as well.
 * Implement Open Graph in scrape.js (possibly using npm open-graph).
 * In server.js, add additional endpoint for DOI and /search endpoint that will return a list of results for search terms

including URL, DOI, and title
 * Additional export formats such as "csl", "bibtex" etc- essentially anything zotero has translators for.
 * Serve HTML pages for testing purposes, and automate tests (i.e. check that scrape.js gives the expected output)
 * Make all methods follow the error first best practice and remove try/catch error catching, see Node.js best practices.

Related extensions and services

 * Zotero translation server -- xpcshell-based Zotero translation server, and https://github.com/zotero/zotero-node, an abandoned and old nodejs equivalent
 * Zotero field mappings, including vs. some cite templates
 * en:Category:Citation_templates
 * en:Help:Citation tools
 * VisualEditor/Citation tool
 * Sample cite-tool definition on Wikipedia Beta
 * Restface (node.js restful api)