views:

512

answers:

5

I need a way to insert new articles straight into my MediaWiki database without damaging the wiki installation.

I'm guessing if I knew what tables/attributes MediaWiki inserts to when creating a new article then I could fill them in myself.

Does anyone know a better way or have any suggestions?

+1  A: 

Why do you need to do this?

  • If you are trying to migrate data from a previous wiki installation, there exist import and export tools already.
  • If you want to automate the addition of a large set of pre-formatted pages automatedly, the MediaWiki API provides a safer route than mucking with the database directly.
ephemient
I am writing a php script to lists various RSS feeds from which the user can select articles to add into the wiki.I'm not too sure on how to use the API for this as I've never used it before. Is it possible to create several pages at once (depending on how many articles the user has selected) using the API?
I'm not sure if you can create many pages in a single call without using `action=import`, but you can just invoke `action=edit` multiple times, once for each new page you wish to create.
ephemient
I can probably use cURL to send multiple calls to the API. I'm having trouble figuring out how to use/create an edit token or specifying which user to do the posting with. Otherwise I'm on the right track. Thanks for the help.
+1  A: 

Definitely you don't want to write to the database directly. You may want to create an extension that takes selected items from RSS as input and creates one wiki article per item, using Article::doEdit().

Joshua C. Lerner
+1  A: 

Out of many bots and APIs available for MediaWiki, a simple place to begin is the MediaWiki Bulk Page creator.

http://meta.wikimedia.org/wiki/MediaWiki_Bulk_Page_Creator

It is a simple PHP script, relying on the Snoopy class library, that can create several pages from a simple text format.

Before getting started, make sure you read Creating a Bot first. it contains critical details on how to set up bot access to your wiki.

Laurent Alquier
Very helpful, got this up and running with my rss script in about 30 minutes. Thanks!
A: 

Export pages with Special:Export

Import pages using Special:Import. Not you have to have the 'import' user right to be able to import.

Adrian Archer
+1  A: 

You should do this with a bot. Bots can be run standalone, but if you're integrating with other code, you might want to pick based on the language. For PHP, there is the MediaWiki Bulk Page Creator. For Python, pymediawiki comes with Pagefromfile.

There is also an extension by Yaron Koren called External Data which solves a related task. It lets you incorporate data from external sources into your wiki pages. You can pull specific elements from CSV, XML or JSON -- retrieved from URLs, local files, or database.

Matt G