07 November 2009

Customize MediaWiki into Your Ultimate Collaborative Web Site [Mediawiki]

Customize MediaWiki into Your Ultimate Collaborative Web Site [Mediawiki]: "

The free MediaWiki software is best known for powering Wikipedia, but you don't have to be writing an encyclopedia to put it to good use. Extend, skin, and customize MediaWiki to create any kind of easy-to-update, collaborative web site.

When and Why MediaWiki?

MediaWiki is arguably the most advanced, install-it-yourself, free wiki package available. A wiki is an editable web site; you can change each page's content without having to log into a content management system like WordPress or access the server via FTP or other means—you just hit the edit button. While MediaWiki is built for public web sites that anyone can update, like Wikipedia, you can customize it to limit access to certain users. Like WordPress and Firefox, MediaWiki is extendable via plug-ins that add functionality. MediaWiki is also skinnable, which means your wiki can sport a custom theme so it doesn't look just like Wikipedia.

MediaWiki's greatest strengths are that it makes web site pages extremely easy to update, and it makes managing page changes by multiple users very easy as well. So, while you could use MediaWiki to publish your own personal web site where you're the only author, MediaWiki really shines when you're co-authoring with another person or group, or if you have an editor reviewing text on a site who needs to make quick corrections and changes. MediaWiki is also very good at structuring large amounts of text with simple markup. For example, MediaWiki automatically creates on-page, hierarchical outlines based on page sections (shown here) with links that point directly to those sections (even if they're midway down the page). Whether you're co-writing your NaNoWriMo novel, setting up a company intranet, or just want an easy-to-update web site, MediaWiki fits the bill.

Recently, Adam and I used MediaWiki to write, publish, and expand a book-in-progress using MediaWiki. Check it out to get a feel for what a non-Wikipedia web site using MediaWiki can look like.

MediaWiki Installation and Basic Usage

To use MediaWiki, you'll need a web server with PHP and MySQL available and some experience installing web applications. If you've installed WordPress before, you'll have no problem installing MediaWiki. To do some of the customizations below, you'll have to be comfortable adding files to your installation, doing some light PHP file editing, and in the case of skins, know how to tweak HTML and CSS to get your skin to look how you want.

Back in 2006, we covered how to install MediaWiki and that article still stands up. (However, you can't go wrong getting instructions from the horse's mouth—here are MediaWiki's latest installation instructions.) If you don't want to deal with the hassle of setting up a web server with PHP and MySQL and MediaWiki, check out the quick-setup BitNami installer for MediaWiki.

Once MediaWiki's installed, you can start adding and editing pages to your wiki. Wiki pages aren't made of HTML like regular pages, they're made of special wiki markup. Here's a rundown of the most common bits of wiki markup you'll need to know. To see wiki markup in action, hit the play button to watch a five-minute screencast demonstrating how to edit and create pages ('chapters') of a novel in MediaWiki.

MediaWiki Skins

Out of the box, MediaWiki comes with the look and feel you're so used to from Wikipedia; this MediaWiki skin is called MonoBook, and it's popular and immediately recognizable. However, if you log into your MediaWiki installation and click on preferences, and then the Skins tab, you can dress up your wiki in various other looks. With a little elbow grease, you can also create your own custom skin and assign it as the default to the wiki.

All your wiki's skin files are located in the /path-to-your-wiki/skins/ directory, where 'path-to-your-wiki' is the directory where MediaWiki is installed. A skin is made up of a single PHP file, and a directory with its CSS files and images. For example, a skin called 'My Great Skin' will consist of /path-to-your-wiki/skins/MyGreatSkin.php and /path-to-your-wiki/skins/mygreatskin. Unlike WordPress, you have to update your skin files by hand on your MediaWiki server. Be sure to back up your entire working installation before you start, just in case something goes wrong.

Newbie MediaWiki skin developers would do well to start with a copy of the MonoBook skin files and modify them. WikiHow (another MediaWiki-based site!) offers a simple tutorial on how to do that: How to Create a MediaWiki Skin Based on the MonoBook Skin. You can always preview a skin in your user Preferences->Skins area as you develop to make sure things look how you want. The (X)HTML markup for your skin will be located in its .php file and the CSS files will be located in the skin's folder. Be sure to save any skin-specific images in the skin's folder as well.

Once your skin development is complete, you want to set it as the default for everyone who looks at your wiki, whether or not they're logged in. To do so, in /path-to-your-wiki/LocalSettings.php, set the $wgDefaultSkin variable to to the name of your custom skin and refresh your wiki.

MediaWiki Extensions

Like WordPress, MediaWiki is an extensible web application, and several MediaWiki plug-ins that add functionality to MediaWiki are available for free. Unlike WordPress, MediaWiki extensions require manually copying files into your MediaWiki installation directory and hand-editing the LocalSettings.php file.

Three MediaWiki extensions you may find useful include:

These three extensions are just the beginning. See MediaWiki's list of extensions by category for more.

To install an extension, download its zip file and extract it to the /path-to-your-wiki/extensions/ directory. Then, in your LocalSettings.php file, add a line that includes the extension file. For example, to activate the Cite extension, you'd use the line require_once('$IP/extensions/Cite/Cite.php');. (Each extension's homepage will provide the line of code you'll need to install it, and how to use the extension once it is installed.)

MediaWiki User Permissions

The primary purpose of a wiki is to give anyone the ability to edit its pages, but MediaWiki is customizable enough that you can limit that access if you're concerned about vandalism, or if you want only certain users to be able to change content.

For example, MediaWiki comes with a mechanism to register users, so people can create an account at your wiki and log in. This comes in handy if you want to restrict edit access to only people who are logged into your wiki. Likewise, you can 'protect' pages on your wiki and grant only certain users 'editprotected' page access.

To set your MediaWiki user permissions, you have to edit the LocalSettings.php file. For example, to disable the ability for anyone who visits your wiki to edit its pages, create pages, or add to talk pages, use this code:

$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createtalk'] = false;
$wgGroupPermissions['*']['createpage'] = false;

Above, the * represents all users.

A default group called 'user' refers to visitors who have created an account and logged into your wiki. To give them edit privileges, add the following to your LocalSettings.php file:

$wgGroupPermissions['user']['edit'] = true;

You can even restrict edit access only to users who have created an account AND verified their email address with this code in LocalSettings.php:

# Disable for everyone.
$wgGroupPermissions['*']['edit'] = false;
# Disable for users, too: by default 'user' is allowed to edit, even if '*' is not.
$wgGroupPermissions['user']['edit'] = false;
# Make it so users with confirmed e-mail addresses are in the group.
$wgAutopromote['emailconfirmed'] = APCOND_EMAILCONFIRMED;
# Hide group from user list.
$wgImplicitGroups[] = 'emailconfirmed';
# Finally, set it to true for the desired group.
$wgGroupPermissions['emailconfirmed']['edit'] = true;

MediaWiki's user rights scheme is complex but deeply customizable. See the Manual's User Rights page for a full list of rights, default groups, and how to create your own groups with custom access privileges.

More MediaWiki Customization Fun

This overview of skins, extensions, and user permissions is just a broad look at what's possible in the world of MediaWiki customization. Here are links to a few more common tweaks you might make to your wiki:

  • Set your logo image: If you're using MonoBook or another skin that uses a wiki logo, set it to your custom image.
  • Prettify your wiki URLs: By default, MediaWiki's page URLs look like /index.php?title=Your_Page, but an .htaccess file tweak can make them look like Wikipedia's clean /wiki/Your_Page links.
  • Set a custom Main Page: If 'Main Page' isn't the first two words you want your wiki's visitors to see, you can move the Main Page to a custom page you create and name.
  • Use MediaWiki templates for reusable modules: If you use repetitive page elements, like an image with a caption formatted a certain way, set up a MediaWiki template for easy reuse.
  • Make your wiki read-only with $wgReadOnly: To disable editing on all pages across the board on your wiki, set the $wgReadOnly variable to an explanatory string in your LocalSettings.php file. For example, the line $wgReadOnly = 'Wiki locked for maintenance'; will disable editing of all pages, and display that message to anyone who tries to edit a page.

What are your favorite MediaWiki customizations, extensions, or skins? Share 'em in the comments.

Gina Trapani, Lifehacker's founding editor, is very excited to finally co-author a book for real using MediaWiki. Her weekly feature, Smarterware, appears every Wednesday on Lifehacker. Subscribe to the Smarterware tag feed to get new installments in your newsreader.

http://completewaveguide.com/guide/Get_Started_with_Wave#



"

2 comments:

  1. Gina's online book about wave is here http://completewaveguide.com/guide/Get_Started_with_Wave#

    ReplyDelete
  2. The most abused thing of any mediawiki installation is the talk pages. Spammers just use that to create spamming links. Here's a MediaWiki permission guide -
    http://www.wikipliris.com/w/index.php?title=Restricting_Edit_Privileges_in_MediaWiki

    ReplyDelete