Contents

Introduction

This Wiki runs on customised MediaWiki software with extensions.

This page documents all of the customisations and extensions to the base MediaWiki software that are used across the site. A source of related information is Special:Version.

Using this page as a reference it should be possible to rebuild the site from scratch (assuming access to database backups).

Submitting extensions and customisations

If you wish to work on improvements to the Wiki software, then please submit them through this page's discussion page.

To have a complete copy of the site for testing you need a backup of the database. Database backups can be provided to responsible people on request to the server administrator.

Configuration notes

Most noteworthy

  • Editing permissions: pages are not editable by anonymous users - account creation and log in is required. Both sites allow sysops to restrict editing for an individual page to sysops-only - this is through a standard MediaWiki function: the 'protect' action appearing on the actions tab to those with a sysop account. Both sites also make use of a patch that allows those in the sysop group to use this same tab to unblock anonymous edits on a per-page basis.
  • File upload permissions: as for pages, files (images) may only be uploaded by logged-in users.
  • Syntax highlighting: source code in several languages, most importantly C, can be highlighted with automatic insertion of reference links to keyword/function descriptions: for C code these links point to clc-wiki articles, many of which are as-yet uncreated.
  • Treeview skin: this is installed as the default skin; it is a custom extension.
  • Caching: memcached is used to cache messages, parsed page content and other data such as logged-in user details. File caching is used to cache full page html for anonymous views.
  • Automated election and demotion of editors to/from different groups by vote (as well as miscellaneous decisions): supported by a custom Voting extension but not in active use.

Other

  • Improved administration: a "rename user" extension available to those in the 'bureaucrat' group; an extension showing a tabular view of permissions available to all.
  • Control over section numbering: a custom patch allows the __NOTOCNUM__ token to suppress automated section number generation within tables of contents.

Configuration and extension items

Primary software (MediaWiki)

The MediaWiki software has been installed manually and is periodically manually upgraded.

Versions and configuration

Version MediaWiki 1.6.7
LocalSettings.php entries [listed below are only those settings that were consciously made, that are actively used or relied on and that are unrelated to patches / extensions]
$IP = "/home/comp.lang.c/clc-wiki.net/user/htdocs/mediawiki";

$wgSitename         = "clc-wiki";
$wgArticlePath      = "/wiki/$1";

$wgLogo             = "$wgStylePath/treeview/clc-wiki.png";

$wgEnableEmail = true;
$wgEnableUserEmail = true;

$wgEmergencyContact = "admin@clc-wiki.net";
$wgPasswordSender	= "clc.webadmin@flash-gordon.me.uk";

$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;

$wgDBserver         = "localhost";
$wgDBprefix         = "clc_";

$wgUseMemCached   = true;
$wgMainCacheType = CACHE_MEMCACHED;
$wgMemCachedServers = array (
  0 => 'localhost:11211',
);
$wgEnableParserCache = true;

$wgUseFileCache = true;
$wgFileCacheDirectory = "$IP/file_cache";
# required to be false when $wgUseFileCache is true
$wgShowIPinHeader = false;

$wgEnableUploads		= true;

$wgLanguageCode = "en";

$wgGroupPermissions['sysop']['edit']            = true;
$wgGroupPermissions['sysop']['read']            = true;
$wgGroupPermissions['user' ]['upload']          = true;
$wgGroupPermissions['user' ]['edit']            = true;
$wgGroupPermissions['user' ]['move']            = false;
$wgGroupPermissions['*'    ]['createaccount']   = true;
$wgGroupPermissions['*'    ]['read']            = true;
$wgGroupPermissions['*'    ]['edit']            = false;

$wgExtraNamespaces = array(	100 => "Planning",
				101 => "Planning_Talk"
			  );

# Don't auto-capitalise the first letter of pages
$wgCapitalLinks = false;

Syntax highlighting: GeSHi and an extension to wrap it

GeSHi is the syntax highlighting engine used on this wiki. We reciprocate its use by maintaining the C language files for the 1.1.x series of GeSHi. The extension that wraps GeSHi for MediaWiki's use is GeSHiWrapper.php: a custom extension based on existing code.

GeSHi 1.1.x is installed at mediawiki/extensions/geshi-1.1.<x>. A symbolic link in that same directory points from geshi to geshi-1.1.<x>. It's been patched to adjust the background colour to a lighter shade of yellow: this is a one line change to line 92 of geshi-1.1.2-alpha1/geshi/classes/renderers/class.geshirendererhtml.php to set background-color to #fefef9 instead of #ffc. In addition, because some of the filetypes that we highlight on clc-wiki are not yet supported by 1.1.x, GeSHi 1.0.7.x is installed in parallel at mediawiki/extensions/geshi-1.0.7.<x>. GeSHiWrapper is installed at mediawiki/extensions/GeSHiWrapper.php.

For the test site, GeSHi 1.1.x is checked out from its cvs repository (module geshi-src) to /var/geshi-src. A symbolic link points from mediawiki/extensions/geshi to /var/geshi-src. As for the live site, 1.0.7.x is installed in parallel at mediawiki/extensions/geshi-1.0.7.<x>; it has been slightly patched as described in the GeSHiWrapper README. GeSHiWrapper is installed at mediawiki/extensions/GeSHiWrapper/GeSHiWrapper.php with its README also in that directory.

Patches to GeSHi 1.0.7.x for C and C grammar support: the C syntax highlighting file that ships with GeSHi 1.0.7.x has been updated (but is no longer in use because GeSHi 1.1.x performs that highlighting) and a C grammar highlighting module for GeSHi 1.0.7.x has been created. Both of these modifications are described in the GeSHi 1.0.7.x mods article.

Versions and configuration

Version Versions 1.1.2-alpha1 with one-line colour patch described above and (with C and C grammar patches as described above) version 1.0.7.11 of GeSHi; CVS revision 1.14 of GeSHiWrapper.php and 1.1 of its (new) README.
LocalSettings.php entries
include("extensions/GeSHiWrapper/GeSHiWrapper.php");
$wgGeSHiFallbackDir = 'geshi-1.0.7.11';
$wgGeSHiFallbackClassName = 'GeSHi__1_0_7_X';
$wgGeSHiFileBlacklistREs = array();   # block none
$wgGeSHiFileAllowedDirs  = array(
	'/home/comp.lang.c/clc-wiki.net/user/htdocs'
);

Notes

geshi-1.0.<x>/geshi/c_grammar.php is a custom file that should be copied across during upgrades. Don't forget to re-patch 1.0.7.x when upgrading, as described in the GeSHiWrapper README.

Permissions extension

The Permissions special page extension displays in tabular form the current set of permissions available to all defined user groups on the wiki.

Versions and configuration

Version As at 2005-11-21 plus a one-liner patch that solves a problem with the extension under MediaWiki 1.6.6.
LocalSettings.php entries
include('extensions/SpecialPermissions.php');

Notes

There have been patches applied to the code on the wiki page since 2005-11-21 that we could look at.

Rename user extension

SpecialRenameuser.php is a special page stored in the MediaWiki-extensions code repository. It is accessible on this wiki to those in the bureaucrat user group, to allow for - as its title indicates - renaming of users.

Versions and configuration

Version Subversion revision 14296.
LocalSettings.php entries
include('extensions/Renameuser/SpecialRenameuser.php');
$wgGroupPermissions['bureaucrat']['renameuser'] = true;

Patch for control over section numbering

This custom patch adds support for a __NOTOCNUM__ token that can be used to suppress automatic section numbering. This version of the patch applies to 1.5.x and up to at least the 1.6.6 release. For MediaWiki 1.9.2, the patch is as follows:

--- Parser.php.orig	2007-02-05 10:14:58.000000000 +1100
+++ Parser.php	2007-02-10 21:24:08.000000000 +1100
@@ -3394,6 +3394,11 @@
 	function formatHeadings( $text, $isMain=true ) {
 		global $wgMaxTocLevel, $wgContLang;
 
+		# do not number TOC entries or corresponding headings if the string
+		# __NOTOCNUM__  (not case-sensitive) occurs in the HTML
+		$mw =& MagicWord::get( 'notocnum' );
+		$noTocNum = $mw->matchAndRemove( $text );
+
 		$doNumberHeadings = $this->mOptions->getNumberHeadings();
 		if( !$this->mTitle->userCanEdit() ) {
 			$showEditLink = 0;
@@ -3518,16 +3523,18 @@
 
 				$levelCount[$toclevel] = $level;
 
-				# count number of headlines for each level
-				@$sublevelCount[$toclevel]++;
-				$dot = 0;
-				for( $i = 1; $i <= $toclevel; $i++ ) {
-					if( !empty( $sublevelCount[$i] ) ) {
-						if( $dot ) {
-							$numbering .= '.';
+				if (! $noTocNum ) {
+					# count number of headlines for each level
+					@$sublevelCount[$toclevel]++;
+					$dot = 0;
+					for( $i = 1; $i <= $toclevel; $i++ ) {
+						if( !empty( $sublevelCount[$i] ) ) {
+							if( $dot ) {
+								$numbering .= '.';
+							}
+							$numbering .= $wgContLang->formatNum( $sublevelCount[$i] );
+							$dot = 1;
 						}
-						$numbering .= $wgContLang->formatNum( $sublevelCount[$i] );
-						$dot = 1;
 					}
 				}
 			}

It also requires the addition of this file named Notocnum.php in the extensions directory:

<?php

$wgHooks['LanguageGetMagic'][] = 'wfNotocnum_LanguageGetMagic';

function wfNotocnum_LanguageGetMagic(&$magicWords, $code) {
	$magicWords['notocnum'] = array(1, '__NOTOCNUM__');
}
?>

Finally, the extension has to be included in LocalSettings.php as below.

Versions and configuration

Version Patch as listed above.
LocalSettings.php entries
require_once('extensions/Notocnum.php');

Spam protection: bad behaviour extension

Bad behavior "is a set of PHP scripts which prevents spambots from accessing your site by analyzing their actual HTTP requests and comparing them to profiles from known spambots."

Versions and configuration

Version 1.2.4 with patch described below
LocalSettings.php entries
include('extensions/bad-behavior/bad-behavior-mediawiki.php');

Patch to prevent password logging

In bad-behavior-core.php the following

// Reconstruct the HTTP entity, if present.
$wp_bb_request_entity = "";
if (!strcasecmp($wp_bb_request_method, "POST")) {
        foreach ($_POST as $wp_bb_header => $wp_bb_value) {
                $wp_bb_request_entity .= "$wp_bb_header: $wp_bb_value\n";
        }
}

has been replaced with

// Reconstruct the HTTP entity, if present.
$wp_bb_request_entity = "";
if (!strcasecmp($wp_bb_request_method, "POST")) {
        foreach ($_POST as $wp_bb_header => $wp_bb_value) {
                if (strcasecmp($wp_bb_header, "wpPassword")) {
                        $wp_bb_request_entity .= "$wp_bb_header: $wp_bb_value\n";
                }
        }
}

Spam protection: Spam Blacklist extension

Spam Blacklist "is a simple edit filter extension. When someone tries to save the page, it checks the text against a potentially very large list of "bad" hostnames. If there is a match, it displays an error message to the user and refuses to save the page."

The list of blocked URLs is at Spam_blacklist and edits to this page should remain restricted to sysops. This should only be used for real spam, not to block people from adding links from their home pages or links to C related sites else where.

Versions and configuration

Version ?
LocalSettings.php entries
require_once( "$IP/extensions/SpamBlacklist/SpamBlacklist.php" );
$wgSpamBlacklistFiles = array( 'DB: wikidb Spam_blacklist', );

Spam account filtering patch

This custom patch hides accounts marked as spambots or testing from the main user listing at Special:Listusers (they can still be listed by choosing either group from the dropdown).

This allows us to hide the (growing) collection of spambots by adding them to the 'spambot' group (through Special:Userrights, accessible to users in the 'bureaucrat' group) without having to delete them: account deletion is discouraged by MediaWiki developers, who suggest that it is fraught.

Versions and configuration

Version patch against 1.9.2
LocalSettings.php entries
$wgHiddenGroups = array('spambot', 'testing');
$wgGroupPermissions['spambot']['read']          = false;
$wgGroupPermissions['spambot']['edit']          = false;
$wgGroupPermissions['spambot']['talk']          = false;
$wgGroupPermissions['spambot']['move']          = false;
$wgGroupPermissions['spambot']['upload']        = false;
$wgGroupPermissions['testing']                  = array();

Spam protection: undescribed anti-spam extension

This very simple custom extension provides some ad-hoc anti-spammer protection; it's not described further here, so that we have some mild security-through-obscurity.

Versions and configuration

Version CVS revision 1.4
LocalSettings.php entries
include('extensions/AntiSpam/AntiSpam.php');

Voting extension

The voting extension was written for this wiki and it is described in the Voting extension child article. It's not in active use (yet - mainly because it needs finer integration).

Versions and configuration

Version 0.1 alpha.
LocalSettings.php entries
include("extensions/Voting/SpecialVote.php");
# Duration in days of the voting period on decisions
$wgVotingPeriod = 30;
$wgPendingPeriod = 10;
# Inactivity period in days before an editor is consider inactive for
# vote tallying purposes
$wgInactivityPeriod = 90;
define('NS_DECISION'          ,  300);
$wgExtraNamespaces[NS_DECISION    ] = 'Decision';
$wgExtraNamespaces[NS_DECISION + 1] = 'Decision_talk';
$wgGroupPermissions['user' ]['vote']		= true;
$wgGroupPermissions['user' ]['propose']		= true;

Treeview skin

The Treeview skin was written for this wiki; its development motivations are described at Planning:Treeview skin. The cvs repository referred to is not public.

Versions and configuration

Version 1.1.beta
LocalSettings.php entries
include('extensions/Hierarchy/SpecialHierarchy.php');
$wgGroupPermissions['sysop']['rebuildtreeview'    ] = true;
$wgGroupPermissions['sysop']['parsetreeview'      ] = true;
$wgGroupPermissions['sysop']['treeviewcachestatus'] = true;
$wgDefaultSkin   = 'treeview';
# relies on a custom patch to EditPage.php and Title.php
$wgRelyOnUserCanEdit = true;
$wgShowPoweredByIcon = false;
$wgShowCopyrightIcon = false;
$wgCacheEpochTouchFile = '/home/comp.lang.c/clc-wiki.net/user/htdocs/mediawiki/cache_epoch';

Patch to enable anonymous edits on a per-page basis

In our setup where by default edits are restricted to logged-in users, this patch (Project:Config:Wiki:Per-page_anon_edits_patch) adds the ability for a sysop to mark an individual page as editable by anonymous users through the 'protect' tab by selecting 'Allow all including anons/not-logged-in'.

Recognition of this patch is the purpose of the Treeview skin's $wgRelyOnUserCanEdit setting.

Versions and configuration

Version The patches against 1.9.2 in the child article as linked to above.
LocalSettings.php entries
# This needs to be augmented by editing MediaWiki:Protect-level-* to
# 'Allow all including anons/not-logged-in'
array_splice($wgRestrictionLevels, 1, 0, '*');

Additional configuration files

Two call-out configuration files based in /home/comp.lang.c/clc-wiki.net/user/private/clcwikiconf/ are included from LocalSettings.php to allow mirror sites to easily override settings to match their configuration, and to keep passwords and usernames private when LocalSettings.php is displayed.

Versions and configuration

Version n/a
LocalSettings.php entries
# [...] (placement is significant so refer to the full LocalSettings.php file)

# Include private stuff such as passwords ; override $IP for a local mirror as
# necessary
 
include('/home/comp.lang.c/clc-wiki.net/user/private/clcwikiconf/PrivateSetting.php');

# [...] (placement is significant so refer to the full LocalSettings.php file)

# Override $wgScriptPath, $wgScript and/or $wgArticlePath for a local  mirror as
# necessary; can't be combined with '/home/clc/PrivateSetting.php' because
# DefaultSettings.php both reads the $IP variable and resets these  variables
include_once('/home/comp.lang.c/clc-wiki.net/user/private/clcwikiconf/LocalOverrides.php');

A template for PrivateSetting.php

This file should be customised and placed in /home/clc/PrivateSetting.php or /home/clc/TestPrivateSetting.php depending on whether you're restoring a live site or test site backup:

<?php

$wgDBname           = "wikidb";
$wgDBuser           = "<username>";
$wgDBpassword       = "<pw>";
$IP = "/path/to/my/www/root/for/clc/mediawiki/install";

?>

A template for LocalOverrides.php

This file should be created as /home/clc/LocalOverrides.php and customised; it can be empty if your settings match those of the live install:

<?php

# If other mediawiki installations are present, /mediawiki may already
# be used.
$wgScriptPath       = "/<webserver_root_for_mediawiki>";
# Reset this variable since it depends on $wgScriptPath
$wgScript           = "$wgScriptPath/index.php";
# Don't use '/wiki' as Flash's server is set up with an apache rewrite rule to do;
# instead use MediaWiki's default path
$wgArticlePath      = "$wgScript/$1";

?>

Logo and icon

The original site logo is visible when using a skin other than Treeview. It was put together as an interim solution but stayed for a while; it's not versioned and hasn't changed.

The site icon [is undocumented].

Personal tools