Page MenuHomePhabricator

allow limited wikicode rendering via api.php
Closed, ResolvedPublic

Description

Author: herd

Description:
(Per IRC convo with yurik)

There is a native feature called LivePreview in the mediawiki core code (since 1.5), which allows an ajax POST request to fetch a preview (similar to action=render), but this feature request is not quite the same.

The easiest description would be by pseudoexample: /w/api.php?action=livepreview&wiki=%5B%5BFoo%5D%5D

On enwp it would return: <a href="/wiki/Foo" title="Foo">Foo</a>

On a wiki without such a page: <a href="/w/index.php?title=Foo&amp;action=edit" class="new" title="Foo">Foo</a>

Future uses include ability to link to a preview, rather than require POST data, as well as possibly speeding up popups, and giving bots the ability to check wikicode structure easier. Could also improve wikiwyg feasability.

Negative aspects do include possible performance vulnerabilities (associated with extensions) such as rapid generation of <timeline> and <math> tags (which already exist with LivePreview), but the restricted length of GET requests should limit this somewhat.

Additionally, some new format= parameters may be required for optimal usage, such as format=raw (content-type: text/plain) format=render (content-type: text/html, with wrapping xml), etc.


Version: unspecified
Severity: enhancement
URL: http://en.wikipedia.org/w/api.php

Details

Reference
bz11173

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:49 PM
bzimport set Reference to bz11173.

Okay, the same feature will be nice for expanding templates

(In reply to comment #1)

Okay, the same feature will be nice for expanding templates

Can't you just do this?

/w/api.php?action=livepreview&wiki={{template|param1|param2}}

Created attachment 4222
Proposed patch

Ok, here's a proposed implementation. Usage:
api.php?action=render&title=Test&text=dd[[ff]]{{ee}}

Attached:

Will also verify and test this one tomorrow.

Added in r26501. Thanks to VasilievVV for the patch.