Mediawiki configuration: a quickstart tutorial

September 7th, 2009 in Mediawiki. Add comment
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 5.00 out of 5)
Loading ... Loading ...

If you have installed Mediawiki but still trying to find your way around on how to customize it for your needs, this cheat sheet describes some of the basic configuration aimed at giving you a head start. The configurations have been tested with Mediawiki 1.15.1.
In the descriptions below, all changes to variables (e.g $wgGroupPermissions etc) are made in LocalSettings.php in the Mediawiki install directory.

Basic user permissions configuration

All users, including anonymous users, are in the ‘*’ group; all registered users are in the ‘user’ group.

  • Prevent anonymous edits (i.e edits by unregistered users):

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

    NOTE: To disallow anonymous users from viewing any pages, change the ‘edit’ to ‘read’ above

  • Block anonymous users from viewing some pages: The following prevents users from viewing all pages except the Main Page the Userlogin special page and a page called Test Page.

    $wgGroupPermissions['*']['read']=false;
    $wgWhitelistRead=array (”Main Page”,”Special:Userlogin”,”Test Page”);

  • Add users to a custom group:
    1. The following will create a group called ‘editors’ as well as give it ‘edit’ permissions:

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

    2. Then go to the User Rights special page (http://your_wiki_url/index.php/Special:UserRights), Enter the username of the user to add to the group and click on Edit User Groups button. You should now be able to add users to the editors group by selecting the appropriate checkbox. See below:
      mediawikiuserrights Mediawiki configuration: a quickstart tutorial
  • Allow only some users to edit:

    1. First create a new group and add users to it as described above.
    2. Then revoke edit permissions to anonymous users, the ‘user’ group and grant it to the new group -’editors’ in our case- and (optionally) to the sysop group.

      $wgGroupPermissions['*']['edit']=false;
      $wgGroupPermissions['user']['edit']=false;
      $wgGroupPermissions['editors']['edit']=true;
      $wgGroupPermissions['sysop']['edit']=true;

  • Disallow editing of particular pages to all except administrator: Log in as admin, go to your target page(s) and use the protect page option at the top the page.
  • Change password: Go to the maintenance directory and run: php changePassword.php –user=someuser –password=somepass or use the email password option from the user login page.
  • Show list of users: Go to http://your_wiki_url/index.php/Special:ListUsers

Editing

  • Uploading images:

    1. Enable image uploads: Go to LocalSettings.php and add the following line:

      $wgEnableUploads=true;

    2. Change permissions in the images directory: Change the permissions in the images directory so that it is writable by the webserver i.e. in Unix do the following:

      %> chgrp -R apache $MEDIAWIKI_HOME/images
      %> chmod 765 $MEDIAWIKI_HOME/images

      NOTE: If you are using the default Ubuntu webserver change ‘apache’ to ‘www-data’ in the above.

    3. Use the upload file link on the left menu (under toolbox) and upload the file.
  • Embedding images:To embed images in your posts use any of the following

    1. For a basic image: [[Image:Example.jpg]]
    2. For a thumbnail: [[Image:Example.jpg| thumb]]
    3. For a thumbnail with description: [[Image:Example.jpg|thumb| Example description]]
    4. To create a gallery:

      <gallery widths=”100px” heights=”100px” >
      Image:a.gif
      Image:b.gif|a caption
      Image:c.gif
      </gallery>

    NOTE: When text flows around an image but you’d like it to stop flowing and restart after the bottom of the image, use the following

    <br style=”clear:both” />

  • Change existing or add a new side menu: Go to http://your_wiki_url/index.php/MediaWiki:Sidebar and edit. The format is:

    *menu header
    **pagename|link text

  • Add a sitewide notice: set $wgSiteNotice to the notice you want to display.
  • Table of contents: A table of contents is added on top of the page whenever there are more than three headers in the article in the page. You can override this default behavior in the following ways:

    1. Do not add table of contents: In the page edit mode enter _NOTOC_ anywhere in the page
    2. Place table of contents at a different location: In page edit mode, enter _TOC_ at the location in the page you want it.
    3. Force add table of contents for pages that have fewer than four headers: In page edit mode, enter _FORCETOC_

Look and feel configuration

  • Change default skin (to cologne blue):

    $wgDefaultSkin=’cologneblue’

  • Disallow users from changing their own skins: users can change their skins by going to preferences->skin tab. If for some reason you don’t want users to have this feature, set the following:

    $wgAllowUserSkin = false

  • Adding custom styles:

    1. The easiest way to add your own look & feel is to choose the skin that conforms to the layout you want and then style the elements of your skin.
    2. To add your custom styles to your skin, edit the css page of your skin. However, the Mediawiki docs do not recommend directly editing the css files in the skins folders. Edits should be done through the wiki. For example, if you are using the default Monobook skin, use the page: http://your_wiki_url/index.php/MediaWiki:Monobook.css to add your styles. To add styles that are common across all skins, use the page http://your_wiki_url/index.php/MediaWiki:Common.css.
      For example adding the following css to MediaWiki:Monobook.css :

      /* CSS placed here will affect users of the Monobook skin */
      
      /* the main area that contains the text */
      #content {
             background: #F8F2E5;
             color: black;
             border: 1px solid #1B619B;
             line-height: 1.5em;
             width:80%;
      }
      /* the background of the area outside the main content area */
      body {
        background: #D3E0EA;
      }
      /*stuff that's outside of the main content  area i.e left navigation bar, tabs etc */
      .portlet {
         background:#1B619B;
      }
      /* body of the portlet class */
      .pBody{
          background: #ACCBE0;
      }
      /* tabs on the top */
      #p-cactions li a{
        background:#ACCBE0;
      }
      /*selected tab on the top */
      #p-cactions li.selected a {
        background: #F8F2E5;
      }
      /*The logo style */
      #p-logo, #p-logo a, p-logo a:hover{
      
      }
      

      results in something similar to the following:
      mediawikicustomstyle Mediawiki configuration: a quickstart tutorial
      A caveat here: Adding your own styles is not very straight forward. For more complex styles, you may have to befriend a tool like firebug.

Tags: ,

Leave a Reply

Sponsors