MediaWiki

From JonWiki

jontse.com > HOWTOs > MediaWiki
Jump to: navigation, search

I must say I really like MediaWiki. As I explore its capabilities more, I'll post anything interesting or novel here. This serves more as a reminder in case I need to set a MediaWiki install up again.

Contents

Inline LaTeX Markup

  1. Obtain MediaWiki from http://www.mediawiki.org/
  2. Follow the installation instructions for MediaWiki.
  3. For the inline LaTeX markup, http://www.mediawiki.org/wiki/Manual:Math
  4. We'll need texvc, which is included with MediaWiki, but we need to compile ocaml from http://caml.inria.fr/. For DreamHost, use this guide: http://wiki.dreamhost.com/Unison
  5. Once you have all that, navigate to math directory in your MediaWiki root and run make. That's it.

MediaWiki Skins

Some googling turned up http://www.paulgu.com/. He's made a pretty snazzy MediaWiki Skin, called GuMax, which you see on this site. I really like it.

I made some changes to the CSS templates, but that shouldn't be too difficult to sort out.

Here's some random notes on GuMax:

  • The tabs have been moved to the bottom, which is okay I suppose.
  • The nav sidebar is now strung across the top. Any extra menus you have get strung underneath, and it looks funny, so don't do it.

Adding Breadcrumbs

I decided I needed some snazzy breadcrumbs, so I found this: http://www.ehartwell.com/InfoDabble/MediaWiki_extension:_BreadCrumbs2

The instructions there are pretty impeccable, but you must make sure to use the MediaWiki:Breadcrumbs page. Note the lowercase "c." I had been using MediaWiki:BreadCrumbs, and I couldn't figure out why it was broken till I re-did the whole RTFM thing.

Also, I CSS-fied the breadcrumbs, which was pretty important.

Adding a Purge Tab

When you're doing dev work, caches suck. So, I added a purge tab to each page on the site to fix this issue.

  1. Create a file called add_remove_tabs.php or something in your extensions directory.
  2. Use the require_once directive to include it in your LocalSettings.php
  3. Stick the following code in your add_remove_tabs.php:
<?php
$wgHooks['SkinTemplateContentActions'][] = 'ReplaceTabs';
 function ReplaceTabs ($content_actions) {
      $purge_action['purge'] = array(
        'class' => false,
        'text' => 'Purge',
        'href' => 'http://www.jontse.com/index.php?title='.$_GET['title'].'&action=purge',
      );
      $content_actions = array_merge($content_actions,$purge_action);
      return true;
 }
?>

Adding Source Highlighting

See here: http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi

Note that you need both the MediaWiki extension and GeSHi, which is a standalone PHP syntax highlighting engine.

Adding Useful Parser Keywords

See here: http://www.mediawiki.org/wiki/Extension:ParserFunctions

This basically lets you do things like have if/else and other nifty features within your templates. Very handy.

FlowPlayer Fix

I used the FlowPlayer MediaWiki Extension to play videos on some of my MediaWiki sites, but there were some issues with displaying two videos at once.

On reading the HTML source, I discovered that the FlowPlayer extension author didn't account for multiple videos on a single page.

Here's my fix, to be added near the end of extensions/FlowPlayerExtension/FlowPlayerExtension.php:

//Super Dirty Hack for Fixing PlayerContainer
 //THIS LINE ADDED
$pcfix = rand();
 
//remove the last ,
$flashvars = rtrim($flashvars,",");
$flashvars .= "}})";
$flowplayerpath = $wgScriptPath . "/extensions/flowplayer/FlowPlayer.swf";
 
        $returnString = "<script type='text/javascript' src='/extensions/flowplayer/jquery.js'></script><script type='text/javascript' src='/extensions/flowplayer/jquery.flashembed.js'></script>\n";
 //THIS LINE CHANGED
        $returnString .= "<div id='playerContainer".$pcfix."'></div>\n";
        $returnString .= "<script type=\"text/javascript\">\n";
//THIS LINE CHANGED
        $returnString .= "$(\"#playerContainer".$pcfix."\").flashembed({src:'". $flowplayerpath ."',width:".$args["width"].",height:".$args["height"]."},\n"; 
        $returnString .= $flashvars;
        $returnString .= "</script>\n";
 
        return $returnString;

Yes, I know this is really dirty and can fail, but I'm assuming that the php rand() function doesn't suck, and I was too lazy to implement a real fix using utime.