The geek way to edit a mediawiki: wikipediafs

I have always hated wysiwyg html editors because they never produced the output I actually wanted to have. Also, being used to writing close to everything in vim, with wikipediafs, I found the perfect way to edit a mediawiki, which I use for work- and personal documentation. Here’s how to set it up.

I’m lazy, so my laptop runs xubuntu (an ubuntu version with my favorite desktop environment xfce). This distribution ships a package for wikipediafs. If you’re running a different distribution, the setup might be slightly different from what’s next.

First off: install the package:

sudo apt-get install wikipediafs

Then, it’s time for the dummy mount, which creates the configuration file. I created a directory called “mediawiki” in my home directory to mount the filesystem.

mount.wikipediafs /home/ahwhattheheck/mediawiki

To verify this worked, run

df -a

you should see an entry with wikipediafs in the list of mounted filesystems. If the mount command was not successful, check that you have write permissions to the mountpoint and you also may need to be a member of the fuse usergroup.

So anyway, if the first “dummy” mount succeeded, you will see the new directory .wikipediafs in your $HOME. It holds the configuration file config.xml that already has a test wiki configuration enabled.

<?xml version="1.0" encoding="UTF-8"?>
<wfs-config>
 <general>
   <!-- Cache time in seconds -->
   <article-cache-time>30</article-cache-time>
   <login-cache-time>7200</login-cache-time>
  </general>
  <sites>
   <site>
    <dirname>mblondel.org</dirname>
    <host>www.mblondel.org</host>
    <basename>/mediawiki/index.php</basename>
   </site>
  </sites>
</wfs-config>

Yes, it is freaking xml, but you’ll get over it … If you take a look into the mountpoint, you will see that the configured dirname refers to a directory within the mountpoint representing the configured mediawiki instance. The host configuration is the fully qualified domain name of the instance and the basename has to be set to the url where the wiki resides.

So now it’s time to configure your instance of mediawiki in wikipediafs:

 <site>
  <dirname>directory_name</dirname>
  <host>www.yourdomain.com</host>
  <basename>/wiki/index.php</basename>
  <username>your username</username>
  <password>your password</password>
 </site>

To activate this configuration, unmount and mount the filesystem.

sudo umount /home/ahwhattheheck/mediawiki
mount.wikipediafs /home/ahwhattheheck/mediawiki

Now say you want to edit the existing page “Wurst” on your wiki.

cd $mountpoint/directory_name
vi Wurst.mw

This opens the article in vi (of course you can use whatever editor you like) and lets you edit the page in a convenient way. As soon as you write the “file”, the article is saved online. Exiting without saving leaves the article untouched as you’d expect. Creating a new article is just as easy, simply create a new “file” with the file ending “.mw” with your editor and write it.

If your mediawiki instance is on an SSL site, add an <https/> tag to the site-configuration and if your instance is behind some basic-auth mechanism, you might want to use httpauth_username and httpauth_password tags to your site configuration. You might also want to have a look at the manpage to mount.wikipediafs.

To mount wikipediafs at boot time, create an entry in /etc/fstab

none /home/ahwhattheheck/mediawiki/ wikipediafs auto,user

This sure isn’t for everybody, but I just freaking love it.

Advertisements

4 responses to “The geek way to edit a mediawiki: wikipediafs

  1. unfortunately, since the software is not maintained for quite some time, there seem to be problems when editing large pages. so this should be used with caution (or not used).

  2. Hey there,
    I really want to use this system, but am encountering an error. It works as you suggest up until I try

    vi Wurst.mw

    upon which I get an error at the bottom of vim:

    “Wurst.mw” [Permission Denied]

    Any ideas what’s going wrong?

  3. Unfortunately, I don’t have an idea on that one. Since it is unmaintained software, I stopped using it after a couple of (failed) tests (see comment 1).

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s