When normalising a TemplateData blob for API consumers, we previously
automatically generated the 'paramOrder' with the order of the keys
as they were specified in the JSON blob (which, unlike in JS, is
known to be reliable in PHP).
While this was useful to some extent, it made it mandatory for
Parsoid and VisualEditor to always re-order properties during
edits to match the specified order.
In order to allow the order to remain flexible/unspecified, the
original Specification made paramOrder optional, but during the
implementation I gave it a default, which kind of defeated that
intention. This patch fixes that.
Bug: T138200
Change-Id: Ib40d23dac7e75274083f95a25c5aa1c22dfffb22
Three-braces-and-a-bang can be a table starting construct in templates.
This also fixes an overlooked bug in which the test wasn't checking
array element key names.
Bug: T157029
Change-Id: I69ed4fc9fe3bb126b7b39abea0f58ad56adf3885
Parameter names can be constructed with parser functions, so
we should not include these as raw parameter names. There
might be more characters to add here.
Bug: T203605
Change-Id: If57a9ed7edf1e881cd121d9a1bcb2e7455c04ec9
When extracting raw parameters from wikitext, ignore those that
only differ from already-found ones by spaces, underscores, or
hyphens.
Bug: T193265
Change-Id: I012e06bf4353eaaf0613124d7d6b88f3444d248a
Deprecate the 'doNotIgnoreMissingTitles' parameter and
replace it with 'includeMissingTitles'. If this parameter
is requested 'raw parameters' will be added to the
response in the same format as templatedata parameters.
Raw parameters are those that *might* be in the
template (using the same logic as the TemplateData generator
wizard).
Also fix the example that was using a falsy value which
meant the option was enabled rather than disabled as it
says in the docs.
Bug: T191756
Change-Id: Ie5fe2097cda45968bb080643d3afcac0b2868a6c
The following sniffs are failing and were disabled:
* MediaWiki.Commenting.FunctionComment.MissingParamComment
* MediaWiki.Commenting.FunctionComment.MissingParamName
* MediaWiki.Commenting.FunctionComment.MissingParamTag
* MediaWiki.Commenting.FunctionComment.MissingReturn
* MediaWiki.Commenting.FunctionComment.ParamNameNoMatch
* MediaWiki.FunctionComment.Missing.Public
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment
Change-Id: I79fb2bf4782b14ba671c15e304f110183adabdf1
* Remove use of undocumented 'this' inside promise callback,
use the promise variable instead.
* Remove needless expectCount.
Change-Id: I3a698207440d8085a502fa54da8bb5feddfa1dcb
Thanks to Thiemo Mättig for the suggestion and specification at
Wikimania 2016 in Esino Lario.
This is an extended version of Thiemo's original specification. This
version also allows specification of "own line" properties for
templates; that is, whether the template should be preceded/followed
by a newline, as requested by James Forrester.
Bug: T138492
Bug: T135667
Change-Id: Idc6b2680330e6bf5caec2bf6fc86a705d25bc649
Reuses some messages, renaming them in the process.
Changes undefined on the client to unknown.
Bug: T61745
Change-Id: I2cf5c25acbe1c854c33b2eb3f23dc74393a456d4
Don't enforce 'inline' as the default format if none is specified.
Instead preserve the unspecified value as 'null'. This allows
third-party tools to provide a better default experience when changing
existing content (e.g. by using smart detection to follow the format
already used).
Bug: T128337
Change-Id: I911c7999e3731c0125fc058118f8d7287d8f88f4
It looks like this is how the code was originally intended,
but 'name' and 'key' are the same thing.
Move the key to the 'alias' list where CSS already exists to
colour it differently.
Change-Id: Ieade122633cec14203f7959121e9cd7250bb9f7a
Adding format data, which defines the preferred source format
to use when using templates.
Possible formats:
* Inline - all parameters in a single line
* Block - each parameter is in its own line
Bug: T64147
Change-Id: Id856c4a38890526060d0619432f06174d66f7792
Add a sourceHandler that deals with all source-related actions
like fetching template source and validating the existing
TemplateData string.
Also add a MessageDialog warning the user in case the TemplateData
is invalid. In this case, the user will be given the option either
to correct the JSON by hand or to start the editor to replace the
existing TemplateData with a new one.
Bug: T91730
Bug: T91325
Change-Id: I4e6d04f02565a02d8dcf5c70a575ab6433caa27f
A dependent and dependee properties should only update one another
once in the model, and the UI should be responsible for resetting
the input when it is toggled.
Bug: T92558
Change-Id: I944aaf9c44d0f305a34458f0b8009a98c9570661
The deprecated property allows for either a boolean or text, so we
should allow the user to insert guidance text in case that property
is true. To achieve that, the model also defines 'textValue' for
boolean properties with text representation so an internal property can
be set to hold that value and inputs can be automatically built from the
property structure.
Bug: T90734
Change-Id: Iadc6abdcc0cf2721a311cf43847b306cb269b5e8
Make sure that paramOrder is initialized as an array even if the
params property of the TemplateData object is empty.
Bug: T91470
Change-Id: I2bc79421be33053e7e21170528fbbd1c01eaf4bb
Change the ui/data behavior to work with oojs and event emitters,
and replace the gui from jquery ui to oojs-ui.
Changes made:
* Recreate the templatedata editor with oojs and ooui.
* Create a standalone templatedata model with internal validation.
* Allow the user to insert language-specific strings:
* Allow adding arbitrary languages and values
* Normalize output between language object and 'simple' string
* Add new language code by searching for its name or code
* Import parameters from template code
* If the template is in subpage and there is no code in the
current page, the code will request the contents of the parent
page.
Change-Id: I985ea03dfee58984ec22ec9a157a00968bfca878
Add "maps" as an allowed root value to template data JSON.
Maps allow applications to map equivalencies between their
application-specific parameters and valid template parameters.
Each Map has arbitrary keys (from the consuming application) that
are mapped to one or more template parameters.
* Added root.maps to TemplateDataBlob
* Validates that values are strings or arrays
* Validates that values are valid params
* Added templatedata-invalid-param to i18n/en.json
* Richer error message for when invalid value is a param
* Fixed existing tests to work with new "maps" property
* Added two new tests for maps
* Test for invalid value (!string or !array)
* Test for invalid parameter
* Added specification for root.maps property and Map object
Change-Id: I3bf5e002ad6c1632e02c4c2e393b244c51f77177
These wiktext-isms from the Status object make the tests rather
obfuscated and hard to read/maintain.
Change-Id: I6438c33229ac013489893f8a2241510d9b5a7765
Add an 'autovalue' parameter property to the TemplateData spec. And
implement it in the validation for the API and in the editor.
Also added tests to make sure all parameter attributes preserve
their values before and after parsing, including the 'autovalue'
parameter.
Bug: 51428
Change-Id: Iffb376a804d39388d2b5b6ea3583ef2a292eea41