Commit graph

62 commits

Author SHA1 Message Date
Mark Holmquist 53e48a98d5 Add specialized short-form string/line type
This is to help differentiate between <input type="text" /> and
<textarea> fields. We need this for UploadWizard in particular because
we intend to build a form for the Information template on Commons, and
it has both small fields (for which we'll use <input>) and big ones
like description (for which we need <textarea>).

Change-Id: Ib9b381816d18f2723a9f715c54f6a64ff4b69847
2013-07-11 17:04:42 -07:00
Timo Tijhof 70ab71d6a3 phpcs: Resolve style violations
Change-Id: Ie5d4d84b8d7b6bc88e7a5a1559579e504dd1bd20
2013-05-16 15:31:25 +00:00
Timo Tijhof 708bbad12d Implement Sets
Change-Id: I93a0ba7287fec6e5566994d03dff1d8eaeeb8430
2013-05-16 01:35:31 +02:00
Timo Tijhof 059c5b18f1 TemplateDataBlob: Improve error handling
For invalid keys, pass property path, not just the latest
child.

Changes error:
 - Invalid value for "typo"
 + Invalid value for "params.date.typo"

Also cleaned up the concatenation logic for the others to
be more readable (PHP dots vs. string dots):
 - 'params.' . $paramName . '.key'
 + "params.{$paramName}.key"

Change-Id: I666e0b22f4b7bacc5b89b0761c74138732f94d73
2013-05-09 07:12:05 +00:00
Timo Tijhof 5e50116d6d TemplateDataBlob: Implement 'type' and 'label'
InterfaceText now defaults to null instead of {en:""} which
was awkward to deal with in the frontend.

As specified:
- label is InterfaceText
- type is a string and must be a one of the recognized types

Updated example for the hypothetical variant of Template:Unsigned
and removed other no longer needed example.

HTML output has been revised per conversation with Trevor,
James and Timo:
- Not sortable.
- Add label to html output.
- Aliases in the main parameter column (one per line),
  but muted in styling.
- Add type to html output.

The css module styles content from the server, not content
generated by javascript. Moved module to position => top to
fix flash of unstyled content.

Change-Id: I16d3f9e460c5513935b9b55fe4cec0092b38e6c2
2013-05-09 02:49:56 +00:00
Timo Tijhof 8636d19ca8 TemplateDataBlob: Don't add class "sortable" to HTML rendering
Change-Id: I7268a5a4d1cced7eaf74f8c6000144287bce397e
2013-05-01 00:32:31 +02:00
Timo Tijhof 61ab90278a TemplateDataBlob: Convert 'clones' to 'inherits'
Before

{
  a: {
    ...,
    clones: ['a2', 'a3']
  },
  a2: {
    some: 'thing'
  },
  a3: {
    other: 'thing'
  }
}

After

{
  a: {
    ...
  },
  a2: {
    inherits: 'a',
    some: 'thing'
  },
  a3: {
    inherits: 'a',
    other: 'thing'
  }
}

Change-Id: Ib17d9e299d503c35e3ee817d3cc4ecb56186b84c
2013-05-01 00:32:08 +02:00
Timo Tijhof 93e8f78fec TemplateDataBlob: Add comments referencing parts of the spec
Also moved 'inherit' up to make the code easier to follow.

Change-Id: I0059236924c5b49bff71a745b9895651c4eb6d0b
2013-04-30 23:24:44 +02:00
Timo Tijhof 942c88f749 API: Update/Normalise before outputting
I ran into countless random exceptions and errors locally due to
cache I built up over time that was no longer valid. Though in
approved commits in the repository there is only 1 version as of
now, I'm sure we will make changes in the future that require a
cache invalidation since getHtml needs to be able to make
assumptions about what properties exist.

Also fixed a bug in the parse() method where the 'deprecated'
property is asserted the wrong way around. Added a test for it.

Change-Id: I5f61d6030578a711909435c8b996373e9aaa5178
2013-04-23 23:52:37 +00:00
Timo Tijhof b18ca675bc TemplateDataBlob: Fix getHtml exception
getHtml failed with a PHP exception in Html.php regarding
converting stdClass to string.

Change-Id: I9b703d496684a9d389ec6112895a3d21a0c763b3
2013-04-22 22:07:21 +02: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