Add registration page and mechanism for OpenCL contest.
This commit is contained in:
parent
f3121aaf96
commit
dd6f529919
|
@ -0,0 +1,2 @@
|
|||
AddHandler cgi-script .cgi
|
||||
Options +Indexes +ExecCGI
|
|
@ -1,3 +1,3 @@
|
|||
FILES = index.html register.html
|
||||
FILES = index.html register.html register-fail.html register-success.html register.cgi .htaccess
|
||||
RELDIR = opencl/
|
||||
include ../common.mk
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version='1.0'?>
|
||||
|
||||
<!DOCTYPE cscpage SYSTEM "../csc.dtd">
|
||||
|
||||
<cscpage title="CSC/AMD OpenCL Competition Registration">
|
||||
<header />
|
||||
|
||||
<section title="CSC/AMD OpenCL Competition Registration">
|
||||
<p>
|
||||
|
||||
You didn't fill out all required information on the registration form. Please <a href="register">try again</a>.
|
||||
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<footer />
|
||||
</cscpage>
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version='1.0'?>
|
||||
|
||||
<!DOCTYPE cscpage SYSTEM "../csc.dtd">
|
||||
|
||||
<cscpage title="CSC/AMD OpenCL Competition Registration">
|
||||
<header />
|
||||
|
||||
<section title="CSC/AMD OpenCL Competition Registration">
|
||||
<p>
|
||||
|
||||
Thank you for registering to participate. Your information has been recorded, and we will be contacting you shortly with further instructions.
|
||||
|
||||
</p>
|
||||
</section>
|
||||
|
||||
<footer />
|
||||
</cscpage>
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env racket
|
||||
#lang racket
|
||||
(require srfi/98)
|
||||
(require net/uri-codec)
|
||||
(require net/smtp)
|
||||
|
||||
(define ERROR-HEADER "Location: http://csclub.uwaterloo.ca/opencl/register-fail\n\n")
|
||||
(define SUCCESS-HEADER "Location: http://csclub.uwaterloo.ca/opencl/register-success\n\n")
|
||||
|
||||
(define (is-user? str) (equal? (list str) (regexp-match #rx"[A-Za-z0-9._]+" str)))
|
||||
(define (is-email? str) (equal? (list str) (regexp-match #rx"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+" str)))
|
||||
|
||||
(define required-fields `( (quest . ,is-user?) (email . ,is-email?)))
|
||||
(define check-fields '(team open closed))
|
||||
|
||||
(define (identity x) x)
|
||||
|
||||
(let*
|
||||
((post-data (form-urlencoded->alist (port->string)))
|
||||
(required-extract
|
||||
(map
|
||||
(lambda(x) (let ((e (assoc (car x) post-data)))
|
||||
(cond [(false? e) #f]
|
||||
[((cdr x) (cdr e)) e]
|
||||
[else #f])))
|
||||
required-fields))
|
||||
(check-extract (filter identity (map ((curryr assoc) post-data) check-fields)))
|
||||
(filled-out? (andmap identity required-extract)))
|
||||
(when (not filled-out?)
|
||||
(printf ERROR-HEADER)
|
||||
(exit 0))
|
||||
(smtp-send-message
|
||||
"caffeine.csclub.uwaterloo.ca"
|
||||
"opencl-contest-registration@csclub"
|
||||
(list "init512@gmail.com")
|
||||
"Subject: Contestant registered!\n\n"
|
||||
(list (with-output-to-string
|
||||
(lambda() (write (append required-extract check-extract))))))
|
||||
(printf SUCCESS-HEADER)
|
||||
(exit 0))
|
||||
|
|
@ -7,7 +7,28 @@
|
|||
|
||||
<section title="CSC/AMD OpenCL Competition Registration">
|
||||
<p>
|
||||
Registration will open on the 16th of February.
|
||||
|
||||
<form action="register.cgi" method="post">
|
||||
<table cellpadding="5px">
|
||||
<tr>
|
||||
<td>Quest ID:</td><td><input type="text" name="quest" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Email:</td><td><input type="text" name="email" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Are you participating with a team?</td><td><input type="checkbox" name="team" value="yes" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Problem type:</td><td><input type="checkbox" name="open" value="yes" /> Open Submission
|
||||
<input type="checkbox" name="closed" value="yes" /> Problem Set</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td><td><input type="submit" name="Register" value="Register" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
|
Loading…
Reference in New Issue