Jump to content

User:PerfektesChaos/js/citoidWikitext/opus

From Wikipedia, the free encyclopedia

Software issues related to citoidWikitext: The opus postprocessing interface.

Rationale

[edit]

When a Zotero result arrives, it may be less precise than desired.

Some modifications for certain sources might be appropriate, e.g. distinctions for particular publications based upon URL or details of received data.

Ideally this would have been done upstream already, but for the time being this gives a quick capability to improve the Zotero result set.

Installation

[edit]

Gadget programmers need to wait for correct installation of this script before any function can be used. This requires two steps, loading and executing.

if ( ! mw.loader.getState( "ext.gadget.citoidWikitext/opus" ) ) {
   mw.loader.state( { "ext.gadget.citoidWikitext/opus": "loading" } );
   mw.loader.load( "https://en.wikipedia.org/w/index.php?"
                   + "title=User:PerfektesChaos/js/"
                   + "citoidWikitext/opus/r.js"
                   + "&bcache=1&maxage=604800"
                   + "&action=raw&ctype=text/javascript" );
}
mw.hook( "citoidWikitext/opus.ready" ).add( mainTask );

Loading again would not be meaningful if already done. Therefore the state of this script is checked first. Another gadget which also uses this script library might have loaded already.

When loading of all components has been completed, the citoidWikitext/opus.ready hook will be fired.

Here is mainTask a callback function with the actual functionality of the user application.

function mainTask( application ) may use one parameter. That is the application object for the library. It is supposed to be mapped into mw.libs.citoidWikitext also.

API

[edit]

The application object gained by callback function exposes the following function (among others).

.opus.fire()

[edit]

Transform and merge multiple citoid results.

Call .opus.fire(ask,answers)
Parameter Type Meaning
ask object basic citoid query
answers Array citoid server results, each an object, at least one
Return value Array of citoid results.
  • The elements of answers will be reflected, and might be modified copies.
  • The first element [ 0 ] does contain the best merge of all elements, and will have been improved if possible.

Improvement means:

  • completion by guessing missing fields
  • standardization and interpretation of values
  • normalization of encoding
  • formatting of values (dates, languages etc.)
  • additional knowledge about some publications

Merging means that the same query (“what book is this?”) may be launched to several libraries. Their answers might differ or fail completely. Partial answers from one library may fill gaps in the answer of another one.

The result ensures entries for all compontents of the minimum data model.

See also

[edit]
  • softwarecitoidWikitext software issues in general