Difference between revisions of "MediaWiki"
m (→References) |
|||
Line 224: | Line 224: | ||
<br>Having a CSS trick to see clearly when we're offline could help |
<br>Having a CSS trick to see clearly when we're offline could help |
||
+ | ==Tips== |
||
+ | When developing extensions I had the problem that cached pages didn't get refreshed properly even if [http://www.mediawiki.org/wiki/File_cache they claim] it shouldn't concern logged users. |
||
+ | <br>It is possible to force one individual page to be invalidated and refreshed by using ?action=purge |
||
==References== |
==References== |
||
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list] |
* [http://www.mediawiki.org/wiki/Help:Configuration_settings Configuration settings list] |
Revision as of 19:26, 25 March 2008
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
- cf http://meta.wikimedia.org/wiki/Preventing_Access#Setting_permissions_for_a_Group_on_a_whole_new_Namespace
- and http://meta.wikimedia.org/wiki/Help:Custom_namespaces
- But there are security problems: http://meta.wikimedia.org/wiki/Talk:Preventing_Access#Security_Problem_using_Namespace_to_limit_access
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";
Menus
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
Google Gears support
This is an attempt to provide an offline version of the wiki.
Inspired by this blog post
Using Google Gears technology
You must first install the plugin available here, note that it does a stupid browser detection and refuses my Iceweasel 2.0 so I had to cheat with my User Agent Switch extension and mimick Firefox 2.0 ;-)
On the Mediawiki server:
- Create a folder gears in your MediaWiki installation directory
- I created /etc/mediawiki/gears <- /var/lib/mediawiki/gears <- /usr/share/mediawiki/gears
- As I'm using rewriting rules, I had to add to /etc/apache2/sites-available/wiki.yobi.be:
RewriteCond %{REQUEST_URI} !/gears/
- Download the gears_init.js from the Google Gears web site and place it in the newly created folder
- Download the gears_offline.js from the Google Gears tutorial
- Modify the manifest file name in this file to:
var MANIFEST_FILENAME = "/gears/manifest.php";
- Create the manifest.php that creates the file list on the fly (based on access to the database):
{ "betaManifestVersion": 1, <?php require_once("../DBSettings.php"); $l = mysql_connect($wgDBserver,$wgDBuser,$wgDBpassword); mysql_selectdb($wgDBname); $q = "SELECT max(rc_timestamp) from ".$wgDBprefix."recentchanges"; $r = mysql_query($q); $t = mysql_fetch_row($r); echo ' "version": "' . $t[0] . '",'; ?> "entries": [ <?php $q = "SELECT page_title from ".$wgDBprefix."page"; $r = mysql_query($q); while ($t = mysql_fetch_row($r)) { echo ' { "url": "/wiki/' . $t[0] . '" },'; } ?> { "url": "/wiki/Main_Page" }, { "url": "/gears/go_offline.js"}, { "url": "/gears/gears_init.js"} ] }
Note that I moved my DB settings from LocalSettings.php to DBSettings.php, replaced now by a
require_once("DBSettings.php");
And at the end of LocalSettings.php I add a link to my new extension:
require_once("$IP/extensions/GGears/ggears.php");
So that means another new directory /etc/mediawiki/extensions/GGears with the file ggears.php:
<?php if (defined('MEDIAWIKI')) { function fnMyGGearsHook($out) { $gearjs='<script type="text/javascript" src="/gears/gears_init.js"></script>'; $out->addScript($gearjs); $gearjs='<script type="text/javascript" src="/gears/go_offline.js"></script>'; $out->addScript($gearjs); $gearinit='init()'; $out->addInlineScript($gearinit); return true; } function fnMyGGearsHook2() { echo '<li><a href="#" onclick="createStore();">create Store</a></li>'; echo '<li><a href="#" onclick="capture();">capture</a></li>'; echo '<li><a href="#" onclick="uncapture();">uncapture</a></li>'; echo '<li><a href="#" onclick="removeStore();">remove Store</a></li>'; echo '<span id="textOut"></span>'; return true; } $wgExtensionCredits['other'][] = array('name' => 'GGears', 'version' => '0.1', 'author' => 'Philippe Teuwen', 'url' => 'http://www.mediawiki.org/wiki/Extension:GGears', 'description' => 'Allows Google Gears to work offline'); $wgHooks['BeforePageDisplay'][] = 'fnMyGGearsHook'; $wgHooks['MonoBookTemplateToolboxEnd'][] = 'fnMyGGearsHook2'; } ?>
TODO
There is always a complete replication of online content as soon as some change occurred (this could be made smarter by not leaving everything to Gears, but implementing your own update strategy) and moreover I've to refresh the page :-( so it makes it quite impractical as such...
Check also http://code.google.com/apis/gears/samples/hello_world_managedstore/managed_store.html
Having a CSS trick to see clearly when we're offline could help
Tips
When developing extensions I had the problem that cached pages didn't get refreshed properly even if they claim it shouldn't concern logged users.
It is possible to force one individual page to be invalidated and refreshed by using ?action=purge
References
Useful pages:
- http://www.mediawiki.org/wiki/Manual:Backing_up_a_wiki
- http://www.mediawiki.org/wiki/Manual:AdminSettings.php
- http://www.mediawiki.org/wiki/Manual:Upgrading_to_1.11
- http://www.mediawiki.org/wiki/Manual:Short_URL/wiki/Page_title_--_with_aliases--root_access
- http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
- http://www.mediawiki.org/wiki/Manual:%24wgLanguageCode
- http://www.mediawiki.org/wiki/Manual:%24wgUseAjax