User:Stefahn/Docu

On this page I collect useful stuff for running great MediaWiki websites :)
(This page is ever-growing)

MediaWiki Docu

edit

Stying up-to-date / Newsletters:

Installing

edit

Useful: MediaWiki core code on Github: https://github.com/wikimedia/mediawiki/

Core

edit

This is how I install MediaWiki Core (as of 2021):

  1. Create a database at your host and copy the database name, database user, password and host.
  2. Connect to Server via SSH
  3. Go to the root folder of the domain (not in the /mediawiki folder).
    1. If I use GIT (preferred):
      1. git clone https://gerrit.wikimedia.org/r/mediawiki/core.git --branch REL1_39 mediawiki (if you add --depth=1 at the end, this would reduce the number of revisions that are cloned but this makes it impossible to checkout newer branches later on)
      2. To load all bundled extensions and skins (not possible in master branch): In the /mediawiki folder: git submodule update --init --recursive (this takes about 7 minutes) This somehow makes all extensions be "HEAD detached at..." (how can I set all extensions to the 1.39 branch?)
      3. In the /mediawiki folder: Run composer update --no-dev to load external dependencies.
    2. If I can't use GIT: Get the latest download link at Download. wget Link, unzip File and mv Folder mediawiki
  4. Go to the mediawiki directory in the browser and follow the steps (use the database credentials from step 1).
  5. Download LocalSettings.php.
  6. Edit LocalSettings.php: Below the line with $wgMetaNamespace = add this line (for security reasons):
    $wgCookiePrefix = $wgMetaNamespace;
  7. Upload LocalSettings.php.

Extensions

edit

How to install Extensions with GIT:

  1. Connect to Server via SSH
  2. Go to the folder mediawiki/extensions/
  3. git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/NAME --branch master
    You can try to go with the master version first. If a certain branch is needed, replace master with REL1_3x.
    Replace NAME with the extension's name, starting with a capital letter.

If you install the VisualEditor extension, make sure to run git submodule update --init in extensions/VisualEditor afterwards. Otherwise files under extensions/VisualEditor/lib/ve/src might be missing.

If for some reason an extension is not hosted on Gerrit, but on Github, use git clone https://github.com/miraheze/RottenLinks.git --branch master

Upgrading / Updating

edit

Web updater:

  • Useful if you don't have SSH access. Instead of the update script you can use the web updater.
  • Accessible at domain.com/mediawiki/mw-config
  • Manual:Upgrading#Web_updater
  • This is not recommended since the web update can timeout (see [3])

Essential changes (to me) in the change log:

With Git

edit
  • Updating with Git, see Download from Git
  • Everything in this chapter has a prerequisite, that the wiki and its extensions were installed with Git, see #Installing.
  • To see which branch the core or a extension is on and which other branches exist: git branch

Core, minor upgrade

edit

(for example from 1.36.3 to 1.36.4):

  1. Go the the mediawiki folder.
  2. git pull
    This downloads updates for the bundled extensions too, but it does not switch the extensions to their latest versions.
  3. Update your extensions. See below.
  4. If you get a message like "Please commit or stash your changes first" and you didn't change anything, use git stash to ignore the message and use git pull again.

Core, major upgrade

edit
  1. Go to the mediawiki folder.
  2. git checkout REL1_3x
  3. git pull (maybe git pull --recurse-submodules is nescessary, maybe even git submodule update --init --recursive)
  4. Update your skin too. If you use Vector, go to skins/Vector and do git checkout REL1_3x too.
  5. Update your extensions. See below.
  6. Run composer update --no-dev
  7. Run php_cli maintenance/update.php

Extensions and skins

edit
  1. (Go to mediawiki/extensions and do git pull)(I think this pulls the new versions but doesn't switch the extensions to the new versions)
  2. You must go into each extension and skin directory and update it with a command like git pull --recurse-submodules[2]

If an extension is not in the right branch read on.

How to change branch of extensions:

The following only works if you have not used --depth=1 in the inital checkout:

  1. Navigate to the extension folder that you want to change
  2. Use git checkout REL1_39 to change to the 1.39 branch for example

How to checkout a certain ID within an extension:

This might be helpful if the latest version does not work for some reason.

  1. Find the version / ID that works. It might be helpful to use git log
  2. Use git checkout ID

See more here.

Without Git

edit

This is how to upgrade without Git:

Core, major upgrades

edit

This is how I do major upgrades on my wikis:

  1. Backup all MediaWiki databases and all FTP files that I adapted (for example these files).
  2. Access the command line by connecting to my server via Putty/SSH.
  3. Navigate to my website folder (not the mediawiki folder but the one that contains the mediawiki folder).
  4. Download the new package via wget https://releases.wikimedia.org/mediawiki/1.3x/mediawiki-1.3x.y.tar.gz (URLs of the download packages can be retrieved from Download).
  5. Extract the file via tar -xvzf mediawiki-1.3x.y.tar.gz (this will create a new folder named mediawiki-1.3x.y)
  6. Copy all "old", adapted FTP files into the new mediawiki folder.
    This includes, but is not limited to:
    1. extensions that are not bundled with the tarball
    2. the images folder (for example with cp -r sitename/mediawiki/images/ sitename/mediawiki-1.3x.y/
    3. LocalSettings.php
    4. composer.local.json
    5. custom skins (or changes you made to default skins)
  7. In the release notes for the new version, see if any changes need to be made to LocalSettings.php.
  8. Rename the old mediawiki folder to mediawiki-old.
  9. Rename the new mediawiki-1.3x.y folder to mediawiki.
  10. Update any extensions if there are updates.
  11. Run the update script with php_cli maintenance/update.php --skip-external-dependencies.
  12. Check my wiki if all works like it should, for example
    1. Viewing pages
    2. Editing pages
    3. Uploading a file
    4. Visit Special:Version and check that the version shown is correctly and that my extensions are present.

Core, minor upgrades

edit

This is how I do minor version upgrades:

  1. Backup all MediaWiki databases and all FTP files that I adapted (for example these files).
  2. Access the command line by connecting to my server via Putty/SSH.
  3. Navigate to my html folder.
  4. Download the new patch file via wget https://releases.wikimedia.org/mediawiki/1.xx/mediawiki-1.xx.x.patch.gz
  5. Extract the file via gunzip mediawiki-1.xx.x.patch.gz
  6. Navigate to the mediawiki folder of the wiki.
  7. Run patch -p1 --dry-run -i ../../mediawiki-1.xx.x.patch to check what will be patched.
  8. If all is fine, run patch -p1 -i ../../mediawiki-1.xx.x.patch
  9. Visit Special:Version and check that the version shown is correctly and that my extensions are present.
  10. Repeat the last 4 steps for every wiki.

Extensions

edit

This is how I upgrade my extensions:

  1. Visit the extension page and get the download link of the new version (I always try to run the master version, even if I'm on the LTS version).
  2. Access the command line by connecting to my server via Putty/SSH.
  3. Navigate to my extension folder.
  4. Run wget COPIED-URL
  5. Rename the existing extension folder to EXTENSION-NAME-old
  6. Run tar -xzf GZ-FILE (this extracts the files into the folder EXTENSION-NAME.
  7. Visit Special:Version and check that the version number is updated.
  8. Check functionality that the extension provides.

Running a MediaWiki site

edit

MediaWiki Support

edit

Here you can get free support for MediaWiki:

Finding MediaWiki Consultants:

Short URLs

edit
  • very important!
  • Docu: Short URL
  • What I use in my .htaccess files:
RewriteRule ^wiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ /mediawiki/index.php [L,QSA]
RewriteRule ^/*$ /mediawiki/index.php [L,QSA]
Last line redirects domain.com to domain.com/wiki/Mainpage
  • Not tested yet, but looks helpful to setup short URLs for MediaWiki: http://shorturls.redwerks.org/
  • Related to URL: If you set your wiki to private and you're not logged in, the homepage won't be redirected to domain.com/wiki/Mainpage but stay at domain.com. This is useful for testing the pagespeed at https://www.pagespeed.de/

URLs with / without capitals

edit

Default behavior:

  • URLs are case sensitive
  • However, the first character of the page name is case-insensitive - Example: https://secret-wiki.de/wiki/vitori_Kristallmatte redirects to https://secret-wiki.de/wiki/Vitori_Kristallmatte (this is also the case on Wikimedia projects)
  • https://secret-wiki.de/wiki/Vitori_kristallmatte gives an error - this might be a problem if a user enters the URL this way (without capitals)

One can change behavior of links and allowed URLs with $wgCapitalLinks. Setting $wgCapitalLinks to false...

  • ...doesn't change anything about the existing pages with capitals!
  • ....enables links like small (which would link to a page "small" not "Small")
  • ...enable pages/URLs that start with a small letter

I still don't know if URLs with capitals are a bad thing in terms of SEO. If someone knows more about it please mail me at info AT interspirit.de

Sitemap

edit

Possibilities to generate a sitemap:

Ways to set a page to noindex

edit

Debugging & Hacking

edit

If you get an empty page, chances are there is a fatal PHP error: Add this to the second line from the top (right below the <?php) of LocalSettings.php to turn on error messages:

error_reporting( -1 );
ini_set( 'display_errors', 1 );

This corresponds to

error_reporting = E_ALL
display_errors = On

in your php.ini.

For more info see Manual:How to debug. Another proposed way: [4]

My debugging "setup":

  • in my php.ini I had (and have) :
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
  • If my website is live I don't have any "debugging lines". If I want to debug something I temporarily add this code to my LocalSettings.php:
error_reporting( -1 );
ini_set( 'display_errors', 1 );
$wgShowExceptionDetails = true; 
$wgDebugLogFile = "/tmp/debug-{$wgDBname}.log";

Become a MediaWiki hacker:

Hosting

edit
  • Never go for windows hosting for Meadiawiki.[4]

Memory limit:

  • "The minimum amount of memory that MediaWiki "needs" is 50 megabyte."[5]
  • "The minimal limit should be something like 20 MB, but if you want MediaWiki to work correctly, consider using at least 50 MB."[6]

PHP Version:

Speeding up MediaWiki:

  • Manual:Performance tuning
  • $wgDBserver: Use IP addresses where possible to avoid the overhead of a DNS lookup for every single connection to the wiki.

Permissions:

  • If you have root or sudo access:
    • chown everything to the apache user/group (recursively). In Ubuntu: chown -R www-data:www-data your-mediawiki-directory
    • chmod LocalSettings.php to 600. Leaving everything else as default should be fine (644 for files and 755 for directories).
  • If you do not have root or sudo access:
    • chown LocalSettings.php and the images directory (recursively) so it is in your name but the apache group
    • chmod LocalSettings.php to 640 and chmod the images directory to 775 (recursively). Leaving everything else as the default should be fine.

Database

edit

Maintenance scripts

edit
  • Manual:Maintenance scripts
  • Helpful after importing data into your wiki (fixes categories for example): Manual:rebuildall.php
  • If you see some links with Special:BadTitle the script Manual:cleanupTitles.php can help to fix this.
  • if you get an PHP Notice like "Undefined index: SERVER_NAME in /yourfolder/mediawiki/includes/GlobalFunctions.php on line 1471" you can try this on the console[7]
SERVER_NAME=yourdomain.com
export SERVER_NAME
php update.php 
If php update.php doesn't work, try php_cli update.php

Manual:RunJobs.php:

  • one can also run it with php srv/directory/mediawiki/maintenance/runJobs.php
  • SMW recommends parameter --maxjobs 1000

Moving entire wiki

edit

Steps to change the domain of the wiki:

  • Point the new domain to your FTP folder
  • In LocalSetting.php change the domain under $wgServer
  • Done :)

Caching

edit

Object caching:

  • If you use $wgMainCacheType = CACHE_ACCEL; and you can't login afterwards, try to set $wgSessionCacheType = CACHE_DB;.[9]

Page caching:

  • See Manual:File_cache
  • To invalidate all cached html files, just edit LocalSettings.php (adding a space is enough).
  • If you edited a template that is used on all pages, logged-in users see the change (coming from the template), but logged-out users are still served the cached page. -> Invalidate all cached files to reflect the changes for everybody.

Extensions

edit

All Extensions:

Downloading:

  • Download extensions and see most popular ones can be done with Special:ExtensionDistributor
    Yaron Koren: "However, for most extensions, these files represent a random snapshot that may not actually hold a working set of code."[11] -> it's better to download extensions with Git
  • "...the fact that an extension's code is contained on the MediaWiki Git repository is to some extent... a positive sign about its maintenance."[12]

Misc:

  • Snippets - small pieces of code to provide additional functionality whether interactive, visual or both.
  • Cite: It's okay to use <ref name="foo"></ref> and define foo only later.
  • If the version number on Special:Version is not updated although you have the new files in place: Topic:Ubxbytoe9k5jqkug

Useful extensions

edit

Show a list of users who have contributed to an article:

  • Extension:Contributors: used often, works after this and this hack, in includable version contributors are sorted by edits, but not linked and there is no number of edits -> managed to hack the code so that users are linked and number of edits are shown :)
  • Extension:Contribution_Credits: ordered by username, stable, used 6 times (works!), managed to remove certain usernames by hacking extension
  • Extension:Uniwiki_Authors: old, unordered list, hack to show only users who contributed certain number of bytes, according to Wikipiary: not used
  • Extension:PageBy: excludes bots and anons, ordered by edits?, very old, used 6 times (but couldn't see it on two of those wikis)
  • Extension:AuthorInfo: limit number of shown users, not used, code completely outdated
  • Extension:Semantic_Extra_Special_Properties: unordered, output as a property (I can adapt it via ask function)

Extensions that (in my eyes) could provide a good commenting service (as of 23.7.2016):

  • Extension:Comments - works good. Anons can comment too, but they can only leave a text (not their name, not their website).
  • Extension:PageDisqus - integrates the Disqus commenting service to every page, right after the content area
  • Extension:Widgets - with Facebook and Disqus widgets

Failed extensions

edit

Extensions I tried and didn't find to be useful (so far).

Extension My purpose Issue Solution
Extension:Multi-Category_Search Find pages that are in certain categories (more than one) None Found Semantic MediaWiki which suits my needs far better :)
smw-searchprofile Combine full text search with semantic search Doesn't offer it Use Extension:SolrStore instead
Extension:UniversalSuggester Add function to toolbar to search for certain templates and pages Problem with (standard) toolbar in 1.19.2 - and: doesn't work with WikiEditor toolbar - also see Extension_talk:UniversalSuggester#Where_is_the_toolbar.3F_19440 TO DO: Customize WikiEditor

Hooking / Building custom extensions

edit
Ways to add HTML output (in MediaWiki 1.19)
edit

Don't quote me on that, I might be wrong / not completely right.

If OutputPage object ($output) is passed to function

  • Use &$out in function definition, like function myFunction (&$out).
  • Then use one of the following:
    • $out->addHTML('<div id="yeah">bla</div>');
    • $out->addHTML("<div id=\"yeah\">bla</div>");

If OutputPage object ($output) is not passed to function

  • Use: global $wgOut;
  • Then use one of the following:
    • $wgOut->addHTML('<div id="yeah">bla</div>');
    • $wgOut->addHTML("<div id=\"yeah\">bla</div>");
Get the title of a page
edit
  • in VectorTemplate.php: $this->getSkin()->getTitle()
  • in LocalSettings.php: $out->getTitle() (at least this works within a function like this function MyFunction(&$out, &$skin) { ... }

Example: Adding og:image to the Main page of your wiki (and only on the Main page):

$wgHooks['BeforePageDisplay'][] ='MyFunction';
function MyFunction(&$out, &$skin) {

	$script= "";
	if ($out->getTitle() == "Main page" ) { 
		$script .= "<meta property='og:image' content='/your-logo.png'>";
	}

	$out->addHeadItem("My script", $script);
	return true;
};

Tables:

table.your_zebra_class > tbody > tr:nth-child(2n) > td {
    background-color: #F3F5F5;
}
edit
  • Highlight a sidebar entry:
#p-Name-Of-Sidebar-Entry h5 a {
    background-color: yellow;
}
  • Add picture before sidebar entry:
#n-Name-Of-Sidebar-Entry > a {
    background: url("http://upload.wikimedia.org/wikipedia/commons/7/7b/Neu.png") no-repeat scroll -1px 1px transparent;
    padding-left: 23px;
}
  • Show a certain entry (or a group of entries) only to a certain user group:
Add to your Common.css:
#n-Name-Of-Sidebar-Entry { 
    display: none;
}
Add to MediaWiki:Group-groupname.css (for example for bureaucrats: MediaWiki:Group-bureaucrat.css, more examples at Manual:User group CSS and Javascript) :
#n-Name-Of-Sidebar-Entry { 
    display: block !important;
}

Design & Skins

edit

Footer:

Mobile skinning:

Learn skinning:

Cool skins

edit

My favorites:

Other skins:

Ideas:

Show content only to logged-in users

edit

Ways to show content only to logged-in users and not to anons ("show" means "print on screen"):

Working solution: CSS
In MW 1.16.2 I used this code to load a custom CSS sheet (in my PHP skin file) - this code still works with 1.19.2:

global $wgUser;
if (!$wgUser->isLoggedIn()) {
    $out->addStyle( 'vector/anon.css', 'screen' );
}

Create a file "anon.css" (in the skins/vector directory) and add:

.noanon {
   display: none;
}

Then in your wikitext add the following class if you don't want to show content to anons (that means if you want to show content only to logged-in users):

bla bla (visible to everyone)
<div class="noanon">
Only visible to logged-in users
</div>

Working solution: Extension:UserFunctions
Use parser function {{#ifanon:then|else}}.

Possible solution: common.js (not working for me)

use something like <div class="anononly>your wikitext</div>; in MediaWiki:common.css add: .anononly { display: none; } 
and in MediaWiki:common.js add if ( !mw.user.isAnon() ) { $( '.anononly' ).removeClass( 'anononly' ); }

Tried it and failed - tried the example shown here and replaced isanon with anonymous (since I used 1.19.2) but still no message.

Possible solution: user group CSS
One can load a CSS file for certain user groups via Manual:User_group_CSS_and_Javascript - this works fine for all user groups except for anons (see this discussion).
User group CSS file seems to be case sensitive (I had to name the file MediaWiki:Group-Mitschreiber.css instead of MediaWiki:Group-mitschreiber.css to get it working).

Show content only to a certain group (in PHP files)

edit

The following worked for me - I added this code in my skin PHP file:

global $wgUser;
if (in_array("YourUserGroupName", $wgUser->getEffectiveGroups())) {
   dosomething;
}

Images

edit

Thumbnails:

Uploads:

  • Bulk upload is possible with Extension:UploadWizard
  • Uploading within the editor is possible with the VisualEditor
  • Fix issues with uploading files in MW 1.26.2: in Ubuntu chown everything to www-data: chown -R www-data:www-data mediawiki

Other technical stuff:

  • Renaming (a lot of) images with the API: /api.php?action=move&from=File:old.jpg&to=File:new.jpg&token=xxxx
  • Manual:Image_administration#Deletion_of_images
  • Images URLs: To use absolute URLs instead of relative URLs place the domain in the variable $wgScriptPath. This is useful if you embed the wiki content on another domain but want the images to be loaded from the original (wiki) URL.

JavaScript & jQuery

edit

JavaScript:

$wgHooks['BeforePageDisplay'][] ='MyFunction';
function MyFunction(&$out, &$skin) {
    $script = "<script type='text/javascript'>Your JavaScript code</script>";
    $out->addHeadItem("My script", $script);
    return true;
};

Loading JavaScript that is required for other modules:
Since MediaWiki 1.26 all of MediaWiki's JavaScript is loaded asynchronously. If one doesn't load the external code through the ResourceLoader and declare dependencies, you have no guarantee that jQuery (or anything else) will be available at the time you load your code.[15]
-> Possibilities:

jQuery:

  • jQuery has been introduced in MediaWiki core as of MediaWiki 1.16 and is loaded by default on every page as of 1.17 (see JavaScript). One doesn't find any "jquery" term within the source code of the page though.
  • Add jquery ready function to Mediawiki:Common.js: just write $(document).ready(function() { without script tags.
  • If you add $(document).ready(function() { to the wikitext of a page, you'll get an error. This is because the script is loaded before jQuery and mw scripts[16]. Instead, edit Common.js and insert this, adapting the page name and script path:
if (mw.config.get('wgPageName') == 'Your page') {
    $.getScript('path.script.js');
}
  • Also, if you add a script.js (that contains jQuery) somewhere in your php files, there might be an error "$ is not defined". If you load the script via Mediawiki:Common.js there is no problem.
  • The JavaScript from Common.js is loaded after the page load event, so document.write cannot be used there.[17]

Search / Replace

edit

The Wikimedia Foundation uses CirrusSearch (ElasticSearch). More info:

"Usual" MediaWiki uses LuceneSearch:

  • "The search functionality can be considered to operate on whole words." -> You won't get the desired results if you enter only a part of a word :(
    Good workaround: Use the search function of Extension:Replace Text (without replacing anything, i.e. don't carry out the 2nd step, just do the 1st one). It also finds part of a word :)
  • See Help:Searching#How_it_works for more info

Other search engines:

Misc:

Replace:

  • Extension:ReplaceText works fine - in terms of Regex (regular expressions) only the following special characters are allowed: ( ) . * + ? [ ] | - ^ for example doesn't work
  • To use other (all) Regex commands, use Extension:MassEditRegex
  • Do not alter the database with offline tools like Notepad++, see Topic:Ubxsfo482b58tlop.
  • People also recommend to use Pywikibot to do replacements on the wiki.

Users

edit
  • If admin creates a user account (for someone else):
    Benutzerkonto anlegen = use PW that was entered before
    Per E-Mail = use random PW and mail it to new user
  • Account names (usernames) are case sensitive. Not allowed characters in usernames by default: @ and : (see Manual:$wgInvalidUsernameCharacters). Spaces are allowed.
  • Change email address of an user: [9]
  • Mass delete (spam) users: Possible with Extension:BlockAndNuke in combination with Extension:UserMerge - see this paragraph

Permissions

edit

Groups

  • To define a new group just use a line in LocalSettings.php with $wgGroupPermissions['Test-Gruppe']['right'] = true; (it's not necessary to create a page MediaWiki:Group-Test-Gruppe, but it's recommened - see here)
  • How to add bureaucrats to protection groups
  • To disable for everyone and also users that don't belong to a certain group "Test-Gruppe":
# Disable for everyone.
$wgGroupPermissions['*']['edit']              = false;
# IMPORTANT: Disable for users too: by default 'user' is allowed to edit, even if '*' is not.
$wgGroupPermissions['user']['edit']           = false;
# Allow for Test-Gruppe:
$wgGroupPermissions['Test-Gruppe']['edit'] = true;

Feed

edit

Multilingual Wiki

edit

Namespaces

edit
  • To see all namespaces used on a wiki (with their numbers): use URL mediawiki/api.php?action=query&meta=siteinfo&siprop=namespaces
  • All namespaces used by MediaWiki itself and its extensions: Extension default namespaces

Custom namespaces:

  • Get the content part of a page via the API: api.php?page=Albert_Einstein&action=parse&format=json
  • Special:ApiSandbox
  • Other stuff: search for api on this page

Connecting WordPress with MediaWiki

edit

Single Sign-On

Run MW and WP on the same domain (without subdomains)
Say you want your wiki to be located at example.com/wiki and at the same time you want your WordPress pages to be at example.com/word and example.com/press - and: the homepage example.com should be also a WordPress page.

This worked for me:

  • Install MediaWiki in folder root/mediawiki and WordPress in root/wordpress.
  • In WP Dashboard -> Settings -> General set the following:
  • Copy the index.php from root/wordpress to root/ and change the line require('./wp-blog-header.php'); to require('./wordpress/wp-blog-header.php'); (see also [13])
  • Now comes the magic: Copy the content of root/wordpress/.htaccess and generate the following .htaccess file in root/ :
# BEGIN MediaWiki
RewriteEngine On
# for Short Wiki URL:
RewriteRule ^wiki/(.*)$ /mediawiki/index.php?title=$1 [PT,L,QSA]
RewriteRule ^wiki/*$ /mediawiki/index.php [L,QSA]
# To redirect all users to access the site WITHOUT the www. prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
#END MediaWiki

# Copy the content of root/wordpress/.htaccess and add it below:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
  • Make sure that you do not add a line like the RewriteRule ^/*$ /mediawiki/index.php [L,QSA] since this would forward the homepage to your wiki (we don't want this since we want a WordPress homepage).
  • This tutorial assumes that you use Short URLs for your wiki - I use the following lines in my LocalSettings.php:
$wgScriptPath       = "/mediawiki";
$wgArticlePath = "/wiki/$1";  
$wgUsePathInfo = true;
  • You don't have to delete the original .htaccess file in root/wordpress/.htaccess.

Messages / Languages

edit
  • If you want to see system messages in another language add ?uselang=language to the URL (for english use ?uselang=en for example)
  • You can find the message you want to change by adding ?uselang=qqx to the URL.
  • MediaWiki:Copyright is only shown if $wgRightsText is set to something else than "" (also works if one uses $wgRightsText = " "; but in this case an empty image is put into the footer)

Cookies

edit
  • Overview of cookies that MediaWiki sets
  • If you check the "Keep me logged in" box when you log in, the login cookies have a lifetime of half a year (be default). Without the tick, the lifetime is only one month (by default).

Misc

edit

Timezone issues:

Security:

References:

  • Any list with more than 10 references will get the CSS class .mw-references-columns[19]. This can be used to show the references in columns.

How to chose the right editor / form / template

edit

When it comes to editing usual pages (without SMW attributes) as of 2024 I go with the VisualEditor, because it has WYSIWYG and it handles citation very well.

Extension:PageForms was my choice before, even for editing usual pages. It can be used with Extension:VEForAll, but unfortunately VEForAll has no citation option.[20] So now we use PageForms only when a page has a lot of attributes and/or needs autosuggestion in input fields.

In combination with the VisualEditor I use Extension:TemplateData to provide helpful information when using simple templates like a warning boxes with custom text (i.e. a template with one string parameter). But TemplateData lacks flexibility to autosuggest values and/or restrict input. There is a suggestedvalues parameter, but the values within that parameter need to be put in manually. One can't use a SMW query for example. So it can't replace PageForms and SMW templating.

Creating content

edit

Some special wikitext:

Templates

edit

Parameters

edit

Including

edit
  • If the source is in the Template namespace, just use the name itself, alone: {{Bla}}
  • If the source is in the Main article namespace, you must put a colon (:) in front of the name, thus: {{:Cat}}
  • If the source is in any other namespace (e.g., "User:Example"), you must use the full name, including the namespace, thus: {{User:Example}}
  • Noinclude, includeonly, onlyinclude:
    • noinclude: displayed only when the template page is being viewed directly; will not be included; useful for a description how to use the template and for [[Category: Template]]
    • includeonly: displayed only when the page is being included. Useful for adding all pages containing a given template to a category, but not the template itself.
    • onlyinclude: only text surrounded by "onlyinclude" markup should be transcluded onto another page. It often overrules the other include tags: If there is at least one pair of "onlyinclude" tags on a page, then whenever this page is transcluded, it is only the material within the "onlyinclude" tags which gets transcluded.
  • If you want to know on which pages you've included a certain other page (with {{:Page}}):
    Go the page, click on "What links here" and "Hide Links" and "Hide redirects". Then one can see the transclusions easily.

Discussions & Watch/Unwatch

edit

Liquid Threads

edit

Update: Extension:LiquidThreads (LQT) is no longer maintained and replaced by Flow

Old stuff (just for the record):

  • Namespaces that LQT adds: Extension_default_namespaces#LiquidThreads
  • How to prevent anons from using LiquidThreads
  • Header
    • If a LQT thread is started in a discussion page, the LQT header seems to be generated (red "Kopfbereich ergänzen" changes to "Bearbeiten Versionen Löschen")
    • If one adds LQT to a page, the Edit and Delete links at the top disappear. You can find them in the LQT header (Discussion).
  • There are 2 user preferences (see Manual:$wgDefaultUserOptions at the very end of the table):
    • lqt-watch-threads: Selbst erstellte oder von mir bearbeitete Themen beobachten (true by default)
    • lqtnotifytalk: Bei Antworten zu beobachteten Themen E-Mails senden (false by default)
  • Problems (with 2.0 alpha):
    • lqt-watch-threads works - but after replying to a thread you have to refresh the page (clear cache) to see "unwatch" instead of "watch" (if you start a new thread it works just fine).

Parser functions

edit
|-
| usual cells
| without if {{#if:{{{Foo|}}}|<br />
{{!}}-
{{!}} cells that are shown 
{{!}} only if Foo is not empty
|}}

#time

  • #timel is identical to #time, except that it uses the local time of the wiki (I didn't have to set $wgLocaltimezone, #timel gave the right time anyway).
  • Check if a date is in the past or not:{{#ifeq:{{#expr:{{#time:U|DATE}}>{{#time:U}}}}|0|In the past|In the future}}

Images & Files

edit
  • Turn off link to image description page: |link= (see also Help:Images#Display_image.2C_turn_off_link)
  • Directly link to a PDF instead of its description page: use [[Media:Filename.pdf]] instead of [[File:Filename.pdf]]
  • Get path to file: {{filepath:File.pdf}} - see here
  • Licensing

HTML

edit

TOC / Headlines

edit

Categories

edit

Ways to print out a list of all available categories:

Linking

edit

Revisions

edit
  • If you want to show the date on which an article was last updated: Last update: {{REVISIONDAY}}.{{REVISIONMONTH1}}.{{REVISIONYEAR}}
  • If you want to hide revisions from the public: Use $wgGroupPermissions['sysop']['deleterevision'] = true;. See Manual:RevisionDelete.

Misc

edit

Other wiki software:

  • Open sourceL DokuWiki, PmWiki, Tiki, TiddlyWiki,
  • Confluence (proprietary application)
  • CMS that include some limited wiki functionality: for example Traction TeamPage, Microsoft SharePoint

Market share:

References

edit
  1. https://phabricator.wikimedia.org/T180121#8737030, viewed on 3.4.2023
  2. Download from Git#Keeping up to date, viewed on 29.3.2024
  3. https://www.facebook.com/groups/2205099323/permalink/10153412499994324/?comment_id=10153413494564324
  4. https://www.facebook.com/groups/2205099323/permalink/10153329509004324/
  5. Manual:$wgMemoryLimit, viewed on 23.5.2016
  6. PHP_configuration#Runtime_configuration_.28php.ini.29, viewed on 23.5.2016
  7. https://www.mediawiki.org/wiki/Manual:Wiki_family#Updating_wikifarm_from_the_commandline, viewed on 14.7.2016
  8. https://www.mediawiki.org/wiki/Topic:Txr70j0hdpc0lv11, viewed on 25.11.2020
  9. https://www.mediawiki.org/w/index.php?title=Topic:Ttnxs3dosx3he584&topic_showPostId=ttoooy8x731aiqzj#flow-post-ttoooy8x731aiqzj, viewed on 22.2.2019
  10. Topic:Sv0x5t8jb1qgqqhe
  11. https://workingwithmediawiki.com/book/chapter2.html, viewed on 28.4.2021
  12. https://workingwithmediawiki.com/book/chapter2.html, viewed on 28.4.2021
  13. http://www.wiki-forum.de/javascript-in-head-einbinden-t362082.htm?sid=d493a1c299ca33d4ad09e46fc7a4adbc#4419655, viewed on 25.7.2016
  14. https://stackoverflow.com/a/26436873/3194543, viewed on 21.10.2017
  15. https://stackoverflow.com/a/43581394/3194543, viewed on 24.11.2017
  16. [1], viewed on 11.2.2020
  17. [2], viewed on 11.2.2020
  18. https://www.mediawiki.org/wiki/Manual:Using_custom_namespaces#Creating_a_custom_namespace, viewed on 13.7.2016
  19. Contributors/Projects/Columns_for_references, viewed on 29.7.2020
  20. Topic:Vjsmim3tel8qynrd, viewed on 17.5.2024
  21. https://www.mediawiki.org/w/index.php?title=Topic:Qyy7labouxcfg3oy&topic_showPostId=w2dac61d4q9u5ezg#flow-post-w2dac61d4q9u5ezg, viewed on 17.5.2024
  22. http://www.cloudways.com/blog/mediawiki-seo-tips/
  23. http://w3techs.com/technologies/overview/content_management/all, viewed on 21.9.2013 and on 17.11.2021