Set a couple of props on script/import_storage to prepare for the next
checkin...
This commit is contained in:
parent
e5b7037259
commit
0238780355
188
script/import_storage
Normal file → Executable file
188
script/import_storage
Normal file → Executable file
|
@ -1,94 +1,94 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'optparse'
|
||||
|
||||
OPTIONS = {
|
||||
:instiki_root => nil,
|
||||
:storage => nil,
|
||||
}
|
||||
|
||||
ARGV.options do |opts|
|
||||
script_name = File.basename($0)
|
||||
opts.banner = "Usage: ruby #{script_name} [options]"
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on("-t", "--storage /full/path/to/storage", String,
|
||||
"Full path to your storage, ",
|
||||
"such as /home/joe/instiki/storage/2500",
|
||||
"It should be the directory that ",
|
||||
"contains .snapshot files.") do |storage|
|
||||
OPTIONS[:storage] = storage
|
||||
end
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on("-i", "--instiki /full/path/to/instiki", String,
|
||||
"Full path to your Instiki installation, ",
|
||||
"such as /home/joe/instiki") do |instiki|
|
||||
OPTIONS[:instiki] = instiki
|
||||
end
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on_tail("-h", "--help",
|
||||
"Show this help message.") { puts opts; exit }
|
||||
|
||||
opts.parse!
|
||||
end
|
||||
|
||||
if OPTIONS[:instiki].nil? or OPTIONS[:storage].nil?
|
||||
$stderr.puts "Please specify full paths to Instiki installation and storage"
|
||||
$stderr.puts
|
||||
puts ARGV.options
|
||||
exit -1
|
||||
end
|
||||
|
||||
raise "Directory #{OPTIONS[:instiki]} not found" unless File.directory?(OPTIONS[:instiki])
|
||||
raise "Directory #{OPTIONS[:storage]} not found" unless File.directory?(OPTIONS[:storage])
|
||||
|
||||
expected_page_rb_path = File.join(OPTIONS[:instiki], 'app/models/page.rb')
|
||||
raise "Instiki installation not found in #{OPTIONS[:instiki]}" unless File.file?(expected_page_rb_path)
|
||||
|
||||
expected_snapshot_pattern = File.join(OPTIONS[:storage], '*.snapshot')
|
||||
raise "No snapshots found in OPTIONS[:storage]" if Dir[expected_snapshot_pattern].empty?
|
||||
|
||||
INSTIKI_ROOT = File.expand_path(OPTIONS[:instiki])
|
||||
|
||||
ADDITIONAL_LOAD_PATHS = %w(
|
||||
app/models
|
||||
lib
|
||||
vendor/madeleine-0.7.1/lib
|
||||
vendor/RedCloth-3.0.3/lib
|
||||
vendor/rubyzip-0.5.8/lib
|
||||
).map { |dir| "#{File.expand_path(File.join(INSTIKI_ROOT, dir))}"
|
||||
}.delete_if { |dir| not File.exist?(dir) }
|
||||
|
||||
# Prepend to $LOAD_PATH
|
||||
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
||||
|
||||
require 'webrick'
|
||||
require 'wiki_service'
|
||||
|
||||
class Revision
|
||||
alias :__display_content :display_content
|
||||
def display_content
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
WikiService.storage_path = OPTIONS[:storage]
|
||||
wiki = WikiService.instance
|
||||
|
||||
wiki.webs.each_pair do |web_name, web|
|
||||
# INSERT INTO webs goes here
|
||||
puts "Web #{web_name} has #{web.pages.keys.size} pages"
|
||||
web.pages.each_pair do |page_name, page|
|
||||
# INSERT INTO pages goes here
|
||||
puts " Page #{page_name} has #{page.revisions.size} revisions"
|
||||
page.revisions.each_with_index do |rev, i|
|
||||
# INSERT INTO revisions goes here
|
||||
puts " Revision #{i} created at #{rev.created_at}"
|
||||
end
|
||||
end
|
||||
end
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'optparse'
|
||||
|
||||
OPTIONS = {
|
||||
:instiki_root => nil,
|
||||
:storage => nil,
|
||||
}
|
||||
|
||||
ARGV.options do |opts|
|
||||
script_name = File.basename($0)
|
||||
opts.banner = "Usage: ruby #{script_name} [options]"
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on("-t", "--storage /full/path/to/storage", String,
|
||||
"Full path to your storage, ",
|
||||
"such as /home/joe/instiki/storage/2500",
|
||||
"It should be the directory that ",
|
||||
"contains .snapshot files.") do |storage|
|
||||
OPTIONS[:storage] = storage
|
||||
end
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on("-i", "--instiki /full/path/to/instiki", String,
|
||||
"Full path to your Instiki installation, ",
|
||||
"such as /home/joe/instiki") do |instiki|
|
||||
OPTIONS[:instiki] = instiki
|
||||
end
|
||||
|
||||
opts.separator ""
|
||||
|
||||
opts.on_tail("-h", "--help",
|
||||
"Show this help message.") { puts opts; exit }
|
||||
|
||||
opts.parse!
|
||||
end
|
||||
|
||||
if OPTIONS[:instiki].nil? or OPTIONS[:storage].nil?
|
||||
$stderr.puts "Please specify full paths to Instiki installation and storage"
|
||||
$stderr.puts
|
||||
puts ARGV.options
|
||||
exit -1
|
||||
end
|
||||
|
||||
raise "Directory #{OPTIONS[:instiki]} not found" unless File.directory?(OPTIONS[:instiki])
|
||||
raise "Directory #{OPTIONS[:storage]} not found" unless File.directory?(OPTIONS[:storage])
|
||||
|
||||
expected_page_rb_path = File.join(OPTIONS[:instiki], 'app/models/page.rb')
|
||||
raise "Instiki installation not found in #{OPTIONS[:instiki]}" unless File.file?(expected_page_rb_path)
|
||||
|
||||
expected_snapshot_pattern = File.join(OPTIONS[:storage], '*.snapshot')
|
||||
raise "No snapshots found in OPTIONS[:storage]" if Dir[expected_snapshot_pattern].empty?
|
||||
|
||||
INSTIKI_ROOT = File.expand_path(OPTIONS[:instiki])
|
||||
|
||||
ADDITIONAL_LOAD_PATHS = %w(
|
||||
app/models
|
||||
lib
|
||||
vendor/madeleine-0.7.1/lib
|
||||
vendor/RedCloth-3.0.3/lib
|
||||
vendor/rubyzip-0.5.8/lib
|
||||
).map { |dir| "#{File.expand_path(File.join(INSTIKI_ROOT, dir))}"
|
||||
}.delete_if { |dir| not File.exist?(dir) }
|
||||
|
||||
# Prepend to $LOAD_PATH
|
||||
ADDITIONAL_LOAD_PATHS.reverse.each { |dir| $:.unshift(dir) if File.directory?(dir) }
|
||||
|
||||
require 'webrick'
|
||||
require 'wiki_service'
|
||||
|
||||
class Revision
|
||||
alias :__display_content :display_content
|
||||
def display_content
|
||||
return self
|
||||
end
|
||||
end
|
||||
|
||||
WikiService.storage_path = OPTIONS[:storage]
|
||||
wiki = WikiService.instance
|
||||
|
||||
wiki.webs.each_pair do |web_name, web|
|
||||
# INSERT INTO webs goes here
|
||||
puts "Web #{web_name} has #{web.pages.keys.size} pages"
|
||||
web.pages.each_pair do |page_name, page|
|
||||
# INSERT INTO pages goes here
|
||||
puts " Page #{page_name} has #{page.revisions.size} revisions"
|
||||
page.revisions.each_with_index do |rev, i|
|
||||
# INSERT INTO revisions goes here
|
||||
puts " Revision #{i} created at #{rev.created_at}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue