a site that makes more sense
parent
0a1de81462
commit
8e13d7f2f5
60
gather.rb
60
gather.rb
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
require 'cgi'
|
||||||
|
|
||||||
$PAGE_BASE = "http://tilde.town/~dzwdz/golf"
|
$PAGE_BASE = "http://tilde.town/~dzwdz/golf"
|
||||||
$LOCAL_BASE = "/home/dzwdz/public_html/golf"
|
$LOCAL_BASE = "/home/dzwdz/public_html/golf"
|
||||||
|
@ -16,36 +17,7 @@ def submissions(event)
|
||||||
.filter {|l| not l.end_with? '.hint'}
|
.filter {|l| not l.end_with? '.hint'}
|
||||||
end
|
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)
|
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
|
|
||||||
|
|
||||||
# temporary
|
|
||||||
p_map["dzwdz1"] = p_map["dzwdz"]
|
|
||||||
p_map["dzwdz2"] = p_map["dzwdz"]
|
|
||||||
p_map["dzwdz3"] = p_map["dzwdz"]
|
|
||||||
|
|
||||||
file = File.new("#{$LOCAL_BASE}/#{event}/index.html", 'w')
|
file = File.new("#{$LOCAL_BASE}/#{event}/index.html", 'w')
|
||||||
file.write $HTML_HEAD
|
file.write $HTML_HEAD
|
||||||
|
|
||||||
|
@ -53,32 +25,19 @@ def challenge_page(event)
|
||||||
file.write "<div id=\"challenge_header\">"
|
file.write "<div id=\"challenge_header\">"
|
||||||
file.write "<h1>#{event}</h1>"
|
file.write "<h1>#{event}</h1>"
|
||||||
file.write File.read("challenges/#{event}/desc.html")
|
file.write File.read("challenges/#{event}/desc.html")
|
||||||
file.write "<a href=\"#{$PAGE_BASE}/how.html\">how can i join?</a>"
|
|
||||||
file.write "</div>"
|
file.write "</div>"
|
||||||
|
|
||||||
# solutions
|
# solutions
|
||||||
file.write "<div id=\"solutions\">"
|
file.write "<div id=\"solutions\">"
|
||||||
p_map.each do
|
submissions(event)
|
||||||
|user, submissions|
|
.each do |path|
|
||||||
file.print "<div class=\"card\"><h2>~#{user}</h2><ul>"
|
file.write "<div class=\"sol\">"
|
||||||
submissions.each do
|
file.write "<h2>#{path.split('.')[-1]}, #{File.size path} bytes</h2>"
|
||||||
|path|
|
file.write "<pre>#{CGI::escapeHTML File.read path}</pre>"
|
||||||
name = path.split('/')[5]
|
file.write "<p class=\"source\">#{path.sub('/home/', '~')}</p>"
|
||||||
file.print "<li>"
|
file.write "</div>"
|
||||||
# todo this has a million vulns
|
|
||||||
# also it's a mess
|
|
||||||
file.print "<a href=\"#{$PAGE_BASE}/#{event}/mirror/#{user}/#{name}\">"
|
|
||||||
file.print "#{name}"
|
|
||||||
file.print "</a> (#{File.size path}b)"
|
|
||||||
hint = path + '.hint'
|
|
||||||
# speaking of messes
|
|
||||||
if File.exists? hint
|
|
||||||
file.print "<a class=\"hint\" href=\"#{$PAGE_BASE}/#{event}/mirror/#{user}/#{name}.hint\">hint</a>"
|
|
||||||
end
|
|
||||||
file.print "</li>"
|
|
||||||
end
|
end
|
||||||
file.print "</ul></div>\n"
|
|
||||||
end
|
|
||||||
file.write "</div>"
|
file.write "</div>"
|
||||||
|
|
||||||
file.write $HTML_FOOT
|
file.write $HTML_FOOT
|
||||||
|
@ -96,7 +55,6 @@ end
|
||||||
|
|
||||||
Dir['challenges/*'].each do |path|
|
Dir['challenges/*'].each do |path|
|
||||||
name = path.split('/', 2)[-1]
|
name = path.split('/', 2)[-1]
|
||||||
mirror name
|
|
||||||
challenge_page name
|
challenge_page name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
56
style.css
56
style.css
|
@ -4,24 +4,8 @@ body {
|
||||||
font-family: mono;
|
font-family: mono;
|
||||||
background: #32302f;
|
background: #32302f;
|
||||||
color: #f2e5bc;
|
color: #f2e5bc;
|
||||||
}
|
max-width: 90ch;
|
||||||
|
margin: auto;
|
||||||
a { color: #83a598 }
|
|
||||||
|
|
||||||
#solutions {
|
|
||||||
display: grid;
|
|
||||||
align-items: center;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(25em, 1fr));
|
|
||||||
}
|
|
||||||
|
|
||||||
.card {
|
|
||||||
margin: .5em;
|
|
||||||
background: #504945;
|
|
||||||
padding: .3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card ul {
|
|
||||||
padding: 0 1em 0 1em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
@ -29,5 +13,39 @@ h2 {
|
||||||
background: #b16286;
|
background: #b16286;
|
||||||
}
|
}
|
||||||
|
|
||||||
.hint {float: right}
|
a { color: #83a598 }
|
||||||
|
|
||||||
|
|
||||||
|
.sol {
|
||||||
|
margin: 1ch;
|
||||||
|
background: #504945;
|
||||||
|
padding: .3em;
|
||||||
|
box-shadow: .2em .2em .2em #0005;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sol pre {
|
||||||
|
border-left: 1px solid;
|
||||||
|
padding-left: .5em;
|
||||||
|
margin: .5em 0 .5em;
|
||||||
|
font-family: mono;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sol .source {
|
||||||
|
margin: 0;
|
||||||
|
text-align: right;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
background: #504945;
|
||||||
|
padding: .3em 2ch .3em 2ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
header a {color: #f2e5bc}
|
||||||
|
|
||||||
|
header a:last-child {
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,13 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>~town golf</title>
|
<title>~town golf</title>
|
||||||
<link rel="stylesheet" href="http://tilde.town/~dzwdz/golf/style.css">
|
<link rel="stylesheet" href="https://tilde.town/~dzwdz/golf/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<header>
|
||||||
|
<a href="https://tilde.town/~dzwdz/golf/">~town golf</a>
|
||||||
|
<a href="https://tilde.town/~dzwdz/golf/how.html">how does this work?</a>
|
||||||
|
</header>
|
||||||
/snip/
|
/snip/
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue