Commit graph

20 commits

Author SHA1 Message Date
Kunal Mehta 4d3d1b72a4 Only enable OOUI if it will be used
If the TemplateData blob failed validation, then OOUI would be enabled
in the ParserOutput even though it wouldn't be used.

Also fix casing of the Status::getHTML() function call.

Change-Id: I1c1cc8ffd46deecd12a07bb13730a073a3363019
2016-08-31 00:57:44 -07:00
Reedy 080aa0cfe7 Remove 'UnitTestList' hook
No longer needed now that extension unittests are autodiscovered.

Bug: T142120
Bug: T142121
Change-Id: I1e6718113af00c1bfc1ca0adff7abb36c3982b8a
2016-08-05 17:42:24 +01:00
Kunal Mehta 7280f40cc6 build: Updating mediawiki/mediawiki-codesniffer to 0.7.1
Also added "composer fix" command.

Change-Id: I7d2e62235f08ecb03f92e5eafccd84b79434c9d1
2016-05-09 17:00:14 -07:00
Ed Sanders c069153411 Display format icon and message inside parameters table caption
Change-Id: Id9d6620ed766645384d31c63aacd7c8167c1ce19
2015-11-13 12:35:07 -08:00
Kunal Mehta 0006cff10c Specify MediaWiki version requirement in extension.json
...and get rid of the wfUseMW() call.

Change-Id: Ie83a8275e2531bcd836a56c19300ea261b5aa2a0
2015-10-29 17:03:52 -07:00
Timo Tijhof 08bf776406 Fix FOUC for TemplateData html rendering
On pages like https://www.mediawiki.org/wiki/Template:Unsigned, the
parameter documentation first renders without these styles because
the module is loaded asynchronously with JavaScript.

Change-Id: I2fdb961e0bd8efb1aa3c3e825d58d1071f20a3ec
2015-09-30 15:13:26 -07:00
Timo Tijhof eb7dab091e Fix ResourcesTest::testUnsatisfiableDependencies test failure
> The module 'ext.visualEditor.mediawiki' must not have target 'mobile' because
> its dependency 'jquery.uls.data' does not have it

This happens when TemplateData is loaded before VisualEditor.
Both extensions provide jquery.uls.data when ULS is not installed.
The first one wins.

Change-Id: I9d24da71bb960b88cfd891ac8523bc2ec97551e1
2015-06-02 02:22:15 +01:00
Kunal Mehta d2343e9569 Use ResourceLoader::isModuleRegistered()
Change-Id: I91319d2d975620b047e7be933aba257f28eb7201
2015-03-15 16:54:16 -07:00
James D. Forrester cda06241f1 Move to wfUseMW for compatibility detection
Change-Id: I46f9c148ec14eae557c4c9c44832a368e2d72e82
2015-02-20 23:44:43 +00:00
Marielle Volz f940a0707b Correctly detect if jquery.uls.data is loaded
Fix onResourceLoaderRegisterModules() to
check if the jquery.uls.data module is already
loaded in the ResourceLoader.

Modify comment to indicate that VE also
loads this module.

Bug: T85733
Change-Id: Idd459555312879a85a0a56fba651f609b4f9a52a
2015-01-03 17:36:36 +00:00
Moriel Schottlender df59f0179a Eventify TemplateDataGenerator and use oojs-ui
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
2014-12-22 12:58:37 -05:00
Moriel Schottlender 8c27921232 Implement edit interface for TemplateData documentation
This adds a TemplateData manager to the edit page in the Template
namespace.

If a <templatedata> tag already exists, the tool will parse it and
display it in a visual interface that the user can then manipulate in
their own language. If there is no <templatedata> tag, the dialog will
appear empty and allow users to add and tweak their desired template
parameter data.

The tool also allows rudimentary parameter import, which picks up the
parameters from a current template into the GUI to make the user's life
easier when producing TemplateData.

The template documentation editor feature is off by default. To enable it
use $wgTemplateDataUseGUI = true in LocalSettings.

Bug: 50436
Change-Id: I863a8199c0b08cc52b320ed00dcba912dd2aeefc
2014-01-14 18:39:20 -08:00
Timo Tijhof 2890feb325 render: Use 'errorbox' instead of 'error' for on-save parse error
This message is output' within the page. A single line in red text was
easily lost on a longer page. This also makes it consistent with other
errors from mediawiki.

Change-Id: I71b8be492d4f9f2ecdecc66a88e17490fbf62112
2013-12-10 21:46:25 +00:00
Aaron Schulz 7629dba738 Avoid extra parsing on edit
bug: 57026
Change-Id: I0782ea669b431697d6c76be945c93d3e2f30f3cf
2013-11-15 00:17:03 +00:00
MatmaRex 7bf85a39a1 Remove all references to TemplateInfo
Change-Id: I5ffc8f75140a2c372fc1c64509b13a534fe07479
2013-09-12 11:41:07 +02:00
MatmaRex d66b4c6090 Store compressed JSON since size is limited
We only have 65535 bytes, let's use them wisely.

Prior to Ib2db241a in core (1.22wmf12) even binary page properties
were sometimes shown as plaintext (e.g. on Special:PagesWithProp).
Thus this introduces a "soft dependency" on that change.

No backwards-incompatible changes were made in public methods.
Added two new ones:

* Add TemplateDataBlob#getJSONForDatabase which returns compressed
  JSON, use it where applicable.
* Add TemplateDataBlob::newFromDatabase which accept compressed and
  uncompressed JSON, use it where applicable.

Use a long pseudorandom string in the test.

Bug: 51740
Change-Id: Ie66b0dd6b6dab6f8648e78595c41e52d9c704d57
2013-09-04 22:52:02 +00:00
Timo Tijhof 088d67b61f Use ParserOptions language instead of RequestContext language
The context user language is correctly set to that of the user
who is saving the page.

Parser options are set to the default language during saving and
only changed to the user language when viewing the page with
a uselang that is not the default wiki language.

As a result we were saving the user language (e.g. French) on
en.wikipedia.org as the canonical version on-save and only changing
it to the correct language for non-English viewers.

To test:
* Wiki set to 'en', user preference language to 'nl'
* Save a page with templatedata
* View it logged-out without a uselang query

Was 'nl', is now 'en'.

Bug: 52419
Change-Id: Ic8b5b63450c9f80b85a95d16cc81ce62fc96b77f
2013-08-01 23:18:00 +02:00
Timo Tijhof 70ab71d6a3 phpcs: Resolve style violations
Change-Id: Ie5d4d84b8d7b6bc88e7a5a1559579e504dd1bd20
2013-05-16 15:31:25 +00:00
Timo Tijhof ffd8899def Add unit tests and fix implemention accordingly
* Add unit tests for all types of invalid input we check for.
* Add unit tests for all types of input we expand or otherwise
  normalise.

* Implement InterfaceText expansion/normalisation.
* Fix bug that caused a string value in the root description property
  to be considered invalid (it only accepted an object, it should
  accept both).

Change-Id: I5a15080f1f924451a9dde8af96ea2922011981ec
2013-04-22 07:42:49 +00:00
Timo Tijhof b7080c5f90 Initial TemplateData commit
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
2013-03-14 19:19:55 +00:00