Wikis are popular intranet tools in which teams collaboratively develop a shared knowledge base. So far, however, there has often been the problem that wikis were not available (even read-only) offline, e.g., when traveling.
Google Gears is an interesting new technology to solve the problem of offline web applications in a surprisingly easy way. In order to try out the potential of it, I have recently tried to apply it to the MediaWiki system (actually a Semantic MediaWiki installation).
What do you have to do?
- Create a folder gears in your MediaWiki installation directory
- 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 a php script, e.g. manifest.php
- Create the manifest.php that creates the file list on the fly (based on access to the database):
$l = mysql_connect(‘localhost’,’user‘,’pass‘);
$q = “SELECT max(rc_timestamp) from recentchanges”
$r = mysql_query($q);
$t = mysql_fetch_row($r);
echo ‘”version”: “‘ . $t . ‘”,';
- Modify the MonoBook.php skin file (or any other skin you are using):
- add “init()” to body onload
- add a placeholder <span id=’textOut’></span> somewhere for status messages, e.g. in the footer
Of course, the approach is quite a hack and does not scale for large wikis because 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). Likewise, offline search, editing, and other cool features are not available (this would require much more effort towards AJAXifying MediaWiki). So this simple solution just provides the possibility of offline reading – and this transparently to the user (and within less than one hour :).