This repository has been archived by the owner on Feb 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Escape input emails * Add basic template engine * Add basic noscript fallback * Change folder structure and add fallbacks * Add static files * Prettify using CSS * Add JS For a single template * Extract css and js to dedicated files * Move stuff to template * Add frontend * Trim whitespace * Add verification Email-Template * Re-Enable button after success * Split Layout * Add dice template * Fix template * Please checkstyle * Use different config file for public directory * Add full stop * Add more accurate email validation * Remove unecessary escape to please eslint
- Loading branch information
Showing
23 changed files
with
309 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"extends": "airbnb-base" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "airbnb-base", | ||
"env": { | ||
"browser": true, | ||
"node": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>{{ subject }}</title> | ||
<style media="screen"> | ||
a.big { | ||
text-align: center; | ||
} | ||
a.big:link, a.big:visited { | ||
background-color: #B8242B; | ||
color: white; | ||
padding: 14px 25px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: inline-block; | ||
} | ||
a.big:hover, a.big:active { | ||
background-color: #8D1C21; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
{% block -%}{%- endblock %} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<br> | ||
<footer> | ||
<p>This email was sent automatically, if it wasn't you who requested this email, please ignore it.</p> | ||
<p>You can always unsubscribe <a href="{{ unsub }}">here</a>.</p> | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% layout 'base' %} | ||
<h1>The dice have been cast!</h1> | ||
<p>Roll-Time: {{ date }}</p> | ||
<p>Results: {{ dice }}</p> | ||
<br> | ||
<p>You can click below to verify your results:</p> | ||
<a class="big" href="{{ url }}">Verify!</a> | ||
<br> | ||
<p>Note we might not be able to correctly verify integrity for very old (1+ years) dice rolls.</p> | ||
{% include 'footer' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% layout 'base' %} | ||
<h1>Verify your Email on {{ host }}</h1> | ||
<p>You (or someone else prententing to be you) recently registered this email to be used for the dice rolling service.</p> | ||
<p>In order to allow you to use this service you need to click 'Confirm!' below:</p> | ||
<a class="big" href="{{ url }}">Confirm!</a> | ||
<p>Note: The link expires after 24 hours or when a new confirmation email is sent.</p> | ||
{% include 'footer' %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{% include 'submit-button' %} | ||
<span id="error-display" style="display: none; text-align: center;"></span> | ||
<script type="text/javascript" src="./js/ajax-form.js"></script> | ||
<script type="text/javascript"> | ||
registerForm( | ||
'{{ formId }}', | ||
'submit-button', | ||
'error-display', | ||
'{{ method }}', | ||
'{{ url }}', | ||
'{{ buttonText }}', | ||
'Success!'); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" dir="ltr"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>{{title}} | TripleA Dice Server</title> | ||
<link rel="stylesheet" type="text/css" href="./css/base.css"> | ||
</head> | ||
<body> | ||
<div class="center"> | ||
<h1>{{title}}</h1> | ||
{% block -%}{%- endblock %} | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="extended"> | ||
<div class="button-center"> | ||
<button id="submit-button" type="submit" name="button">{{ buttonText }}</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
button { | ||
background-color: #B8242B; | ||
border: none; | ||
color: white; | ||
padding: 15px 32px; | ||
text-align: center; | ||
text-decoration: none; | ||
display: inline-block; | ||
font-size: 16px; | ||
} | ||
button:disabled { | ||
background-color: #B8242B7F; | ||
} | ||
button:hover:not(:disabled) { | ||
background-color: #8D1C21; | ||
color: #EEE; | ||
} | ||
input[type=text], input[type=email]{ | ||
width: 100%; | ||
padding: 12px 20px; | ||
margin: 8px 0; | ||
box-sizing: border-box; | ||
} | ||
.center { | ||
margin: auto; | ||
width: 50%; | ||
padding: 10%; | ||
} | ||
.button-center { | ||
margin: auto; | ||
width: 50%; | ||
text-align: center; | ||
} | ||
h1 { | ||
width: 100%; | ||
text-align: center; | ||
} | ||
.extended { | ||
width: 100%; | ||
} | ||
.lds-dual-ring { | ||
display: inline-block; | ||
width: 32px; | ||
height: 32px; | ||
} | ||
.lds-dual-ring:after { | ||
content: " "; | ||
display: block; | ||
width: 23px; | ||
height: 23px; | ||
margin: 1px; | ||
border-radius: 50%; | ||
border: 5px solid #fff; | ||
border-color: #fff transparent #fff transparent; | ||
animation: lds-dual-ring 1.2s linear infinite; | ||
} | ||
@keyframes lds-dual-ring { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
window.registerForm = (formId, buttonId, errorDisplayId, method, url, text, successText) => { | ||
const form = document.getElementById(formId); | ||
const button = document.getElementById(buttonId); | ||
const errorDisplay = document.getElementById(errorDisplayId); | ||
form.addEventListener('submit', (event) => { | ||
event.preventDefault(); | ||
const formData = new FormData(form); | ||
button.disabled = true; | ||
button.value = ''; | ||
button.innerHTML = '<div class="lds-dual-ring"></div>'; | ||
const request = new XMLHttpRequest(); | ||
request.addEventListener('load', (serverResponse) => { | ||
const response = JSON.parse(serverResponse.target.responseText); | ||
if (response.status === 'OK') { | ||
errorDisplay.style.display = 'none'; | ||
button.innerHTML = successText; | ||
button.disabled = false; | ||
} else { | ||
errorDisplay.style.display = 'block'; | ||
errorDisplay.innerHTML = response.errors.join('<br>'); | ||
button.disabled = false; | ||
button.innerHTML = text; | ||
} | ||
}); | ||
request.open(method, url); | ||
// urlencode the FormData | ||
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | ||
request.send([...formData.entries()].map(e => `${encodeURIComponent(e[0])}=${encodeURIComponent(e[1])}`).join('&')); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
User-agent: * | ||
Disallow: / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{%- layout 'layout', title: 'Confirm Registration' -%} | ||
{%- if email and token -%} | ||
{%- capture url %}./api/register/{{ token }}{% endcapture -%} | ||
{%- assign method = 'POST' -%} | ||
{%- assign formId = 'form' -%} | ||
<form id="{{ formId }}" action="{{ url }}" method="{{ method }}"> | ||
<input type="hidden" name="email" value="{{ email }}" required> | ||
{% include 'form-ajaxify', buttonText: 'Confirm Registration!' %} | ||
</form> | ||
{%- else -%} | ||
<h2>Invalid Arguments!</h2> | ||
{%- endif -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{%- layout 'layout', title: 'Register for the Dice-Server' -%} | ||
{%- assign url ='./api/register' -%} | ||
{%- assign method = 'POST' -%} | ||
{%- assign formId = 'form' -%} | ||
<form id="{{ formId }}" action="{{ url }}" method="{{ method }}"> | ||
<input type="email" name="email" placeholder="Insert your email adress" required> | ||
{% include 'form-ajaxify', buttonText: 'Register!', formId: 'form' %} | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{%- layout 'layout', title: 'Unregister from the dice Server' -%} | ||
{%- assign url ='./api/unregister' -%} | ||
{%- assign method = 'POST' -%} | ||
{%- assign formId = 'form' -%} | ||
|
||
<form id="{{ formId }}" action="{{ url }}" method="{{ method }}"> | ||
<input type="email" name="email" placeholder="Insert your email adress" value="{{ email }}" required> | ||
{% include 'form-ajaxify', buttonText: 'Unregister!' %} | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{%- layout 'layout', title: 'Verify your dice' %} | ||
{%- if invalid -%} | ||
<h2>Invalid link!</h2> | ||
{%- elsif token and dice and date -%} | ||
{%- capture url %}./api/verify/{{ token }}{% endcapture -%} | ||
{%- assign method = 'GET' -%} | ||
{%- assign formId = 'form' -%} | ||
<form id="{{ formId }}" action="{{ url }}" method="{{ method }}"> | ||
<p>Dice Rolled: {{ dice | join: ", " }}</p> | ||
<p>At {{ date | date: "%a, %b %d, %y" }}</p> | ||
{% include 'form-ajaxify', buttonText: 'Verify!' %} | ||
</form> | ||
{%- else -%} | ||
<h2>Malformed JSON</h2> | ||
{%- endif -%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.