index template

This commit is contained in:
Al Beano 2016-08-25 17:13:37 +01:00
parent be0ec1c8d7
commit d54340e067
3 changed files with 31 additions and 2 deletions

19
tormon/index.tt Normal file
View File

@ -0,0 +1,19 @@
<h1>Tor Relay/Bridge Monitor</h1>
<p>This is a simple service which sends emails when a Tor relay/bridge goes down. I built it after Tor's Weather service which also did this vanished mysteriously.</p>
<form action=subscribe method=post>
<label for=fp>Relay/bridge fingerprint to monitor:</label>
<input id=fp type=text name=fp>
<br />
<label for=email>Your email:</label>
<input id=email type=email name=email>
<br />
<!-- simple but effective anti-spam check -->
<label for=spam>What is the capital city of England?</label>
<input id=spam type=text name=spam>
<br />
<button action=submit>Submit</button>
</form>
<hr>
<p id="footer">
tormon version <% version %> by <a href="https://keybase.io/albino">albino</a> | for help, contact albino AT autistici DOT org
</p>

View File

@ -8,6 +8,8 @@ use File::Slurp;
use Template::Simple;
use FindBin qw($Bin);
my $VERSION = "1.0";
my $tmpl = new Template::Simple (
pre_delim => "<%",
post_delim => "%>",
@ -33,11 +35,13 @@ while ($request->Accept() <= 0) {
switch ($ENV{"REQUEST_URI"}) {
case "/debug" {
# TODO - remove this, it's a security vulnerability
use Data::Dumper;
$content = "<textarea>" . Dumper(\%ENV) . "</textarea>";
}
case "/" {
$content = "Hello, world!";
my $tt = read_file("$Bin/index.tt");
$content = ${ $tmpl->render($tt, {version => $VERSION}) };
}
}

View File

@ -3,7 +3,13 @@
<head>
<title>Tor Relay/Bridge Monitor</title>
<style>
body{margin:40px auto;max-width:650px;line-height:1.6;font-size:18px;color:#444;padding:0 10px;font-family: serif}h1,h2,h3{line-height:1.2}
body{margin:40px auto;max-width:650px;line-height:1.6;font-size:18px;color:#444;padding:0 10px;font-family: serif}
h1,h2,h3{line-height:1.2}
input{width: calc(30% - 20px);}
label{width: 70%;}
label, input{display: inline-block;}
form{margin-bottom: 30px}
#footer{margin-top: 0;color:#666;font-style:italic;font-size:12px;}
</style>
</head>
<body>