Wikipedia Parser
Cubia is a lightweight Wikipedia mirror that can run on older computers (less than 1Ghz) without any trouble. One of the issues that it has had for a long time is parsing the Wiki markup to look like Mediawiki (the software that runs Wikipedia). I was making use of a project that stalled years ago but seems to be the only project that can at least somewhat parse it. I looked for updated versions and it seems as though no one has created a full featured stand alone MediaWiki Parser. Most people apparently just run MediaWiki which is fine when you don’t have millions of articles or you have a very powerful server.
So, I finally decided to see if I could just use MediaWiki. Now obviously I can’t point it at Cubia’s database and just expect it to work. Cubia’s database is nothing like MediaWiki’s database. So the first thing I did was install MediaWiki with its own database. I quickly found that skinning wasn’t going to do it. I needed to pull Cubia’s data into MediaWiki to render while MediaWiki uses a bunch of convoluted code to render a page. Using MediaWiki directly would be a huge code rewrite hassle.
So I took a look at MediaWiki’s index.php file and found that I could cut out most of it. The only code needed is the initialization of MediaWiki. After that code is initialized I just pulled the data from Cubia and ran it though $wgOut->parse().
You do need to add
require_once( 'includes/GlobalFunctions.php' );
require_once( 'includes/Parser.php' );
You also have to get rid of the lines in Index.php that get the page title. That’s done either by setting a variable in the page that includes the mediawiki renderer or by setting the REQUEST value.
Before the Setup.php include in order for this to work. I renamed MediaWiki’s index.php to cubia.php and copied the mediawiki installation into Cubia. Now, when rendering an article I just include cubia.php and it creates a variable with the HTML version of the document.
More work needs to be done to clean up the cubia codebase but it functions rather well. Eventually I’d like to figure out the minimum code needed to use MediaWiki’s parser.