Project

General

Profile

Actions

Feature #1224

open

Import wiki pages from MediaWiki

Added by Carl Nygard over 16 years ago. Updated about 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Importers
Target version:
-
Start date:
2008-05-12
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Here's a rake task that will migrate pages from MediaWiki. It will prompt you for the required information, such as mediawiki database connection, target redmine project to translate pages into, target mediawiki page, redmine page author, and whether to use the mediawiki page target as a namespace base to translate multiple pages.

It will prompt you at each page to decide whether to translate the page or not. MediaWiki ':' separators are translated to '_' in redmine.

It won't download images from mediawiki, but it will translate the image tags, so you'll just have to attach the images to the page in redmine after it's been translated.

It also won't retain mediawiki in-line table formatting.

As always, fixes/improvements are welcome. This worked well enough for me, but obviously it doesn't cover absolutely everything.


Files

migrate_from_mediawiki.rake (12.5 KB) migrate_from_mediawiki.rake Carl Nygard, 2008-05-12 16:55
migrate_from_mediawiki.rake (12.7 KB) migrate_from_mediawiki.rake Carl Nygard, 2008-06-20 20:28
Actions #1

Updated by F T over 16 years ago

Hi,
thanks for the target. I get the following error trying import from mediawiki1.7 to redmine 0.7.1

Target project identifier [CommCore]: testwiki
Created Project: Testwiki
rake aborted!
uninitialized constant MWMigrate::TRACKER_BUG
/srv/redmine/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:263:in `load_missing_constant'
/srv/redmine/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:453:in `const_missing'
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:279:in `target_project_identifier'
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:350
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:332:in `prompt'
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:350
/usr/lib/ruby/1.8/rake.rb:387:in `call'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:387:in `each'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:357:in `invoke'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:350:in `invoke'
/usr/lib/ruby/1.8/rake.rb:1906:in `run'
/usr/lib/ruby/1.8/rake.rb:1906:in `each'
/usr/lib/ruby/1.8/rake.rb:1906:in `run'
/usr/bin/rake:4
Actions #2

Updated by Carl Nygard over 16 years ago

Updated code. Sorry, I never used the bit that creates a new project...

Actions #3

Updated by F T over 16 years ago

Hi,
I can go trough the wizard but I get the following error at the end:

WARNING: a new project will be added to Redmine during this process.
Are you sure you want to continue ? [y/N] y

MW directory [/var/www/html/mediawiki-1.8.2]: /var/lib/mediawiki/
MW database adapter (sqlite, sqlite3, mysql, postgresql) [mysql]: postgresql
MW database host [localhost]: *IP_host*
MW database port []: 5432
MW database socket []: 
MW database name [wikidb]: *wikidb_name*
MW database username [wiki]: *username*
MW database password [wikidb]: *password*
MW database encoding [UTF-8]: 
Target project identifier [CommCore]: commcore3
Created Project: Commcore3
MW Page Title [CommCore:Devel:XMLDB]: Main_Page
Page Author [carlnygard@fortna.com]: *new_mail*
Whole namespace (Y/n)? [y]: y

No wiki defined
Migrating Main_Page, 1 of 259 pages
Translate Reserve_windows (y/N)? y
rake aborted!
PGError: ERROR:  relation "text" does not exist
:             SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
              FROM pg_attribute a LEFT JOIN pg_attrdef d
                ON a.attrelid = d.adrelid AND a.attnum = d.adnum
             WHERE a.attrelid = 'text'::regclass
               AND a.attnum > 0 AND NOT a.attisdropped
             ORDER BY a.attnum
/srv/redmine/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'
/srv/redmine/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:395:in `query'
/srv/redmine/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:836:in `column_definitions'
/srv/redmine/vendor/rails/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:485:in `columns'
/srv/redmine/vendor/rails/activerecord/lib/active_record/base.rb:1080:in `columns'
/srv/redmine/vendor/rails/activerecord/lib/active_record/base.rb:1088:in `columns_hash'
/srv/redmine/vendor/rails/activerecord/lib/active_record/base.rb:1259:in `find_one'
/srv/redmine/vendor/rails/activerecord/lib/active_record/base.rb:1250:in `find_from_ids'
/srv/redmine/vendor/rails/activerecord/lib/active_record/base.rb:504:in `find'
/srv/redmine/vendor/rails/activerecord/lib/active_record/associations/belongs_to_association.rb:44:in `find_target'
/srv/redmine/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:133:in `load_target'
/srv/redmine/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:55:in `reload'
/srv/redmine/vendor/rails/activerecord/lib/active_record/associations.rb:992:in `text'
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:176:in `migrate'
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:168:in `each'
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:168:in `migrate'
/srv/redmine/lib/tasks/migrate_from_mediawiki.rake:360
/usr/lib/ruby/1.8/rake.rb:387:in `call'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:387:in `each'
/usr/lib/ruby/1.8/rake.rb:387:in `execute'
/usr/lib/ruby/1.8/rake.rb:357:in `invoke'
/usr/lib/ruby/1.8/thread.rb:135:in `synchronize'
/usr/lib/ruby/1.8/rake.rb:350:in `invoke'
/usr/lib/ruby/1.8/rake.rb:1906:in `run'
/usr/lib/ruby/1.8/rake.rb:1906:in `each'
/usr/lib/ruby/1.8/rake.rb:1906:in `run'
/usr/bin/rake:4

If I answer 'No' to the last question the script ask to translate the next page and so on. I executed the import on mediawiki 1.12 and 1.9

A big thank for your time.

Actions #4

Updated by Carl Nygard over 16 years ago

The script was written agains MW 1.8.2. Most likely they have changed the schema from what I coded. You'll have to download the mediawiki schema document and sort things out for yourself. You may even need to change the script, depending on what they've changed in the schema.

Actions #5

Updated by Thomas Capricelli about 16 years ago

I think this ticket is obsolete. The script maybe work only for some very old version of mediawiki.

Actions #6

Updated by Jean-Philippe Lang about 16 years ago

  • Target version deleted (0.8)
Actions #7

Updated by Benjamin Schunn about 8 years ago

could that be closed?

Actions

Also available in: Atom PDF