From 8e13d7f2f53dc6eabd171fec7c63d27c5a509555 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 28 Mar 2021 21:32:28 +0000 Subject: [PATCH] a site that makes more sense --- gather.rb | 60 ++++++++------------------------------------------- style.css | 56 +++++++++++++++++++++++++++++++---------------- template.html | 6 +++++- 3 files changed, 51 insertions(+), 71 deletions(-) diff --git a/gather.rb b/gather.rb index f3bea21..c55cddc 100755 --- a/gather.rb +++ b/gather.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +require 'cgi' $PAGE_BASE = "http://tilde.town/~dzwdz/golf" $LOCAL_BASE = "/home/dzwdz/public_html/golf" @@ -16,36 +17,7 @@ def submissions(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 - - # 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.write $HTML_HEAD @@ -53,32 +25,19 @@ def challenge_page(event) file.write "
" file.write "

#{event}

" file.write File.read("challenges/#{event}/desc.html") - file.write "how can i join?" file.write "
" # solutions file.write "
" - p_map.each do - |user, submissions| - file.print "

~#{user}

    " - submissions.each do - |path| - name = path.split('/')[5] - file.print "
  • " - # todo this has a million vulns - # also it's a mess - file.print "" - file.print "#{name}" - file.print " (#{File.size path}b)" - hint = path + '.hint' - # speaking of messes - if File.exists? hint - file.print "hint" - end - file.print "
  • " + submissions(event) + .each do |path| + file.write "
    " + file.write "

    #{path.split('.')[-1]}, #{File.size path} bytes

    " + file.write "
    #{CGI::escapeHTML File.read path}
    " + file.write "

    #{path.sub('/home/', '~')}

    " + file.write "
    " end - file.print "
\n" - end + file.write "
" file.write $HTML_FOOT @@ -96,7 +55,6 @@ end Dir['challenges/*'].each do |path| name = path.split('/', 2)[-1] - mirror name challenge_page name end diff --git a/style.css b/style.css index 0a9780e..3cfa6f1 100644 --- a/style.css +++ b/style.css @@ -4,24 +4,8 @@ body { font-family: mono; background: #32302f; color: #f2e5bc; -} - -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; + max-width: 90ch; + margin: auto; } h2 { @@ -29,5 +13,39 @@ h2 { 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; +} + diff --git a/template.html b/template.html index b4a05cd..e0dce1d 100644 --- a/template.html +++ b/template.html @@ -4,9 +4,13 @@ ~town golf - + +
+~town golf +how does this work? +
/snip/