User:PerfektesChaos/js/citoidWikitext

JavaScript gadget to add specific functionality on pages: Insert citation templates filled by Zotero via Citoid into edited source code.

For a publication specification in the editing area at cursor position it will be attempted to get the metadata; and templates are offered to be inserted directly. On copious target pages two mouse clicks are sufficient.

Currently the required template interfaces are defined for German Wikipedia only.

Usage

 * If your project has registered this as a gadget, just activate it on your Preferences page.
 * Otherwise include the following lines into your common.js or similar:
 * If not working as registered user the gadget can be activated by greasemonkey or browser user script.

Possible searches
The particular publication identifiers shall be amended by more expressions in the future.

URL
Every URL (with at least one slash  as root path) can be analysed. At least it might be tried, see what happens. With a space, new line,  or   as well as closing bracket   the effective URL is terminated.

In front of a URL an opening bracket  will also permit protocol-relative URLs.

ISBN
The following formatting variations of an ISBN are supported, tolerating spaces, downcasing and upcasing; examples: For any syntactically valid ISBN (even with wrong check digit) WorldCat will be examined.
 * ISBN 3-7891-4161-5
 *  isbn: 9129657520 
 *  isbn = 978-3-577-09102-2 

This will be completed with a search in national libraries etc. as suggested by the language, which can be derived from the ISBN: During execution links to every catalog are displayed; furthermore to the specific Special:Booksources page.
 * German – Deutsche Nationalbibliothek and similar
 * English – Library of Congress
 * French, dutch, polish analogous.
 * More languages will be supported, when the quality of results has been evaluated.
 * User defined library catalogs can be declared in general or per language.

DOI
DOI can be specified in formats like: It will be redirected to scientific journals, which present often well prepared informations on their sites.
 * DOI 10.1000/182
 * doi=10.1000/182
 *  10.1000/182 
 * 

Standard-IDs: arXiv, PMID, PMC
Formats for arXiv, PubMed are similar as for ISBN etc.: Scientific journals addressed by such IDs offer frequently semantic metadata.
 *  0704.0220 
 * <tt>arXiv astro-ph/0301118</tt>
 * <tt>PMID 1234567</tt>
 * <tt>pmid= 7654321</tt>
 * <tt>pmid: 1234</tt>
 * <tt>PMC 123</tt>
 * <tt></tt>

Library catalogs: DNB, LCCN, OCLC
Formats for DNB, LCCN, OCLC are comparable to those above: Semantic preparation of catalogs differs.
 * <tt>DNB 454663196</tt> (Deutsche Nationalbibliothek)
 * <tt>dnb=770531741</tt>
 * <tt>DNB:993443176</tt>
 * <tt>LCCN 2004-059084</tt>
 * <tt></tt>

Suitable pages
On the following pages the tool will be activated when wikitext source code is edited: Further pages may be equipped on user defined request.
 * All articles (pages in main namesace).
 * All own user pages.
 * WP:Sandbox.

Tool links
If there is a graphical tool bar, a button will be inserted, otherwise in the ‘left column’ of the portal page: A click will start immediately the inspection of the text at cursor position and the query; the citoid box will be opened.

Describing the desired publication
Beginning with the cursor position the following text will be interpreted. Spaces might be interspersed between keywords, data and special characters. The description of the publication will be evaluated as far as to be expected from syntax:
 * By default the source code at cursor position in editing area will be analysed.
 * If a text region is selected (marked), then this will be used and limit the evaluation.
 * After opening the citoid box (usally above the editing area) an input field can be activated by <span style="background: #D0D0D0; border: 2px solid; border-color: #E0E0E0 #E0E0E0 #707070 #707070; color: #000000; font-size: 110%; padding: 2px;">_ button. Then the content there will be evaluated rather than the cursor position in editing area.
 * URL up to, next space, closing bracket  , new line or presumably   indicating a tag.
 * ID until next space, appropriate punctuation or end of line.
 * Template transclusions until pipe, closing brackets   or new line.

Citoid box
After the first tool click a box will be opened (usally above the editing area) wird. It might be closed again.

Leftmost it contains a button <span style="background: #D0D0D0; border: 2px solid; border-color: #E0E0E0 #E0E0E0 #707070 #707070; padding: 2px;">Citoid to start queries. Buttons in tool bars keep their functionality; it is identical.

As tooltip the current version specification of this script is displayed on the button.

Control elements
Once the citoid box has been opened, the following buttons are available in the right corner (from left to right):

Request and problems
In the citoid box the following symbols might be displayed: Additionally links [1] [2] etc. are offered. They match exactly those websites which are contacted automatically now. These pages will be opened in separate browser windows (but always the same).

Results
Basically the quality of the outcome depends on the information available on the target page, whether it has been prepared for extraction, and the format is already known to Zotero.

When the fruits have been completed, some formatting or an appropriate template needs to be determined by the script and will be equipped with parameters. The yielded string is inserted at cursor position into editing area, and will replace a selected (marked) region. Formatting details of template transclusion might be chosen by the user:

After insertion all parameter values are to be checked, whether they are reasonable or should be corrected or completed manually: The citoid box is still open and offers links to the examined websites, which are opening in separate browser windows and might be used to identify and copy missing information manually.
 * Extraction of person names from websites does not always succeed.
 * Information might be entirely missing.
 * Values might have been assigned to the wrong fields.
 * Values might be absolute nonsense.
 * Capitalization, downcasing, abbreviations, typography could require polishing.

This script has neither any influence on the quality of result contents nor on the availabiltiy of the WMF citoid server or target pages.

User configuration
Personal adptions are possible.

Define an application object
Even before script loading the following code is to be inserted into personal common.js page: When prepared in this way individual assignments are possible.

Additional pages
If you like more pages than the standard page collection to be equipped with citoid you may speify individually.

The  component must be an object. Those components are identified by the namespace number and evaluate to a string or RegExp object, which covers all desired page titles.

(see German page for an example)

Library catalogs
(see German page)

Server path
Experts might be interested in results of a particular server version. By default  is used.

Compatibility
The following tools are recognized and supported:
 * CodeMirror
 * wikEd

Codes and software issues
Please see /software.

Other languages
This gadget is prepared for multilingual support.
 * If you like a version in your own language, please forward translations to me:
 * This documentation page.
 * The  mapping within source code.
 * Further ISO 639 language codes your translation might support.
 * German

Remarks
de:User:PerfektesChaos/js/citoidWikitext