Common requirements
Input/output formats (to substitute into {input} and {output} in the use cases below):
- html -> html
- html -> wikitext
- wikitext -> html
For html as a output format, an optional bodyOnly field causes the response to include only the innerHTML of the DOM body
Use case: raw content transformation
Request to RESTBase: POST /{domain}/v1/transform/{input}/to/{output}.
TBD
- Who the first round of users of this feature will be
- Request content type, headers, body model
- Response status, content type, headers body model
Use case: transformation of content from an existing page
- Title and revision are passed: POST /{domain}/v1/transform/{input}/to/{output}/{title}/{revision}
TBD
- Who the first round of users of this feature will be
- Request headers, body model
- Response status, content type, headers body model
Implementation notes
For html-to-wikitext support, we'll need to store the Wikitext in storage. See how Parsoid gets wt from the MW API.
RESTBase retrieves the original html, wikitext & data-parsoid from storage & POSTs it to Parsoid:
POST parsoid/v2/{domain}/wt/{title}/{oldid} { "html": { "headers": { "content-type": "text/html;profile=mediawiki.org/specs/html/1.0.0" }, "body": "<html>The modified HTML</html>" }, "original": { "revid": 12345, "wikitext": { "headers": { "content-type": "text/plain;profile=mediawiki.org/specs/wikitext/1.0.0" }, "body": "the original wikitext" }, "html": { "headers": { "content-type": "text/html;profile=mediawiki.org/specs/html/1.0.0" }, "body": "the original HTML" }, "data-parsoid": { "headers": { "content-type": "application/json;profile=mediawiki.org/specs/data-parsoid/0.0.1" }, "body": { "ids": {} } } } }
If the modified html is just a string, then Parsoid is expected to assume that it's in the latest html version.
Parsoid returns the wikitext, which RESTBase returns to the client without any caching:
{ wikitext: { headers: { 'content-type': 'text/plain;profile=mediawiki.org/specs/wikitext/1.0.0' }, body: "the modified wikitext" } }
We could also just return the wikitext with the appropriate content-type header, but there is something to be said for consistency & the ability to return additional metadata (like warnings or errors) in the future.