I'm trying to write a command line mediawiki markup parser that doesn't require a full Mediawiki setup/installation with database etc.
So far I have this below which works pretty good but requires that my Mediawiki installation be set up with a database.
How can I remove the database dependency from this script?
Also, the article links generated are in the format /index?title=Article_Title&action=edit&redlink=1 how can I change the formatting of these parameters so that it's just /Article_Title
Thanks,
Jonathan
<?php
require_once dirname( __FILE__ ) . '/maintenance/commandLine.inc';
$text = "* [[foo]]\n* [[Example|bar]]\n* [http://example.com/ an outside link]";
$titleObj = Title::newFromText( 'Example' ); $parserOptions = new ParserOptions(); $parserOptions->setTidy( true ); $parserOptions->setEditSection( false );
$parserOutput = $wgParser->parse( $text, $titleObj, $parserOptions ); $parsedText = $parserOutput->getText();
echo $parsedText;
?>
On 24/02/12 07:38, Jonathan Boler wrote:
I'm trying to write a command line mediawiki markup parser that doesn't require a full Mediawiki setup/installation with database etc.
So far I have this below which works pretty good but requires that my Mediawiki installation be set up with a database.
How can I remove the database dependency from this script?
You could create a dummy database class. But it's probably easier to use an empty database. You can use sqlite to avoid having to run a database server.
Also, the article links generated are in the format /index?title=Article_Title&action=edit&redlink=1 how can I change the formatting of these parameters so that it's just /Article_Title
They are in that format because those pages are missing (for existing ones see $wgArticlePath). You can hook TitleIsAlwaysKnown and unconditionally set $isKnown to true (this is a very recent hook, on older versions you will need to modify Title::isAlwaysKnown() )
That worked. Thanks for your help.
I now have the latest dump of the whole English Wikipedia running locally on my laptop using this:
http://users.softlab.ece.ntua.gr/~ttsiod/buildWikipediaOffline.html
Searching and rendering are almost instant!
Jonathan
On Sat, Feb 25, 2012 at 5:38 PM, Platonides Platonides@gmail.com wrote:
On 24/02/12 07:38, Jonathan Boler wrote:
I'm trying to write a command line mediawiki markup parser that doesn't require a full Mediawiki setup/installation with database etc.
So far I have this below which works pretty good but requires that my Mediawiki installation be set up with a database.
How can I remove the database dependency from this script?
You could create a dummy database class. But it's probably easier to use an empty database. You can use sqlite to avoid having to run a database server.
Also, the article links generated are in the format /index?title=Article_Title&action=edit&redlink=1 how can I change the formatting of these parameters so that it's just /Article_Title
They are in that format because those pages are missing (for existing ones see $wgArticlePath). You can hook TitleIsAlwaysKnown and unconditionally set $isKnown to true (this is a very recent hook, on older versions you will need to modify Title::isAlwaysKnown() )
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org