User:PerfektesChaos/js/citoidWikitext/software/wikiProject

Creating a plug-in for a particular wiki project to run citoidWikitext.

Project dependant template specfications and other adaptions need to be provided. The plug-in will receive the common results of the investigation, and shall determine whether and how that shall be inserted into the wikitext source.

Project identifier
Each WMF wiki has a unique identifier by database name, which is available for JavaScript by  configuration specifier.

Typical values are: This code is referred on this page as wikiDB placeholder.
 * for English Wikipedia
 * for German Wikipedia
 * for French Wikisource

Requirements

 * Every plug-in is supposed to provide the Resource Loader module identification wikiDB as soon as possible; beginning with   and   when built.
 * The function wikiDB  has to be supported as specified below.

Source code location
There are three ways to provide the plugin code.
 * 1) By default, registered projects are expected at the tool’s root directory:
 * wikiDB
 * That may consist of two statements:
 * declare loader state to be still
 * load from any other place, e.g. project’s MediaWiki space or trusted user page or anywhere else.
 * 1) By previous external activities, Resource Loader module identification may have been satisfied.
 * 2) * This may be used to provide own forks, e.g. for testing or debugging, and goes for all modules.
 * 3) A   value at the JS variable component was set in advance:
 * wikiDB
 * This is supposed to be a URL which resolves to something which is returning  MIME type.

Plug-in object
A JS variable component is set to be an  (non-null):
 * wikiDB

Within the plug-in object the following function has been defined:
 * wikiDB
 * – Array of citoid server results
 * – combined and enhanced result
 * Further elements of  are distinctive results, when multiple query URLs have been sent to server.
 * Return value: Array,, or.
 * – no meaningful text insertion could be derived from these results.
 * Array, with elements:
 * – Array, with elements describing the entire template:
 * –, with template title or any page name
 * –, on multi-line insertion
 * – permit multiple lines
 * – always compact
 * –, on bibSection option
 * – offer bibSection unordered list
 * – do not mention
 * – Array, with elements describing one single parameter for n>0:
 * –, with parameter name (currently no unnamed parameters expected, but might be supported by  )
 * –, on empty values
 * – show empty parameter assignment, even in compact mode
 * – never show empty parameter assignment
 * –, with parameter value, or   or
 * , with preformatted insertion text
 * No bibSection option.

It is up to the wiki project to determine how to react on a result.

Stated as
The Resource Loader module identification
 * wikiDB

pretends to be.

Templates on input
The plug-in object may contain a component  as object:
 * wikiDB.

That object may contain functions like this:
 * wikiDB.

This function will be called, if a template of this name has been chosen for input. The  utility below might help.
 * One string as input parameter, starting with first pipe or terminating brackets of template transclusion.
 * Supposed to return a URL or other keyword/data, or false.

Common library
For the benefit of plug-in programmers, a set of public components of the application object is provided.
 * .core.fold
 * Derive simple template parameter assignments; not nested, no links.
 * Available from beginning.
 * One string as input parameter, starting with first pipe or terminating brackets of template transclusion.
 * Returns object, with parameter components identified by strings


 * .opus.fetch( assembly, access )
 * Retrieve string value from query result
 * assembly – object, with query result
 * access – string, with component name


 * .opus.figures( apply )
 * Format list of comma-separated hyphen-joined number ranges
 * apply – string, or not


 * .opus.fork( array )
 * Duplicate template definition Array
 * array – Array with basic citoid query


 * .opus.format( assembly )
 * Guess URL content type, like PDF
 * assembly – object, with citoid server result


 * .opus.freeze( amount )
 * Retrieve ISO 8601 string of current date and time
 * amount – Number of digits; 10: date

The  components are available for result evaluation only.

Sandbox
If the project sandbox like WP:Sandbox shall be equipped by default, it needs to be registered at Q3938.