Tuesday 20 October 2009

MediaWiki - Help file import, no SVG support, and additional edits

Another MediaWiki post. This time, I ran into some trouble after exporting all help pages from the official wiki, and trying to import them to my own, as described here.

I'd also recommend you to import Manual:LocalSettings.php, as that is referenced in one of the help pages in an admin-only box.

At the bottom of the list of files referenced, there's a whole bunch of images, which you have to save manually. Some include files in .svg format (vector based), but before you can actually use those, you need to install additional software.

My problem is that I have no idea how to install stuff my VPN, as I am not sure my host enabled a shell account for me. So rather than potentially messing up my box, or relying on my host for something I'm not even sure will add that much value, I figured I'd learn something about wiki, and just change the references from .svg to the png format in which I saved all the files.

As you see, the official wiki page is little help. "You might have to edit some pages to fix the link".

Anyway, here's the pages/items that require editing for the images:

Template:Admin_tip
Template:PD_Help_Page (I also removed some conditional IF statement here)

Further edits I did:
All pages: Removed {{Languages}} tags.

Help:Navigation - There's an admin-block halfway down the page that references a bunch of settings in the LocalSettings.php file. However, the link seemed broken. I replaced this:

{{mediawiki|Manual:LocalSettings.php#Upload location|upload location}}


with this:

[[Manual:LocalSettings.php#Upload location]]
, and the same for the other links in the block.

Help:Starting_a_new_page - Similar edit to the one at Help:Navigation. In the admin-tip, replaced:

{{mediawiki|Extension:Inputbox|inputbox extension}}


with

[[Extension:Inputbox|inputbox extension]]


Help:Navigation references LocalSettings.php, which in turn references Template:Caution. Let's tackle that one next. First of all, we need the proper image referenced. The SVG is here, from where you can also download the other formats. I picked sng.

There's also some weird code in the template that I removed. I basically changed the whole top section, which checks the format of the template invocation, and stripped out the ability to use tables (for some reason, the conditional if made my template look all whack):

{{#if: {{{1|}}}|
}}[[Image:Nuvola apps important.svg|18px|Caution!]] '''Caution''': {{#if: {{{1|}}}|{{{1|}}}
}}


with:

[[Image:Nuvola apps important.png|18px|Caution!]] '''Caution''':


More will follow soon :)


Read more!

MediaWiki - Toolbar

Recently, we downloaded and installed MediaWiki. To our surprise, our of the box, the toolbar available when installing is lacking quite a few buttons that are standard available on wikipedia itself.

The MediaWiki helpfiles are less than helpful, though they do contain a description on how to add a single (table) button. For those wanting to replicate the look of the actual wiki, here's the code for the remaining buttons. You'll need to make modifications to two files (make backups first):


/w/EditPage.php

Find the following snippet:

),
array(
'image' => $wgLang->getImageFile('button-hr'),
'id' => 'mw-editbutton-hr',
'open' => "\n----\n",
'close' => '',
'sample' => '',
'tip' => wfMsg('hr_tip'),
'key' => 'R'
)


Below/after that, add the following:


,
array(
'image' => $wgLang->getImageFile('button-redirect'),
'id' => 'mw-editbutton-redirect',
'open' => '#REDIRECT [[',
'close' => ']]',
'sample' => wfMsg('redirect_sample'),
'tip' => wfMsg('redirect_tip'),
'key' => 'V'
),
array(
'image' => $wgLang->getImageFile('button-strike'),
'id' => 'mw-editbutton-strike',
'open' => "",
'close' => "
",
'sample' => wfMsg('strike_sample'),
'tip' => wfMsg('strike_tip'),
'key' => 'S'
),
array(
'image' => $wgLang->getImageFile('button-linebreak'),
'id' => 'mw-editbutton-linebreak',
'open' => "
",
'close' => "",
'sample' => '',
'tip' => wfMsg('linebreak_tip'),
'key' => 'BR'
),
array(
'image' => $wgLang->getImageFile('button-superscript'),
'id' => 'mw-editbutton-superscript',
'open' => "",
'close' => "
",
'sample' => wfMsg('superscript_sample'),
'tip' => wfMsg('superscript_tip'),
'key' => 'I1'
),
array(
'image' => $wgLang->getImageFile('button-subscript'),
'id' => 'mw-editbutton-subscript',
'open' => "",
'close' => "
",
'sample' => wfMsg('subscript_sample'),
'tip' => wfMsg('subscript_tip'),
'key' => 'I2'
),
array(
'image' => $wgLang->getImageFile('button-smalltext'),
'id' => 'mw-editbutton-smalltext',
'open' => "",
'close' => "
",
'sample' => wfMsg('smalltext_sample'),
'tip' => wfMsg('smalltext_tip'),
'key' => 'J1'
),
array(
'image' => $wgLang->getImageFile('button-hidden'),
'id' => 'mw-editbutton-hidden',
'open' => "",
'sample' => wfMsg('hidden_sample'),
'tip' => wfMsg('hidden_tip'),
'key' => 'HC'
),
array(
'image' => $wgLang->getImageFile('button-gallery'),
'id' => 'mw-editbutton-gallery',
'open' => "",
'close' => "
",
'sample' => wfMsg('gallery_sample'),
'tip' => wfMsg('gallery_tip'),
'key' => 'HC'
),
array(
'image' => $wgLang->getImageFile('button-blockquote'),
'id' => 'mw-editbutton-blockquote',
'open' => "
",
'close' => "
",
'sample' => wfMsg('blockquote_sample'),
'tip' => wfMsg('blockquote_tip'),
'key' => 'B1'
),
array(
'image' => $wgLang->getImageFile('button-table'),
'id' => 'mw-editbutton-table',
'open' => "{|",
'close' => "|}",
'sample' => 'class="wikitable sortable border=1 cellpadding=5"
|+ table name
|-
! style="color:#AAB5BE;background-color:#24313F;" | header 1
! style="color:#AAB5BE;background-color:#24313F;" | header 2
! style="color:#AAB5BE;background-color:#24313F;" | header 3
|-
| style="color:#24313F;" | row 1, cell 1
| style="color:#24313F;" | row 1, cell 2
| style="color:#24313F;" | row 1, cell 3
|-
| style="color:#24313F;" | row 2, cell 1
| style="color:#24313F;" | row 2, cell 2
| style="color:#24313F;" | row 2, cell 3
',
'tip' => wfMsg('table_tip'),
'key' => 'A'
),
array(
'image' => $wgLang->getImageFile('button-reference'),
'id' => 'mw-editbutton-reference',
'open' => "",
'close' => "
",
'sample' => wfMsg('reference_sample'),
'tip' => wfMsg('reference_tip'),
'key' => 'R1'
)


For icons, refer to the link above, and find the link at the first option.

Secondly, you need to edit /w/languages/messages/MessagesEn.php. This file will allow us to add both the path to the actual icons (which ought to be placed in /skins/common/images, by the way), and assign a tooltip text (which shows when you hover your mouse over a button) and a sample (which will be put as an example when you click the button. For instance, when you will click the strike-out button, this will show up: Struck out text, and Struck out text is the sample).

Find:

'button-hr' => 'button_hr.png',


Below it, add:

'button-table' => 'button_table.png',
'button-redirect' => 'button_redirect.png',
'button-strike' => 'button_strike.png',
'button-superscript' => 'button_sup_letter.png',
'button-subscript' => 'button_sub_letter.png',
'button-linebreak' => 'button_linebreak.png',
'button-smalltext' => 'button_small_text.png',
'button-hidden' => 'button_hide_comment.png',
'button-gallery' => 'button_gallery.png',
'button-blockquote' => 'button_blockquote.png',
'button-reference' => 'button_reflink.png',


Then find:

'hr_tip' => 'Horizontal line (use sparingly)',


And replace it with:

'table_tip' => 'Insert table (3 by 3)',
'redirect_tip' => 'Redirect',
'redirect_sample' => 'Target page name',
'strike_tip' => 'Strike',
'strike_sample' => 'Strike-through text',
'subscript_tip' => 'Subscript text',
'subscript_sample' => 'Subscript text',
'superscript_tip' => 'Superscript text',
'superscript_sample' => 'Superscript text',
'smalltext_tip' => 'Small text',
'smalltext_sample' => 'Small text',
'hidden_tip' => 'Insert hidden comment',
'hidden_sample' => 'Comment',
'gallery_sample' => 'Image:Example.jpg|Caption1
Image:Example.jpg|Caption2',
'gallery_tip' => 'Insert a picture gallery',
'blockquote_tip' => 'Insert block of quoted text',
'blockquote_sample' => 'Block quote',
'reference_tip' => 'Insert a reference',
'reference_sample' => 'Insert footnote text here',


That's all there really is to it. Your toolbar now reflects the standard one at wiki.


Read more!