mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-23 23:43:54 +00:00
b7080c5f90
Registers a parser tag <templatedata> that should have a JSON blob as content. The blob is then validated and normalised when MediaWiki parses the page (e.g. during save and preview). If there are validation errors, the save is aborted from the extension hook and an error is displayed. If all goes well, the normalised blob is stored in the database (which can be retrieved through the API). And an HTML representation of the template parameters is returned to the wikitext parser to show where the <templatedata> was in the page. The blob format is specified in spec.templatedata.json and is validated in TemplateDataBlob::parse. Bug: 44444 Change-Id: Icf305892a9512545a63f5a5280cc0d340c61585f
154 lines
3.8 KiB
JSON
154 lines
3.8 KiB
JSON
/*
|
|
Specification for the JSON descriptor as used in the
|
|
TemplateData extension for MediaWiki.
|
|
|
|
Author: Timo Tijhof
|
|
Author: Trevor Parscal
|
|
|
|
@structure {Object} Root
|
|
@property {InterfaceText} [description]
|
|
@property {Object} params Contains all parameters.
|
|
Keyed by parameter name, contains #Param objects.
|
|
@property {Object} sets Groups of parameters that should be used
|
|
together. Groups may overlap with each other, though this is not recommended.
|
|
Keyed by an internal id, contains #Set objects.
|
|
|
|
@structure {Object} Param
|
|
@property {InterfaceText} [label] Defaults to key of object in `Root.params`.
|
|
@property {boolean} [required=false]
|
|
@property {InterfaceText} [description]
|
|
@property {boolean|string} [deprecated=false] Tooltip for the user detailing
|
|
the intent for the deprecated parameters.
|
|
@property {Array} [aliases] List of aliases.
|
|
An alias is an alternative name for the parameter that may be used instead of
|
|
(not in addition to) the primary name. Aliases are not documented in a
|
|
separate Param object. If they need more information, they should be in their
|
|
own property marked "deprecated".
|
|
@property {string} [inherits] Key to another object in `Root.params`.
|
|
The current Param object will inherit from that one, with local properties
|
|
overriding the inherited ones.
|
|
@property {string} [default] The default value or description thereof.
|
|
@property {Type} [type] The type of the expected parameter value.
|
|
|
|
@structure {Object} Set
|
|
@property {InterfaceText} [label] Defaults to key of object in `Root.sets`.
|
|
@property {Array} params A subset of the parameter's names that belong to this set.
|
|
|
|
@structure {string} Type
|
|
One of the following:
|
|
- string
|
|
Any textual value.
|
|
- number
|
|
Any numerical value (without decimal points or thousand separators).
|
|
- wikipage
|
|
A valid MediaWiki page name for the current wiki. Doesn't have to exist,
|
|
but if not, should be a valid page name to create.
|
|
- wikiuser
|
|
The username of an account on the current wiki (regardless of whether
|
|
that user has an edit count or a user page).
|
|
|
|
@structure {string|Object} InterfaceText
|
|
A free-form string (no wikitext) in the content-language of the wiki, or,
|
|
an object containing those strings keyed by language code.
|
|
|
|
|
|
Examples:
|
|
*/
|
|
[
|
|
/**
|
|
* Template:Unsigned
|
|
* Example for
|
|
* {{unsigned|JohnDoe|2012-10-18}}
|
|
* {{unsigned|user=JohnDoe|year=2012|month=10|day=18|comment=blabla}}
|
|
*/
|
|
{
|
|
"params": {
|
|
"user": {
|
|
"label": "Username",
|
|
"required:": true,
|
|
"description": "User name of person who forgot to sign their comment.",
|
|
"aliases": ["1"]
|
|
},
|
|
"date": {
|
|
"label": {
|
|
"en": "Date"
|
|
},
|
|
"description": {
|
|
"en": "Timestamp of when the comment was posted, in YYYY-MM-DD format."
|
|
},
|
|
"aliases": ["2"]
|
|
},
|
|
"year": {
|
|
"label": "Year"
|
|
},
|
|
"month": {
|
|
"label": "Month"
|
|
},
|
|
"day": {
|
|
"label": "Day"
|
|
},
|
|
"comment": {
|
|
"required": false
|
|
}
|
|
},
|
|
"sets": {
|
|
"date": {
|
|
"label": "Date",
|
|
"params": ["year", "month", "day"]
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* Template:TemplateBox
|
|
* Example for:
|
|
* {{TemplateBox|1d=..|2d=..|10d=..}}
|
|
*/
|
|
{
|
|
"description": "Document the documenter.",
|
|
"params": {
|
|
"1d": {
|
|
"label": "Param 1",
|
|
"description": "Description of the template parameter",
|
|
"type": "string"
|
|
|
|
},
|
|
"2d": {
|
|
"label": "Param 2",
|
|
"inherits": "1d"
|
|
},
|
|
"3d": {
|
|
"label": "Param 3",
|
|
"inherits": "1d"
|
|
},
|
|
"4d": {
|
|
"label": "Param 4",
|
|
"inherits": "1d"
|
|
},
|
|
"5d": {
|
|
"label": "Param 5",
|
|
"inherits": "1d"
|
|
},
|
|
"6d": {
|
|
"label": "Param 6",
|
|
"inherits": "1d"
|
|
},
|
|
"7d": {
|
|
"label": "Param 7",
|
|
"inherits": "1d"
|
|
},
|
|
"8d": {
|
|
"label": "Param 8",
|
|
"inherits": "1d"
|
|
},
|
|
"9d": {
|
|
"label": "Param 9",
|
|
"inherits": "1d"
|
|
},
|
|
"10d": {
|
|
"label": "Param 10",
|
|
"inherits": "1d"
|
|
}
|
|
}
|
|
}
|
|
]
|