MediaWiki

From YobiWiki
Jump to navigation Jump to search

Install

Version 1.5 was not yet on amd64 feeds but v1.4.x reclaimed php4 so I took mediawiki v1.5 from the i386 feeds as anyway mediawiki is all arch.

  • Raise the PHP memory limit: create /var/lib/mediawiki1.5/.htaccess with%%%php_value memory_limit 32M

Preventing access to pages

Better solution seems to use this patch:

Or as refered on http://meta.wikimedia.org/wiki/Hidden_pages this one:

Disable anonymous reading

Easy to get:

Customisation

Logo

  • I created a symlink from /var/lib/mediawiki1.5/local to /etc/mediawiki1.5/localdata
  • In LocalSettings.php: $wgLogo = "$wgScriptPath/local/mylogo.png";

Import/Export

HTML-WikiConverter

apt-get install libhtml-wikiconverter-perl

Dialogs are not yet packaged, cf bugreports 419918 and 448912, so for now:

perl -MCPAN -e 'install HTML::WikiConverter::MediaWiki'

Here is the script I used to import my phpwiki pages:

#!/bin//bash


for i in lists/*; do
    mkdir -p $(basename $i)
    cd $(basename $i)
    for p in $(cat ../$i); do
	echo $p
	if [ ! -e "$p.html" ]; then
	    wget -q -O - "http://wiki.teuwen.org/$p" > "$p.html"
	fi
	cat > "$p.txt" <<EOF
''Converted with [[MediaWiki#HTML-WikiConverter|HTML::WikiConverter::MediaWiki]] from my old phpwiki site''
----
EOF
	cat "$p.html"|\
	   awk '
		/class=.wikitext/ {b=1};
		/Begin browse-footer/ {b=0};
		b==1' \
	 | sed 's/<div class="wikitext">//g' \
	 | sed 's/<span style="white-space: nowrap">//g' \
	 | sed 's/<span class="wikipage">//g' \
	 | sed 's/<img src="\/phpwikidata\/themes\/[a-zA-Z0-9]\+\/images\/[a-zA-Z0-9]\+.png" alt="" class="linkicon" border="0" \/>//g' \
	 | sed 's/\x92/\x27/g' \
	 |html2wiki --encoding iso-8859-1 --dialect MediaWiki >> "$p.txt"
#	  >> "$p.txt"
    done
    cd ..
done

Upgrade to 1.11

A big jump from 1.5...
Now the package is simply called mediawiki instead of mediawiki1.x
Strangely apt-get wanted to install mysql-server even if the package just recommends it.
So I downloaded the package and used dpkg -i

OpenID support

I installed the following extension:

I installed the extension into /etc/mediawiki/extensions and made a symlink from /var/lib/mediawiki/extensions
I created the extra SQL table:

mysql -uroot -p mediawiki < openid_table.sql

But I had first to edit openid_table.sql to add my table prefix (cf $wgDBprefix)
I installed php-openid:

apt-get install php-openid

Some modifications in /etc/mediawiki/LocalSettings.php:

# Adding /usr/share/php in the include_path to find the Debian php-openid package:
ini_set( "include_path", ".:$IP:$IP/includes:$IP/languages".":/usr/share/php" );
require_once("$IP/extensions/OpenID/OpenID.php");
$wgTrustRoot = "http://wiki.yobi.be/";
$wgOpenIDLoginLogoUrl = "local/login-bg.gif";

(the logo was downloaded from http://www.openid.net/login-bg.gif)

I had to patch the extension as apparently the API of php-OpenID changed since

--- Consumer.php.orig   2008-03-09 00:00:09.000000000 +0100
+++ Consumer.php        2008-03-09 00:00:33.000000000 +0100
@@ -144,7 +144,7 @@
 
                 default: # No parameter, returning from a server
 
-                       $response = $consumer->complete($_GET);
+                       $response = $consumer->complete($_GET['openid_return_to']);
 
                        if (!isset($response)) {
                                $wgOut->errorpage('openiderror', 'openiderrortext');
@@ -162,7 +162,7 @@
                         case Auth_OpenID_SUCCESS:
                                // This means the authentication succeeded.
                                $openid = $response->identity_url;
-                               $sreg = $response->extensionResponse('sreg');
+                               $sreg = $response->extensionResponse('sreg', true);
 
                                if (!isset($openid)) {
                                        $wgOut->errorpage('openiderror', 'openiderrortext');
@@ -558,7 +558,7 @@
        }
 
        function OpenIDToUserName($openid) {
-        if (Services_Yadis_identifierScheme($openid) == 'XRI') {
+        if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
                        wfDebug("OpenID: Handling an XRI: $openid\n");
                        return OpenIDToUserNameXri($openid);
                } else {
--- OpenID.php.orig     2008-03-08 22:41:02.000000000 +0100
+++ OpenID.php  2008-03-09 00:09:13.000000000 +0100
@@ -226,7 +226,7 @@
 
        function OpenIDToUrl($openid) {
                /* ID is either an URL already or an i-name */
-        if (Services_Yadis_identifierScheme($openid) == 'XRI') {
+        if (Auth_Yadis_identifierScheme($openid) == 'XRI') {
                        return OpenIDXriToUrl($openid);
                } else {
                        return $openid;

Normally the extension makes your personal page an OpenID server as well but I didn't try
Now you can login via Special:OpenIDLogin or associate your OpenID URL to your existing account via Special:OpenIDConvert
BTW initially I didn't know about Special:OpenIDConvert and I manipulated directly the SQL table ${wgDBprefix}user_openid

References

Useful pages: