Another possible approach is to have the MediaWiki server proxy and cache the content from the remote server, and then display it in some kind of safe sandbox. See T31242 https://phabricator.wikimedia.org/T31242.
On Mon, Sep 14, 2015 at 9:15 AM, Daniel Moisset dmoisset@machinalis.com wrote:
How do you handle the "Offline animated image rendering solution" for your current wikiwidgets? What I can think about here is an animated gif fallback, but that would lose interactivity at all (this is something that users will be able to do anyway without any implementation effort)
I don't think we have widgets currently (apart from some JS hacks which change from wiki to wiki and can't deal with offline etc). Videos come closest, and they just display a thumbnail as fallback for offline and old browsers. Depending on the implementation, an interactive algorithm visualisation might work offline just fine, but you need to support old browsers, print/PDF and so on. A simple static image (or even just text explaining there would be a visualisation here but you don't get to see it) would work IMO.
Another (technical) question I have is if there's already something in mediawiki that would allow users to upload JSON content, or if something like that should be implemented. Having that would allow users to use later in markup stuff like {{WikiWidget|WalnutVisualizer:myuser/somecontent}}.
There are three ways to go about this:
- Upload widgets as files, use your own MediaHandler https://doc.wikimedia.org/mediawiki-core/master/php/classMediaHandler.html and MediaTransformOutput https://doc.wikimedia.org/mediawiki-core/master/php/classMediaTransformOutput.html classes to display them. This is what Bryan was referring to in his answer, and probably the best suited for your use case. There is no support for JSON files specifically, but they are not really different from any other file. Licensing and some of the display is handled by MediaWiki, you just need to return an HTML blob from the MediaTransformOutput class, given the dimensions. Compared to the other options, this area of the code is somewhat poorly documented but you can look at the existing media handling extensions https://www.mediawiki.org/wiki/Category:Media_handling_extensions, - Upload widgets as wiki pages. There is some support for JSON pages (see ContentHandler https://www.mediawiki.org/wiki/Manual:ContentHandler and the JsonContent class). This has some advantages if you want to focus on collaboratively creating animations, not just displaying them (you can provide a custom editor, can show custom diffs and so on), but the widget has to be on its own page so not really useful. - Upload widgets as part of the wikitext of a page (something like <animation>...JSON blob here...</animation>). The Graph extension https://www.mediawiki.org/wiki/Extension:Graph is a good example of this. Still somewhat useful for collaborative creation (no JSON support so you get plaintext diffs and less editor support but that's still a lot better than having to compare uploaded files by hand). You need to implement any support you want for licensing and rendering (including how the user can specify size/location) on your own. You can combine this with the previous option to get the benefits of both, via the JsonConfig https://www.mediawiki.org/wiki/Extension:JsonConfig extension (the Graph extension does this as well).