2015-07-27 17:02:45 -04:00
|
|
|
# Importer for phpBB 3.0 and 3.1
|
|
|
|
# Documentation: https://meta.discourse.org/t/importing-from-phpbb3/30810
|
|
|
|
|
2015-07-05 17:17:03 -04:00
|
|
|
if ARGV.length != 1 || !File.exists?(ARGV[0])
|
|
|
|
STDERR.puts '', 'Usage of phpBB3 importer:', 'bundle exec ruby phpbb3.rb <path/to/settings.yml>'
|
|
|
|
STDERR.puts '', "Use the settings file from #{File.expand_path('phpbb3/settings.yml', File.dirname(__FILE__))} as an example."
|
2015-07-27 17:02:45 -04:00
|
|
|
STDERR.puts '', 'Still having problems? Take a look at https://meta.discourse.org/t/importing-from-phpbb3/30810'
|
2015-07-05 17:17:03 -04:00
|
|
|
exit 1
|
|
|
|
end
|
2014-10-07 16:47:17 -04:00
|
|
|
|
2015-07-05 17:17:03 -04:00
|
|
|
module ImportScripts
|
|
|
|
module PhpBB3
|
|
|
|
require_relative 'phpbb3/support/settings'
|
|
|
|
require_relative 'phpbb3/database/database'
|
2014-10-07 16:47:17 -04:00
|
|
|
|
2015-07-05 17:17:03 -04:00
|
|
|
@settings = Settings.load(ARGV[0])
|
2014-10-07 16:47:17 -04:00
|
|
|
|
2015-07-05 17:17:03 -04:00
|
|
|
# We need to load the gem files for ruby-bbcode-to-md and the database adapter
|
|
|
|
# (e.g. mysql2) before bundler gets initialized by the base importer.
|
|
|
|
# Otherwise we get an error since those gems are not always in the Gemfile.
|
|
|
|
require 'ruby-bbcode-to-md' if @settings.use_bbcode_to_md
|
2014-10-19 14:33:01 -04:00
|
|
|
|
2015-07-05 17:17:03 -04:00
|
|
|
begin
|
|
|
|
@database = Database.create(@settings.database)
|
|
|
|
rescue UnsupportedVersionError => error
|
|
|
|
STDERR.puts '', error.message
|
|
|
|
exit 1
|
2014-10-19 14:33:01 -04:00
|
|
|
end
|
|
|
|
|
2015-07-05 17:17:03 -04:00
|
|
|
require_relative 'phpbb3/importer'
|
|
|
|
Importer.new(@settings, @database).perform
|
2014-07-04 16:05:15 -04:00
|
|
|
end
|
|
|
|
end
|