Creating custom edit buttons for MediaWiki

2020-07-27 02:42发布

Hi im trying to build a mediawiki extension which requires AJAX calls during editing a page. All I need is to add a new edit button on the edit page which displays a javascript popup editor which in turn makes the appropriate calls.

I need to know if it is feasible in Mediawiki, to inject javascrpt code into edit buttons.

Any kind of information or leads are welcome!

2条回答
贼婆χ
2楼-- · 2020-07-27 03:14

Ok clearly the question is very specific, tht no one cared to answer. so if some one else wants to know how to add custom edit buttons in Mediawiki, this is how I did it

I found a Mediawiki help page which asks the user to edit a particular javascript page located at http://(wiki-site-url)/Mediawiki:Comomn.js . On closer inspection this is not an actual js page but a normal wikipage(stored in the database as wikitext) which is loaded by mediawiki during runtime. The site admin can edit this page by adding

if (mwCustomEditButtons) {
 mwCustomEditButtons[mwCustomEditButtons.length] = {
 "imageFile": "<path-to-image-on-the-server>",
 "speedTip": "Comment visible only for editors",
 "tagOpen": "open tag",
 "tagClose": "closing tag",
 "sampleText": "Insert comment here"}
}

This can also be achieved for a single user by applying the same edit on the users own copy of the js file available at http://(wiki-site-url/User:(Your_username)/(skinname).js

Both the js pages could be created if they dont already exist.

查看更多
三岁会撩人
3楼-- · 2020-07-27 03:34

The wiki way is to put an HTML button into a Widget and put your JavaScript there, or better yet in its own Gadget

查看更多
登录 后发表回答