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