citoid

From MediaWiki.org
(Redirected from Cite-from-id)
Jump to: navigation, search

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[edit | edit source]

Citoid is a nodejs app that also requires a working installation of Zotero's translation server, which uses the Zotero translators library, and xulrunner. These are included in a deployment repository, or you can install each component individually. Please note that the most recent version of xpcshell doesn't work with translation-server; the deploy directory contains a version which is known to work (29.0).

Install nodejs and npm[edit | edit source]

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.

sudo apt-get install nodejs npm
nodejs --version # should now print v0.10.x Note: not on Ubuntu Server 12.04 LTS, you end up with v0.6.x

For other systems, see:

Install from deploy repository[edit | edit source]

Checkout deploy repo[edit | edit source]

If you want to do an anonymous checkout:

git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/citoid/deploy

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

git clone ssh://<user>@gerrit.wikimedia.org:29418/mediawiki/services/citoid/deploy

Update submodules[edit | edit source]

git submodule update --init

This will put the source of citoid in the /src/ directory. This may not always be the most recent version of citoid- to get the most recent (potentially unstable) version,

cd src
git pull origin master
npm install

Translation-server and the translator libraries are not under source control within the deploy repo. If you want to have the most up-to-date versions of these, you should install from scratch.

Configure translation-server[edit | edit source]

From the deploy directory,

vi translation-server/defaults/pref/config.js

Line one, change the translators directory path to the location your "translators" directory.

Run translation-server[edit | edit source]

From the deploy directory,

 ./translation-server/run_translation-server.sh &

Configure and run citoid[edit | edit source]

From the deploy directory,

mv localsettings.js src/localsettings.js
node src/server.js

Alternatively, you can use the -c flag to specify the location of the localsettings.py file.

Install from scratch[edit | edit source]

Install and configure Zotero's translation server[edit | edit source]

See: Translation-server installation instructions

Note: The most recent version of xpcshell does not work with translation-server. Install version 29.0.

Install and configure citoid service[edit | edit source]

Get the code[edit | edit source]

If you want to do an anonymous checkout:

git clone https://gerrit.wikimedia.org/r/p/mediawiki/services/citoid

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

git clone ssh://<user>@gerrit.wikimedia.org:29418/mediawiki/services/citoid
JS dependencies[edit | edit source]

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

npm install
Create localsettings.js file[edit | edit source]

Copy localsettings.js.sample to localsettings.js

cp localsettings.js.sample localsettings.js
Run the server[edit | edit source]

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

node server.js

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

curl -d '{"url":"http://link.springer.com/chapter/10.1007/11926078_68", "format":"mediawiki"}' --header "Content-Type: application/json" localhost:1970/url

Install and configure Citoid user scripts[edit | edit source]

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[edit | edit source]

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[edit | edit source]

  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[edit | edit source]

If you want to do an anonymous checkout:

git clone https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Citoid

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

git clone ssh://<user>@gerrit.wikimedia.org:29418/mediawiki/extensions/Citoid

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

require_once("$IP/extensions/Citoid/Citoid.php");

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

// Service doesn't need a security certificate, but the https 
// protocol is required in the URL for it to work in FireFox
$wgCitoidServiceUrl = 'https://localhost:1970';

Design and implementation[edit | edit source]

API[edit | edit source]

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

For more, see Citoid/API

Current design[edit | edit source]

  1. Queries Zotero translator-server for translator.
  2. If no translator found, follow redirects (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 native scraper that pulls out the title only.

Issue tracker and project management[edit | edit source]

Bugs, issues, and suggestions for improvement can be added to the Citoid phabricator project.

Related extensions and services[edit | edit source]