[Mediawiki-l] making extra buttons in edit page tool

Alexis Moinet alexis.moinet at fpms.ac.be
Fri Jun 6 12:55:46 UTC 2008


Rein wrote :
> I think the problem is rather that the script is not okay.

well, it works fine on my local vanilla install :-)


> First it is obvious that at mediawiki the script has no results (no extra buttons shown). That's strange because you would think there  should be a working script!

I do see extra buttons for any editable page at http://www.mediawiki.org (when I click on 'edit', I see the 3 buttons just above the edit panel. They look like this : '#R', '-' and 'Cat')


> http://www.mediawiki.org/wiki/MediaWiki:Editpage.js
> This is the script I used. I altered like I wrote the destination of the buttons itself and placed them on my site (of course some I made myself).

can you show us the altered code or a link to your site (if it's not local)


> This line should also puzzles me: 
>  {'imageFile': 'http://upload.wikimedia.org/' + img,
> Shouldn't it be to my own site (I tried but am not sure what the url should be)
> And I think it is connected with the urls of the buttons?

it's the url of the image displayed as a button.

you can replace it with : {'imageFile': 'http://yourwebsite/' + img,

and use the url to the image on your website in the call to addInsertButton()

so if the image is in http://youwebsite/images/extrabutton1.png, you have

{'imageFile': 'http://yourwebsite/' + img,

and

addInsertButton('images/extrabutton1.png','mybutton','...','...','...')

If the image is not found, you should see a simple text 'mybutton' (the second parameter of the function addInsertButton() ) instead of the button. if you see nothing, force-refresh your browser.

NB : you can also let {'imageFile': 'http://upload.wikimedia.org/' + img, and use an image available on the wikimedia server


> If you read it (I'm to too technical, and can read only the basic) this is strange:
> This file is uploaded:
> importScript('MediaWiki:Scripts/Edittools1.js').
> 1. there is no such script
> 2. "Scripts/" looks strange to me
> 3. there is a 'MediaWiki:Edittools.js' but uploading (and correcting the script) had no effect.
> http://www.mediawiki.org/wiki/MediaWiki:Edittools.js
> 
> Then I noticed this:
> loadCommonsEdittoos - twice
> No "l" there: loadCommonsEdittools 
> But no effect here either (nor in combination of above). Nor using it together with the button links in the script.
> Rein

I don't use these two scripts, so they don't seem to be required to make the extra buttons work



NB : for the extra buttons above the edit text pane, I just added (and adapted) some of the function of Mediawiki:Editpage.js in my Mediawiki:Common.js, instead of creating a MediaWiki:Editpage.js page on my wiki

so basically my Mediawiki:Common.js is simply :

/* Any JavaScript here will be loaded for all users on every page load. */
/**
  * Add extra buttons above edit panel
  */

function addCustomButton(imageFile, speedTip, tagOpen, tagClose, sampleText, imageId) {
   mwCustomEditButtons[mwCustomEditButtons.length] =
     {"imageId": imageId,
      "imageFile": imageFile,
      "speedTip": speedTip,
      "tagOpen": tagOpen,
      "tagClose": tagClose,
      "sampleText": sampleText};
}

addCustomButton('http://upload.wikimedia.org/wikipedia/commons/c/c9/Button_strike.png',
                 'strike',
                 '<s>',
                 '</s>',
                 '',
                 'mw-editbutton-strike');


could you check what happen if you have only this in your Mediawiki:Common.js (+ clear your browser's cache) ?




More information about the MediaWiki-l mailing list