mediawiki-customization
This page documents the customizations we've made to MediaWiki for our community.
Contents
extensions
IndieWeb extensions
https://github.com/indieweb/mediawiki-extensions
- AllowAnchorTags - allows inserting
<a>anchor tags into wikitext - notitle - adds
__NOTITLE__tag to stop MediaWiki from adding its own page title - raw - lets you embed raw HTML into wiki pages using raw
- RelWebmention - add webmention endpoint to wiki pages
- LassoAuth - enables web sign-in via the Lasso auth proxy
- Calendar - adds <calendar> tag for creation of a single month calendar
dfn
https://github.com/aaronpk/mediawiki-mf2-dfn
Adds a p-summary tag around the first sentence of a page that contains a <dfn> tag
CategoryTree
mf2 parser
The wiki requires a Microformats parser to be able to do a few things. Copy the php-mf2 repository to the extensions folder.
enable extensions
wfLoadExtension('Cite');
wfLoadExtension('ParserFunctions');
wfLoadExtension('Auth_remoteuser');
wfLoadExtension('CategoryTree');
require_once('extensions/php-mf2/Mf2/Parser.php');
require_once('extensions/dfn/dfn.php');
require_once('extensions/IndieWeb/raw.php');
require_once('extensions/IndieWeb/notitle.php');
require_once('extensions/IndieWeb/AllowAnchorTags.php');
require_once('extensions/IndieWeb/RelWebmention.php');
require_once('extensions/IndieWeb/Calendar.php');
require_once('extensions/IndieWeb/LassoAuth.php');
extension config
LassoAuth::$auth = 'https://sso.indieweb.org/'; LassoAuth::$wiki = 'https://indieweb.org/'; $wgPingbackEndpoint = 'https://webmention.io/indiewebcamp/xmlrpc'; $wgWebmentionEndpoint = 'https://webmention.io/indiewebcamp/webmention';
editable customizations
See MediaWiki:Common.css for custom CSS used on this wiki.
configuration
Add these to LocalSettings.php
enable nice urls
The wiki is installed in the wiki folder on the server, but we want the URLs to be indieweb.org/example.
$wgScriptPath = '/wiki'; $wgScriptExtension = ".php"; $wgArticlePath = '/$1'; $wgUsePathInfo = true; $wgCapitalLinks = false;
user permissions
$wgGroupPermissions['*']['read'] = true; $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createaccount'] = false; $wgGroupPermissions['*']['autocreateaccount'] = true; $wgGroupPermissions['user']['move'] = true; $wgGroupPermissions['user']['movefile'] = true; $wgGroupPermissions['user']['delete'] = true; $wgGroupPermissions['user']['undelete'] = true; $wgGroupPermissions['user']['browsearchive'] = true; $wgGroupPermissions['user']['rollback'] = true; $wgDefaultUserOptions ['editsection'] = true; $wgAllowUserSkin = true; $wgAllowUserCss = true; $wgAllowUserJs = true;
copyright
$wgEnableCreativeCommonsRdf = true; $wgRightsPage = "IndieWebCamp:Copyrights"; # Set to the title of a wiki page that describes your license/copyright $wgRightsUrl = "http://creativecommons.org/publicdomain/zero/1.0/"; $wgRightsText = "a CC0 public domain dedication"; $wgRightsIcon = "https://i.creativecommons.org/p/zero/1.0/88x31.png"; $wgEnableCreativeCommonsRdf = true;
allow more file uploads
$wgFileExtensions[] = 'pdf'; $wgFileExtensions[] = 'txt'; $wgFileExtensions[] = 'svg'; $wgFileExtensions[] = 'ai';
others
$wgEnableUploads = true; $wgAllowImageTag = true; $wgNoFollowLinks = false; $wgAllowExternalImages = true; $wgCookieExpiration = 180 * 86400; $wgSecureLogin = true; $wgCookieSecure = true;
set up https://www.mediawiki.org/wiki/Manual:$wgRCFeeds to the secret lair of Loqi
skin
We use the default Vector skin for the wiki, with some minor customization to add Microformats markup to pages.
In skins/Vector/VectorTemplate.php, make the changes described on https://aaronparecki.com/2018/01/14/3/
front page
MediaWiki refuses to serve the front page from / and insists on redirecting it to /Main_Page instead. It's possible to rename that page to something like /Home, but even that isn't great. We want the front page to be served at just https://indieweb.org/. To do that, there is a separate index.php file at the root of the server, which essentially proxies the MediaWiki page.
<?php
$opts = array('title' => 'Main_Page');
if(array_key_exists('useskin',$_GET))
$opts['useskin'] = $_GET['useskin'];
$ch = curl_init('https://indieweb.org/wiki/index.php?'.http_build_query($opts));
// Pass the HTTP_COOKIE header through for auth
if(array_key_exists('HTTP_COOKIE', $_SERVER)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Cookie: ' . $_SERVER['HTTP_COOKIE']
));
}
header('Link: <https://webmention.io/indiewebcamp/webmention>; rel="webmention"');
// No-cache if the user is logged in
if(isset($_SERVER['REMOTE_USER'])) {
header('Cache-Control: no-cache');
}
curl_exec($ch);
See Also
- wiki/
- microformats wiki:
- microformats wiki mediawiki customization - you might find some useful customizations here too.











