How to configure MediaWiki

From WhyNotWiki
Jump to: navigation, search

How to configure MediaWiki  edit   (Category  edit)


MediaWiki  edit   (Category  edit)


MediaWiki to do workflow edit

cropastrco mondel acerre taboel noreleldr Workflow: When an item on MediaWiki to do becomes resolved/finished, move the item to How to configure MediaWiki or MediaWiki bugs and solutions (or another appropriate page) for future reference.

 


Contents

Style customization

Simply edit MediaWiki:Monobook.css

InterWiki

# Custom entries:
mysql> REPLACE INTO interwiki (iw_prefix, iw_url, iw_local) VALUES ('w', 'http://en.wikipedia.org/wiki/$1', 1);
mysql> REPLACE INTO interwiki (iw_prefix, iw_url, iw_local) VALUES ('wikipedia', 'http://en.wikipedia.org/wiki/$1', 1);
mysql> REPLACE INTO interwiki (iw_prefix, iw_url, iw_local) VALUES ('whynotwiki', 'http://whynotwiki.com/$1', 1);
mysql> REPLACE INTO interwiki (iw_prefix, iw_url, iw_local) VALUES ('whynotwiki_edit', 'http://whynotwiki.com/index.php?title=$1&action=edit', 1);
mysql> REPLACE INTO interwiki (iw_prefix, iw_url, iw_local) VALUES ('redirect_to', 'http://whynotwiki.com/redirect_to.php?url=$1', 1);


# Wikipedia's standard list:
mysql> \. wiki/maintenance/wikipedia-interwiki.sql

Custom namespaces

Custom namespaces

$wgExtraNamespaces =
    array(
        100 => "Private",
        101 => "Private_Talk"
    )
;

[SOLVED] Changing which namespaces are searched by default

  1. These settings are in /includes/DefaultSettings.php, but you can copy the array to LocalSettings.php if you wish. In my examples the 100 and 101 correspond with your custom namespaces as defined in LocalSettings.php by the variable $wgExtraNamespaces
  2. The new namespaces can be searched by default, by enabling their variables in $wgNamespacesToBeSearchedDefault
  • Example for MediaWiki 1.4.x and older:
$wgNamespacesToBeSearchedDefault =
       array( -1 => 0, 0 => 1, 1 => 0, 2 => 0, 3 => 0,
               4 => 0, 5 => 0, 6 => 0, 7 => 0,
               8 => 0, 9 => 1, 10 => 0, 11 => 1,
               100 => 1, 101 => 1 );
  • Example for MediaWiki 1.5.x:
$wgNamespacesToBeSearchedDefault = array( 
       -1                => false, 
       NS_MAIN           => true, 
       NS_USER           => false,
       NS_USER_TALK      => false, 
       NS_PROJECT_TALK   => false, 
       NS_IMAGE_TALK     => false, 
       NS_IMAGE_TALK     => false, 
       NS_TEMPLATE_TALK  => false, 
       NS_HELP_TALK      => false, 
       NS_CATEGORY_TALK  => false, 
       100               => true, 
       101               => true 
);

Custom group/permissions

    function userCanRead() {
        global $wgUser;

        $result = null;
        wfRunHooks( 'userCan', array( &$this, &$wgUser, 'read', &$result ) );
        if ( $result !== null ) {
            return $result;
        }

        if( $wgUser->isAllowed('read') ) {
            if( $this->getNamespace() == 100 || $this->getNamespace() == 101 ) {    // 'Private' namespace
                if( $wgUser->isAllowed('can_read_private') ) {
                    return true;
                } else {
                    return false;
                }
            } else {
                return true;
            }

            return true;
        } else {
            global $wgWhitelistRead;
...


Removed other language files so that the output from grep -r on the source wouldn't hose my terminal

ls Language??.php | grep -v LanguageEn | xargs svn rm
ls Messages??.php | grep -v MessagesEn | xargs svn rm
ls Language???.php | xargs svn rm
ls Messages???.php | xargs svn rm
ls *.deps.php | xargs svn rm
ls Messages??*_*.php | xargs svn rm
ls Language??*_*.php | xargs svn rm

Changed navigation/toolbar

Edited MediaWiki:Sidebar

It's auto-closing my div tags! Stop that!

LocalSettings.php:

// This allow us to have unclosed <div> (for example) in our templates. If we don't have this enabled, it will try to auto-close them.
$wgUseTidy = true;

Requires Tidy, but that seemed to be already available for me.

Make the URL pretty

mv wiki w

vim .htaccess

# Close the php security hole...
php_flag register_globals off

# Make http://mysite.com/wiki/PageName links actually use the file /w/index.php
RewriteEngine on
RewriteRule ^wiki/?(.*)$ /w/index.php?title=$1 [L,QSA]

vim w/LocalSettings.php:

...
$wgScriptPath       = "/w";
$wgPrettyScriptPath = "/wiki";
$wgScript           = "$wgPrettyScriptPath/index.php";
$wgRedirectScript   = "$wgPrettyScriptPath/redirect.php";

$wgArticlePath      = "$wgPrettyScriptPath/$1";

$wgStylePath        = "$wgScriptPath/skins";
$wgStyleDirectory   = "$IP/skins";
...
$ diff LocalSettings.php.20060529 LocalSettings.php
41,43c41,44
< $wgScriptPath     = "/wiki";
< $wgScript           = "$wgScriptPath/index.php";
< $wgRedirectScript   = "$wgScriptPath/redirect.php";
---
> $wgScriptPath     = "/w";
> $wgPrettyScriptPath = "/wiki";
> $wgScript           = "$wgPrettyScriptPath/index.php";
> $wgRedirectScript   = "$wgPrettyScriptPath/redirect.php";
48c49
< $wgArticlePath      = "$wgScript/$1";
---
> $wgArticlePath      = "$wgPrettyScriptPath/$1";

Make it stored at wikidir/ instead of w/:

RewriteEngine on
RewriteRule ^wiki$ /wikidir/index.php?title=MainPage
RewriteRule ^wiki/(.*)$ /wikidir/index.php?title=$1 [L,QSA]

Have to disable the talk/discussion namespace

I'm not sure there's a good way to actually disable a namespace, but it's easy to at least hide the talk/discussion links at the top of the page.

Just throw this code in your MediaWiki:Monobook.css:

# Hide the talk/discussion links at the top of the page
#ca-talk {
  display: none;
}

This doesn't seem to work in MW 1.10 - — 66.31.65.129 (2007-08-07 03:57)

Rename the "images" directory to "uploads"

.../wiki/trunk]$ mv images uploads

Why? Because I can contain all sorts of file formats: audio files, video, spreadsheets, ... anything.

Extra javascript/tools that Wikimedia projects use

How to change the copyright notice

Edit your MediaWiki:Copyrightwarning2

How to add "edittools" (list of special characters that you can instert by clicking on)

[tylerrick: ~/tylerrick.com/wiki/trunk]$ cd extensions/
[tylerrick: ~/tylerrick.com/wiki/trunk/extensions]$ mkdir CharInsert
[tylerrick: ~/tylerrick.com/wiki/trunk/extensions]$ cd CharInsert/
[tylerrick: ~/tylerrick.com/wiki/trunk/extensions/CharInsert]$ wget http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/CharInsert/CharInsert.php?view=co

LocalSettings.php

#---------------------------------------------------------
# ParserFunctions
# http://www.mediawiki.org/wiki/Extension:CharInsert

require_once( "$IP/extensions/CharInsert/CharInsert.php" );

How to install math/formula/latex support

$ uname -a
Linux jerky 2.4.32-grsec+f6b+gr217+nfs+a32+fuse23+++opt+c6+gr2b-v6.192 #1 SMP Wed Dec 14 17:06:16 PST 2005 i686 GNU/Linux

[tylerrick: ~/tylerrick.com/wiki/trunk/math]$ make
ocamlopt -c util.ml
ocamlc -c render_info.mli
ocamlc -c tex.mli
ocamlyacc parser.mly
9 shift/reduce conflicts.
ocamlc -c parser.mli
ocamlopt -c parser.ml
ocamlc -c html.mli
ocamlopt -c html.ml
ocamlc -c mathml.mli
ocamlopt -c mathml.ml
ocamlc -c texutil.mli
ocamlopt -c texutil.ml
ocamlopt -c render.ml
ocamllex lexer.mll
272 states, 5040 transitions, table size 21792 bytes
ocamlopt -c lexer.ml
ocamlopt -c texvc.ml
ocamlopt -o texvc unix.cmxa util.cmx parser.cmx html.cmx mathml.cmx texutil.cmx render.cmx lexer.cmx texvc.cmx
ocamlopt -c texvc_test.ml
ocamlopt -o texvc_test util.cmx parser.cmx html.cmx mathml.cmx texutil.cmx lexer.cmx texvc_test.cmx
ocamlopt -c texvc_tex.ml
ocamlopt -o texvc_tex util.cmx parser.cmx html.cmx mathml.cmx texutil.cmx lexer.cmx texvc_tex.cmx
rm parser.ml lexer.ml

[tylerrick: ~/tylerrick.com/wiki/trunk/math]$ file texvc
texvc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs), not stripped

It was seriously that simple. I had no troubles installing it.

Wiki configuration references

Special:Allmessages

Ads
Personal tools