Skip to content
This repository was archived by the owner on Jan 9, 2023. It is now read-only.

Commit 0e34811

Browse files
committed
Whitespace and semi-colon cleanup.
Leave Ruby files with two space indents only; everything else as tabs only (most files had a bit of both). Semi-colons: add missing ones and remove redundant ones.
1 parent e1f6424 commit 0e34811

File tree

6 files changed

+55
-54
lines changed

6 files changed

+55
-54
lines changed

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ gem 'sinatra'
44
gem 'pony'
55

66
group :development do
7-
gem 'shotgun'
7+
gem 'shotgun'
88
end
99

1010
group :production do
11-
gem 'thin'
11+
gem 'thin'
1212
end

app.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
erb :contact
1515
end
1616

17-
post '/contact' do
17+
post '/contact' do
1818
require 'pony'
1919
Pony.mail(
2020
:from => params[:name] + " <" + params[:email] + ">",
@@ -23,14 +23,14 @@
2323
:body => params[:message],
2424
:via => :smtp,
2525
:via_options => {
26-
:address => 'smtp.' + settings.email_service,
27-
:port => '587',
28-
:enable_starttls_auto => true,
29-
:user_name => settings.email_username,
30-
:password => settings.email_password,
31-
:authentication => :plain,
26+
:address => 'smtp.' + settings.email_service,
27+
:port => '587',
28+
:enable_starttls_auto => true,
29+
:user_name => settings.email_username,
30+
:password => settings.email_password,
31+
:authentication => :plain,
3232
:domain => settings.email_domain
3333
}
3434
)
35-
'Many thanks for your mail!'
35+
'Many thanks for your mail!'
3636
end

public/css/style.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
form{padding: 1em;}
2-
#name{width: 25%;}
3-
#email{width: 25%;}
4-
#message{width: 50%;height:300px;}
5-
#ciphertext{width: 50%;height:100px;display:none;}
6-
.pure-form textarea[readonly] {background: #fff;border-color: #fff;}
1+
form {padding: 1em;}
2+
#name {width: 25%;}
3+
#email {width: 25%;}
4+
#message {width: 50%; height: 300px;}
5+
#ciphertext {width: 50%; height: 100px; display: none;}
6+
.pure-form textarea[readonly] {background: #fff; border-color: #fff;}

public/js/app.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
document.addEventListener('DOMContentLoaded', function(){
2-
if (window.crypto && window.crypto.getRandomValues) {
1+
document.addEventListener('DOMContentLoaded', function() {
2+
if (window.crypto && window.crypto.getRandomValues) {
33
// form ready
44
document.getElementById("name").focus();
55
var message = document.getElementById("message");
6-
var ciphertext = document.getElementById("ciphertext");
6+
var ciphertext = document.getElementById("ciphertext");
77
// encrypt on the fly
8-
message.addEventListener("input", function(){
9-
ciphertext.style.display = "block";
10-
ciphertext.value = cleanup(encrypt(message.value));
11-
});
8+
message.addEventListener("input", function() {
9+
ciphertext.style.display = "block";
10+
ciphertext.value = cleanup(encrypt(message.value));
11+
});
1212
// encrypt on submit
13-
document.forms[0].addEventListener("submit", function(evt){
14-
if( form.elements['message'].value == '') {
15-
evt.preventDefault();
16-
alert('Please enter a message!');
17-
} else {
18-
form.elements['message'].value = encrypt(message.value);
19-
return true
20-
}
21-
});
22-
} else {
13+
document.forms[0].addEventListener("submit", function(evt) {
14+
if( form.elements['message'].value == '') {
15+
evt.preventDefault();
16+
alert('Please enter a message!');
17+
} else {
18+
form.elements['message'].value = encrypt(message.value);
19+
return true;
20+
}
21+
});
22+
} else {
2323
// not ready
2424
document.getElementById("button").disabled = true;
25-
window.alert("Error: Browser not supported\nReason: We need a cryptographically secure PRNG to be implemented (i.e. the window.crypto method)\nSolution: Use Chrome >= 11, Safari >= 3.1, Firefox >= 21, Opera >= 15 or IE >= 11.");
26-
return false;
27-
}
25+
window.alert("Error: Browser not supported\nReason: We need a cryptographically secure PRNG to be implemented (i.e. the window.crypto method)\nSolution: Use Chrome >= 11, Safari >= 3.1, Firefox >= 21, Opera >= 15 or IE >= 11.");
26+
return false;
27+
}
2828
});
2929

3030
function cleanup(msg) {
@@ -33,9 +33,9 @@ function cleanup(msg) {
3333

3434
function encrypt(msg) {
3535
if (msg.indexOf("-----BEGIN PGP MESSAGE-----") !== -1 && msg.indexOf("-----END PGP MESSAGE-----") !== -1) {
36-
return msg;
36+
return msg;
3737
} else {
3838
var publickey = openpgp.key.readArmored(document.getElementById("pubkey").innerHTML).keys[0];
39-
return openpgp.encryptMessage([publickey],msg);;
40-
}
39+
return openpgp.encryptMessage([publickey],msg);
40+
}
4141
}

views/contact.erb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
<form id="form" class="pure-form pure-form-stacked" name="contact" method="post" action="/contact">
2-
<fieldset>
3-
<legend>Secure Contact Form</legend>
4-
<label for="name">Your Name</label>
5-
<input id="name" name="name" type="text" required>
6-
<label for="email">Your Email</label>
7-
<input id="email" name="email" type="email" required>
8-
<label for="message">Message</label>
9-
<textarea id="message" name="message"></textarea>
10-
<br />
11-
<button id="button" type="submit" class="pure-button pure-button-primary">Send</button>
12-
<br /><br />
13-
<textarea id="ciphertext" readonly></textarea>
14-
</fieldset>
1+
<form id="form" class="pure-form pure-form-stacked" name="contact" method="post" action="/contact">
2+
<fieldset>
3+
<legend>Secure Contact Form</legend>
4+
<label for="name">Your Name</label>
5+
<input id="name" name="name" type="text" required>
6+
<label for="email">Your Email</label>
7+
<input id="email" name="email" type="email" required>
8+
<label for="message">Message</label>
9+
<textarea id="message" name="message"></textarea>
10+
<br />
11+
<button id="button" type="submit" class="pure-button pure-button-primary">Send</button>
12+
<br />
13+
<br />
14+
<textarea id="ciphertext" readonly></textarea>
15+
</fieldset>
1516
</form>
1617
<!-- your pgp public key -->
1718
<div id="pubkey" hidden="true">

views/layout.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<title>Secure Contact Form</title>
4+
<title>Secure Contact Form</title>
55
<script src="/js/openpgp.min.js" type="text/javascript"></script>
66
<script src="/js/app.js" type="text/javascript"></script>
77
<link href="/css/pure-min.css" rel="stylesheet" >

0 commit comments

Comments
 (0)