2015-07-27 16:02:45 -05:00
|
|
|
# Importer for phpBB 3.0 and 3.1
|
|
|
|
# Documentation: https://meta.discourse.org/t/importing-from-phpbb3/30810
|
|
|
|
|
2015-07-05 16:17:03 -05: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 16:02:45 -05:00
|
|
|
STDERR.puts '', 'Still having problems? Take a look at https://meta.discourse.org/t/importing-from-phpbb3/30810'
|
2015-07-05 16:17:03 -05:00
|
|
|
exit 1
|
|
|
|
end
|
2014-10-07 15:47:17 -05:00
|
|
|
|
2015-07-05 16:17:03 -05:00
|
|
|
module ImportScripts
|
|
|
|
module PhpBB3
|
|
|
|
require_relative 'phpbb3/support/settings'
|
|
|
|
require_relative 'phpbb3/database/database'
|
2014-10-07 15:47:17 -05:00
|
|
|
|
2015-07-05 16:17:03 -05:00
|
|
|
@settings = Settings.load(ARGV[0])
|
2014-10-07 15:47:17 -05:00
|
|
|
|
2015-07-05 16:17:03 -05: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 13:33:01 -05:00
|
|
|
|
2015-07-05 16:17:03 -05:00
|
|
|
begin
|
|
|
|
@database = Database.create(@settings.database)
|
|
|
|
rescue UnsupportedVersionError => error
|
|
|
|
STDERR.puts '', error.message
|
|
|
|
exit 1
|
2014-10-19 13:33:01 -05:00
|
|
|
end
|
|
|
|
|
2015-07-05 16:17:03 -05:00
|
|
|
require_relative 'phpbb3/importer'
|
|
|
|
Importer.new(@settings, @database).perform
|
2014-07-04 15:05:15 -05:00
|
|
|
end
|
|
|
|
end
|