a site that makes more sense
This commit is contained in:
		
							parent
							
								
									0a1de81462
								
							
						
					
					
						commit
						8e13d7f2f5
					
				
							
								
								
									
										60
									
								
								gather.rb
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								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 "<div id=\"challenge_header\">" | ||||
|   file.write "<h1>#{event}</h1>" | ||||
|   file.write File.read("challenges/#{event}/desc.html") | ||||
|   file.write "<a href=\"#{$PAGE_BASE}/how.html\">how can i join?</a>" | ||||
|   file.write "</div>" | ||||
| 
 | ||||
|   # solutions | ||||
|   file.write "<div id=\"solutions\">" | ||||
|   p_map.each do | ||||
|     |user, submissions| | ||||
|     file.print "<div class=\"card\"><h2>~#{user}</h2><ul>" | ||||
|     submissions.each do | ||||
|       |path| | ||||
|       name = path.split('/')[5] | ||||
|       file.print "<li>" | ||||
|       # 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>" | ||||
|   submissions(event) | ||||
|     .each do |path| | ||||
|       file.write "<div class=\"sol\">" | ||||
|       file.write "<h2>#{path.split('.')[-1]}, #{File.size path} bytes</h2>" | ||||
|       file.write "<pre>#{CGI::escapeHTML File.read path}</pre>" | ||||
|       file.write "<p class=\"source\">#{path.sub('/home/', '~')}</p>" | ||||
|       file.write "</div>" | ||||
|     end | ||||
|     file.print "</ul></div>\n" | ||||
|   end | ||||
| 
 | ||||
|   file.write "</div>" | ||||
| 
 | ||||
|   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 | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										56
									
								
								style.css
									
									
									
									
									
								
							
							
						
						
									
										56
									
								
								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; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -4,9 +4,13 @@ | ||||
| 		<meta charset="utf-8"> | ||||
| 		<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||||
| 		<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> | ||||
| 	<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/ | ||||
| 	</body> | ||||
| </html> | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user