4 rfdir = 'rubyforge.org:/var/www/gforge-projects/rainbows/'
5 newbase = 'http://rainbows.bogomips.org/'
6 refresh = '<meta http-equiv="refresh" content="0; url=%s" />'
9 cmd = %W(rsync -av #{rfdir} #{old}/)
10 unless File.directory?(old)
11 system(*cmd) or abort "#{cmd.inspect} failed: #$?"
14 Find.find(old) do |path|
15 path =~ /\.html\z/ or next
16 data = File.read(path)
17 tmp = path.split(%r{/})
18 tmp.shift == old or abort "BUG"
19 dst = "#{new}/#{tmp.join('/')}"
21 tmp[-1] = '' if tmp[-1] == "index.html"
22 url = "#{newbase}#{tmp.join('/')}"
23 meta = sprintf(refresh, url)
24 data.sub!(/(<head[^>]*>)/i, "#$1#{meta}")
25 data.sub!(/(<body[^>]*>)/i,
26 "#{$1}Redirecting to <a href=\"#{url}\">#{url}</a> ...<br/>")
27 FileUtils.mkdir_p(File.dirname(dst))
28 File.open(dst, "w") { |fp| fp.write(data) }
31 print "Verify results in #{new}/, then run:\n "
32 puts %W(rsync -av #{new}/ #{rfdir}).join(' ')