#!/usr/bin/env ruby $PAGE_BASE = "http://tilde.town/~dzwdz/golf" $LOCAL_BASE = "/home/dzwdz/public_html/golf" def all_files(event) `ls -d /home/*/golf/#{event}/*` .lines .map(&:strip) end def submissions(event) all_files(event) .filter {|l| not l.end_with? '.hint'} end ## mirrors files into public_html/golf/[event name]/mirror/ def mirror(event) all_files(event) .each do |path| split = path.split('/') user = split[2] name = split[5] `mkdir -p #{$LOCAL_BASE}/#{event}/mirror/#{user}` begin File.symlink(path, "#{$LOCAL_BASE}/#{event}/mirror/#{user}/#{name}") rescue Errno::EEXIST end end end def challenge_page(event) # maps participants to their submissions p_map = Hash.new [] submissions(event) .each do |path| user = path.split('/')[2] p_map[user] += [path] end file = File.new("#{$LOCAL_BASE}/#{event}/index.html", 'w') p_map.each do |user, submissions| file.print "