MediaWiki

From Indie IT Wiki

For details on the formatting schema on this wiki see here.

Software

Compatibility

Releases

Tables Generator

http://www.tablesgenerator.com/mediawiki_tables

HOWTO: Backup

XML and ZIP file

Importing

Pages

OLD SERVER

Generate the page dump in XML format...

php dumpBackup.php --current > pages.xml

NEW SERVER

Import the pages...

cp pages.xml ./data/html/
php importDump.php < pages.xml
php maintenance/update.php
php maintenance/rebuildall.php
exit

https://www.hostknox.com/tutorials/mediawiki/pages/export-and-import#import-pages-via-ssh

Images

OLD SERVER

Generate the image dumps using dumpUploads.php, which creates a txt list of all image filenames in use...

mkdir /tmp/workingBackupMediaFiles
php maintenance/dumpUploads.php \
   | sed 's~mwstore://local-backend/local-public~./images~' \
   | xargs cp -t /tmp/workingBackupMediaFiles
zip -r ~/Mediafiles.zip /tmp/workingBackupMediaFiles
rm -r /tmp/workingBackupMediaFiles

NEW SERVER

Unzip the files to your container filsystem...

unzip Mediafiles.zip -d /path-to/html/

Import the Images...

php maintenance/importImages.php tmp/workingBackupMediaFiles
php maintenance/update.php
php maintenance/rebuildall.php
exit

https://stackoverflow.com/questions/1002258/exporting-and-importing-images-in-mediawiki

HOWTO: Enable Hit Page Counter Hits

https://www.mediawiki.org/wiki/Extension:HitCounters

HOWTO: EMBED VIDEO

Full guide here.

HOWTO: Update MediaWiki Software

This will update the whole mediawiki software and overwrite the files located in a subdirectory called 'wiki'. Please adjust according to your web hosting! This example is for 1&1...

cd /path/to/web/hosting/
tar -czvf wiki.tar.gz wiki/
wget http://download.wikimedia.org/mediawiki/1.25/mediawiki-1.25.6.tar.gz
tar -xzvf mediawiki-1.25.6.tar.gz -C wiki/ --strip-components=1
cd wiki/
php maintenance/update.php --skip-external-dependencies

This example is for Amazon EC2 running Ubuntu Linux 14.04 LTS...

cd /var/www/domain.com
tar -czvf wiki.tar.gz html/
wget http://download.wikimedia.org/mediawiki/1.25/mediawiki-1.25.6.tar.gz
tar -xzvf mediawiki-1.25.6.tar.gz -C html/ --strip-components=1
cd html/maintenance/
php update.php

If you receive this error...

Error: your composer.lock file is not up to date, run "composer update" to install newer dependencies

...then you need to install the 'composer' binary...

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
cd /var/www/domain.com/html/
composer install
composer update

...and now you can update the Wikimedia software...

cd html/maintenance/
php update.php

Thanks - http://www.cyberciti.biz/faq/how-to-install-composer-on-debian-ubuntu-linux-server

HOWTO: Remove External Link Icons

https://en.wikipedia.org/wiki/Help:External_link_icons

div#content a.external 
{
   background:none !important;
   padding: 0px !important;
}

HOWTO: Change CSS Colours

nano skins/MonoBook/main.css
pre, .mw-code {
   color: #FFFFFF;
   background-color: #364554;
   border: none;
   padding: 0.5em;
   white-space: pre-wrap;
   word-wrap: break-word;
}
.postedit {
   display: none;
}
pre a.external {
   color: #FFFFFF;
}
pre a.external.free {
   color: #FFFFFF;
}
pre a.external.free:visited {
   color: #FFFFFF;
}
a.external.free {
   background-image: none;
}
pre a:visited {
   color: #FFFFFF;
}
div#content a.external 
{
   background:none !important;
   padding: 0px !important;
}

HOWTO: Installation In Ubuntu Server

https://help.ubuntu.com/community/MediaWiki

Enable Auto Complete In Search Box

http://www.mediawiki.org/wiki/Manual:Enabling_autocomplete_in_search_box

WPtouch Mobile Skin

http://www.memorydeleted.com/?p=396

Simple Mobile Skin Auto Change

http://www.mediawiki.org/wiki/Extension:MobileFrontend

Using Lists & Tables

http://www.packtpub.com/article/using-tables-and-lists-with-mediawiki

Changing User Password Via Command Line

cd /var/www/localhost/htdocs/mediawiki/maintenance/
php changePassword.php --user=jsmith --password=myPas5w0rd

Restrict Editing Of All Pages

$wgGroupPermissions['*']['edit'] = false;

Wrapping Text In Code Lines

<pre style="white-space:normal;"> your long line of text here... </pre>

MediaWiki ShortURL Builder

~/.htaccess

RewriteEngine On
RewriteRule ^/?wiki(/.*)?$ %{DOCUMENT_ROOT}/index.php [L]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2 [L,QSA,B]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteRule ^/?images/thumb/archive/[0-9a-f]/[0-9a-f][0-9a-f]/([^/]+)/([0-9]+)px-.*$ %{DOCUMENT_ROOT}/thumb.php?f=$1&width=$2&archived=1 [L,QSA,B]

~/LocalSettings.php

# short urls tweak
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";
$wgScriptExtension = ".php";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

https://www.mediawiki.org/wiki/Manual:Short_URL

http://shorturls.redwerks.org/

Analytics

Matomo

https://www.mediawiki.org/wiki/Extension:Matomo

Google

https://www.mediawiki.org/wiki/Extension:Google_Analytics_Integration

Lock Down Wiki

Disallow account creation (add the following to the end of LocalSettings.php)...

$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['user']['createaccount'] = false;
$wgGroupPermissions['sysop']['createaccount'] = false;

Disallow reading and writing...

$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = false;

Links:

http://en.wikibooks.org/wiki/MediaWiki_Administrator%27s_Handbook/Page_Protection

http://www.mediawiki.org/wiki/Manual:Preventing_access

HOWTO: Add Extra Buttons To Edit Page

http://www.mediawiki.org/wiki/Customizing_edit_toolbar#How_do_I_add_more_buttons_on_the_edit_page.3F

HOWTO: Update Sitemap

sudo -i
cd /var/www/html
php maintenance/generateSitemap.php --fspath . --server http://wiki.indie-it.com --urlpath http://wiki.indie-it.com --compress=no
touch sitemap*