Middlebury

MediaWiki Admin

Revision as of 12:41, 2 June 2011 by Adam Franco (talk | contribs)

Creating New Wikis

  1. SSH to the mediawiki server
  2. cd to the mediawiki directory
  3. Run the createWiki command to create a new wiki.
  4. Optional: Edit the wiki's LocalSettings file to add additional extensions or limit access.

The createWiki command

Running the createWiki command with no argument (or -h for help) will display the following usage message:

$ createWiki -h

Usage: createWiki -n <short name> -t <title> -a <admin id>

Example: createWiki -n TestWiki -t "A Wiki For Testing" -a 1003


Note: The admin user is the only one who will be able to go in and make
other users admins. This should likely be your id (internal to mediawiki).

The admin id is the 'user_id' field in the cas_users table in the mediawiki database.

Some ids you might wish to use:
1003    Adam Franco
1000    Joe Antonioli
1045    Ian McBride
1048    Jason Mittell

The createWiki command will create the new wiki directory in webroot/wikis/, create a default config, add an images directory, and install all the needed database tables.

By default the following extensions are enabled:

  • Cite
  • EmbedVideo
  • FCKeditor

Adding Extra Extensions

Most extensions should be included from the shared extension directory rather than from a per-wiki extension directory. Use the shared-directory constant for the path, e.g.:

require_once( MIDD_MEDIAWIKI_SHARED_DIR."/extensions/FCKeditor/FCKeditor.php" );

Restricting Access

Wikis can be restricted by setting the default read and edit permissions to false and then adding a list of groups and/or a list of authorized users who can view or edit to the LocalSettings.php for a wiki.

Example:

# Disable reading by anonymous users
$wgGroupPermissions['*']['read'] = false;

# But allow them to read e.g., these pages:
$wgWhitelistRead =  array ( "Main Page", "Special:Userlogin", "Wikipedia:Help");


###########################
# CAS Authentication
###########################
// Full Group Id
$wgCASAuthorizedGroups = array(
"CN=LIS Librarians,OU=General,OU=Groups,DC=middlebury,DC=edu",
"CN=LIS Liasons,OU=General,OU=Groups,DC=middlebury,DC=edu",
);

// Users' web-id
$wgCASAuthorizedUsers = array(
'A0F836FCD9DFDD8F7A27D02C62CDB225',
);

Testing/Developing for MediaWiki

Initial Setup

Cloning the central repository

Your ssh keys must be authorized to access the central repository. All chisel accounts' ssh keys have been authorized to do so at the time of this writing. Contact Adam to add ssh keys for other machines (such as your desktop) if desired.

  1. cd to your home directory on chisel:
    cd ~
  2. clone the repository and create a working directory with git-clone:
    git clone git@chisel.middlebury.edu:mediawiki.git
    You should now have a working directory at ~/mediawiki/
  3. cd to your public_html directory on chisel:
    cd ~/public_html/
  4. Make a symbolic link to the mediawiki webroot:
    ln -s ../mediawiki/webroot mediawiki

Configuration

Create a branch called something like "DevConfig" to hold your config changes. Do not put your dev config changes on your master branch and then push them to the central repository.

git checkout -b DevConfig master

Make the following changes:

diff --git a/webroot/mediawiki/LocalSettings.php b/webroot/mediawiki/LocalSettings.php
index 13a7850..20a9b0e 100755
--- a/webroot/mediawiki/LocalSettings.php
+++ b/webroot/mediawiki/LocalSettings.php
@@ -61,15 +61,15 @@ $wgEmailAuthentication = false;

$wgDBtype           = "mysql";
$wgDBserver         = "localhost";
-$wgDBname           = "prod_db";
-$wgDBuser           = "prod_user";
-$wgDBpassword       = "prod_password";
+$wgDBname           = "username_mediawiki";
+$wgDBuser           = "testuser";
+$wgDBpassword       = "testpassword";
$wgDBport           = "5432";
$wgDBprefix         = "";

-$wgScriptPath = "/mediawiki";
+$wgScriptPath = "/~username/mediawiki/mediawiki";
$wgScript = $wgScriptPath."/index.php";
-$wgArticlePath = "/wiki/$1";
+$wgArticlePath = "/~username/mediawiki/wiki/$1";

# MySQL table options to use during installation or update
$wgDBTableOptions   = "TYPE=InnoDB";
@@ -181,9 +181,9 @@ if ($pathInfo) {
$wgDBprefix = $wikiName.'_';
$wgSitename = $wikiName;
$wgScript = $wgScriptPath."/index.php/$wikiName/";
-               $wgArticlePath = "/wiki/$wikiName/$1";
+               $wgArticlePath = "/~username/mediawiki/mediawiki/index.php/$wikiName/$1";
$wgUploadDirectory = "$wikiFolder/images";
-               $wgUploadPath = "/wikis/$wikiName/images";
+               $wgUploadPath = "/~username/mediawiki/mediawiki/index.php/$wikiName/images";

if (file_exists($wikiFolder."/LocalSettings.php")) {
require_once($wikiFolder."/LocalSettings.php");

Then commit them to your DevConfig branch:

git commit -a -m "Added development config."

Development workflow

  1. Get any new changes from the central repository:
    git checkout master ; git pull origin master
  2. Check out your DevConfig branch:
    git checkout DevConfig
  3. Replay your DevConfig on top of the master branch:
    git rebase master
  4. Make changes, test that they work.
  5. Stash your changes:
    git stash
  6. Check out your master branch:
    git checkout master
  7. Apply the changes:
    git stash pop
  8. Commit the changes:
    git commit -a -m "Did something...."

Upgrading MediaWiki core

  1. cd to the webroot:
    cd mediawiki/webroot/
  2. Checkout the core branch:
    git checkout core
  3. Download the new version of mediawiki:
    wget http://download.wikimedia.org/mediawiki/1.16/mediawiki-1.16.5.tar.gz
  4. Decompress the new version then delete the download
    tar xzf mediawiki-1.16.5.tar.gz ; rm mediawiki-1.16.5.tar.gz
  5. Delete the old version and move the new version into place
    rm -Rf mediawiki/ ; mv mediawiki-1.16.5 mediawiki
  6. Stage the changes
    git add mediawiki ; git add -u mediawiki
  7. Commit the changes
    git commit -m "Upgraded to mediawiki-1.16.5 from download"
  8. Merge the new version into our configuration
    git checkout master ; git merge core