tl;dr: What's the right way for a tag extension to execute JavaScript provided
by the user? (On a private wiki without Internet access.)
Details:
I run a private wiki for developers (not accessible from the Internet) that
lets any wiki page author run JavaScript on a page by adding a tag:
<javascript> alert("hi"); </javascript>
(We understand the security implications, which is why the wiki isn't
accessible by the world.) When we upgraded to MediaWiki 1.26 (from 1.24), a
problem occurred: the <javascript> tag stopped recognizing the "mediawiki" and
"mw" objects, but otherwise works. The following code reports an undefined
variable "mw":
<javascript> mw.loader.using(....) </javascript>
I assume this is because the <javascript> extension builds a <script> tag as a
string and uses the SkinAfterBottomScripts hook to add it to the page, rather
than using ResourceLoader. However, I cannot figure out how to use
ResourceLoader to add JavaScript provided on the wiki page like my small
examples above. We can't use the array $wgResourceModules[$name]['scripts']
because the JavaScript isn't in a static file.
So... what's the right method for injecting author-supplied JavaScript in this
manner?
I've already tried using ResourceLoader to add 'mediawiki' to
$wgResourceModules[$name]['dependencies']. It didn't work, complaining that
'mediawiki' was not a known dependency. I also read
https://www.mediawiki.org/wiki/ResourceLoader/Migration_guide_for_extension_developers
but did not find an answer.
Thanks for any advice!
DanB
_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l