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

edit
  • 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:
mw.loader.load("https://en.wikipedia.org/w/index.php?title=User:PerfektesChaos/js/citoidWikitext/r.js&action=raw&bcache=1&maxage=86400&ctype=text/javascript");
  • If not working as registered user the gadget can be activated by greasemonkey or browser user script.

Possible searches

edit

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

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

edit

The following formatting variations of an ISBN are supported, tolerating spaces, downcasing and upcasing; examples:

  • ISBN 3-7891-4161-5
  • isbn: 9129657520
  • isbn = 978-3-577-09102-2

For any syntactically valid ISBN (even with wrong check digit) WorldCat will be examined.

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.

DOI can be specified in formats like:

  • DOI 10.1000/182
  • doi=10.1000/182
  • [[doi:10.1000/182]]
  • {{DOI|10.1000/182}}

It will be redirected to scientific journals, which present often well prepared informations on their sites.

Standard-IDs: arXiv, PMID, PMC

edit

Formats for arXiv, PubMed are similar as for ISBN etc.:

  • [[arxiv:0704.0220]]
  • arXiv astro-ph/0301118
  • PMID 1234567
  • pmid= 7654321
  • pmid: 1234
  • PMC 123
  • {{PMC|456}}

Scientific journals addressed by such IDs offer frequently semantic metadata.

Library catalogs: DNB, LCCN, OCLC

edit

Formats for DNB, LCCN, OCLC are comparable to those above:

  • DNB 454663196 (Deutsche Nationalbibliothek)
  • dnb=770531741
  • DNB:993443176
  • LCCN 2004-059084
  • {{OCLC|633555891}}

Semantic preparation of catalogs differs.

Interactive operation

edit

Suitable pages

edit

On the following pages the tool will be activated when wikitext source code is edited:

  • All articles (pages in main namesace).
  • All own user pages.
  • WP:Sandbox.[1]

Further pages may be equipped on user defined request.

edit

If there is a graphical tool bar, a button will be inserted, otherwise in the ‘left column’ of the portal page:

Element Mode
 
  • Classic editing tool bar
  • wikEd
 
  • Enhanced editing tool bar
    („WikiEditor“)
tool box without graphical tool bars
Citoid After opening the citoid box above the editing area.

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

edit
  • 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 _ button. Then the content there will be evaluated rather than the cursor position in editing area.

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:

  • 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

edit

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 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

edit

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

Button Effect
0 Abort processing, empty citoid box
_ Show input field for publication definition
? Show this help page in a new browser window (but always the same)
X Abort processing, close citoid box.

Request and problems

edit

In the citoid box the following symbols might be displayed:

Symbol Meaning
  Citoid server is being contacted.
??? No publication specifier has been recognized.
!?!?! A publication specifier was found, but related data is invalid.
* Results are available.
:-( A server did not answer (WMF or target page) or asked for authentification.

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

edit

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:

Button Effect
compact
  • All parameters with value, and mandatory parameters or such to be filled at a later stage.
  • All specifications without gaps in one block.

Intended to be used within continous text.

<ref></ref> Same as ‘compact’ before, but enclosed in <ref> and </ref> tags.
== (section) == (only if template is appropriate)
  • All standard parameters listed (those with current values and those which are frequently completed manually)
  • Begin insertion on a new line and prepend a * as list item.
  • One line per parameter, with indentation.
<references>
  • All standard parameters as before, each in a single line.
  • Enclose in <ref name=""> and </ref> tags.

Intended to be used within a <references> block at the end of the article.

After insertion all parameter values are to be checked, whether they are reasonable or should be corrected or completed 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.

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.

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

edit

Personal adptions are possible.

Define an application object

edit

Even before script loading the following code is to be inserted into personal common.js page:

if ( typeof mw.libs.citoidWikitext !== "object" ) {
   mw.libs.citoidWikitext  =  { };
}

When prepared in this way individual assignments are possible.

Additional pages

edit

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

The .pages 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

edit

(see German page)

Server path

edit

Experts might be interested in results of a particular server version.

mw.libs.citoidWikitext.server = "https://citoid-beta.wmflabs.org/url";

By default https://citoid.wikimedia.org/api is used.

Compatibility

edit

The following tools are recognized and supported:

Codes and software issues

edit

Please see /software.

Other languages

edit

This gadget is prepared for multilingual support.

Remarks

edit
  1. ^ Visit the sandbox page first, then open for editing in same tab.