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
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c8e28c3
Escape input emails
RoiEXLab 114fd6c
Add basic template engine
RoiEXLab f32f312
Add basic noscript fallback
RoiEXLab 5e60afa
Change folder structure and add fallbacks
RoiEXLab 6130a20
Add static files
RoiEXLab 26a90ea
Prettify using CSS
RoiEXLab 2e3061d
Add JS For a single template
RoiEXLab eca0a27
Extract css and js to dedicated files
RoiEXLab 0f14479
Move stuff to template
RoiEXLab 8a36f8f
Add frontend
RoiEXLab 2733b98
Trim whitespace
RoiEXLab b9dab0c
Add verification Email-Template
RoiEXLab e4c05fa
Re-Enable button after success
RoiEXLab 5997abe
Split Layout
RoiEXLab 71f5915
Add dice template
RoiEXLab be0e18d
Fix template
RoiEXLab a047889
Please checkstyle
RoiEXLab 3e9040e
Use different config file for public directory
RoiEXLab 25c3643
Add full stop
RoiEXLab 0a80382
Add more accurate email validation
RoiEXLab 9b2db41
Remove unecessary escape to please eslint
RoiEXLab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for future reference... ESLint has a cascading and hierarchical model for configurations. So, if in the future, you want to share a more complicated configuration between back-end and front-end code, it should Just Work in the current project layout.
TL;DR: This line shouldn't be necessary as it should be picked up from the parent configuration (unless there's something special about the
extends
property I don't know about).