diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server.js | 21 | ||||
-rw-r--r-- | src/static/styles.css | 7 | ||||
-rw-r--r-- | src/templates.js | 2 | ||||
-rw-r--r-- | src/templates/expected.html | 2 | ||||
-rw-r--r-- | src/templates/goals.html | 2 | ||||
-rw-r--r-- | src/templates/ledger-edit.html | 2 | ||||
-rw-r--r-- | src/templates/ledger.html | 2 | ||||
-rw-r--r-- | src/templates/login.html | 2 | ||||
-rw-r--r-- | src/templates/me.html | 27 | ||||
-rw-r--r-- | src/templates/message.html | 5 | ||||
-rw-r--r-- | src/templates/navigation.html | 1 | ||||
-rw-r--r-- | src/templates/summary.html | 2 |
12 files changed, 67 insertions, 8 deletions
diff --git a/src/server.js b/src/server.js index 17d5372..e0214ba 100644 --- a/src/server.js +++ b/src/server.js @@ -23,6 +23,19 @@ function hashWithSalt(password, salt) { return hash.digest("base64"); }; +let messages = {} +function putMessage(message, res){ + message[res.locals.username] = message; +} +function consumeMessage(res){ + if(messages[res.locals.username]){ + let t = messages[res.locals.username] + delete messages[res.locals.username] + return t + } + return undefined +} + function setUpRoutes(models, jwtFunctions, database, templates) { // Authentication routine server.use(async function (req, res, next) { @@ -60,7 +73,13 @@ function setUpRoutes(models, jwtFunctions, database, templates) { server.use('/static', express.static(path.join(__dirname, '/static'))) server.get('/', (req, res) => res.redirect("/ledger")) server.get('/about', (req, res) => { - let body = templates["about"]({}); + let name = res.locals.user.username + let body = templates["about"]({name}); + res.status(200).send(body) + }) + server.get('/me', (req, res) => { + let name = res.locals.user.username + let body = templates["me"]({name, message: consumeMessage(res)}); res.status(200).send(body) }) server.get('/login', (req, res) => { diff --git a/src/static/styles.css b/src/static/styles.css index fb91d3b..984a43d 100644 --- a/src/static/styles.css +++ b/src/static/styles.css @@ -69,13 +69,18 @@ body { .main { flex-grow: 3; max-width: 1000px; + margin: auto; } p, li { max-width: 70ch; } -@media only screen and (max-width: 600px) { +a, a:visited { + color: black; +} + +@media (max-width: 600px) { .newItem td { display:block; } diff --git a/src/templates.js b/src/templates.js index a9e3305..d355a5f 100644 --- a/src/templates.js +++ b/src/templates.js @@ -13,8 +13,10 @@ function loadPartial(name, filepath){ function setUpTemplates(){ loadPartial("navigation", path.join(__dirname, "templates/navigation.html")) + loadPartial("message", path.join(__dirname, "templates/message.html")) let templates = {}; + loadTemplate(templates, "me", path.join(__dirname, 'templates/me.html')) loadTemplate(templates, "about", path.join(__dirname, 'templates/about.html')) loadTemplate(templates, "login", path.join(__dirname, 'templates/login.html')) loadTemplate(templates, "signup", path.join(__dirname, 'templates/sign-up.html')) diff --git a/src/templates/expected.html b/src/templates/expected.html index 9554896..3657151 100644 --- a/src/templates/expected.html +++ b/src/templates/expected.html @@ -9,7 +9,7 @@ <body> <div class="main"> - <h1>{{name}}'s Budget</h1> + <h1>Expected</h1> <div> <a href="/ledger"><button>Ledger</button></a> <a href="/summary"><button>Summary</button></a> diff --git a/src/templates/goals.html b/src/templates/goals.html index e30aa62..9c106bd 100644 --- a/src/templates/goals.html +++ b/src/templates/goals.html @@ -9,7 +9,7 @@ <body> <div class="main"> - <h1>{{name}}'s Budget</h1> + <h1>Goals</h1> <form method="post" action="/goals"> <input name="name" placeholder="name"> <input name="total" placeholder="total" type="number" step="0.01"> diff --git a/src/templates/ledger-edit.html b/src/templates/ledger-edit.html index e939b6d..b5539f1 100644 --- a/src/templates/ledger-edit.html +++ b/src/templates/ledger-edit.html @@ -9,7 +9,7 @@ <body> <div class="main"> - <h1>{{name}}'s Budget</h1> + <h1>Ledger - Edit</h1> <form method="post" action="/transaction/{{item.id}}"> <input id="datePicker" name="when" placeholder="date" type="date"> <input name="where" placeholder="where" type="text" value="{{item.where}}"> diff --git a/src/templates/ledger.html b/src/templates/ledger.html index e2b7625..031108e 100644 --- a/src/templates/ledger.html +++ b/src/templates/ledger.html @@ -10,7 +10,7 @@ <body> <div class="main"> - <h1>{{name}}'s Budget</h1> + <h1>Ledger</h1> <form method="post" action="/transaction"> <input id="datePicker" name="when" placeholder="date" type="date"> <input required name="where" placeholder="where" type="text"> diff --git a/src/templates/login.html b/src/templates/login.html index dcf8f8e..a8cc98c 100644 --- a/src/templates/login.html +++ b/src/templates/login.html @@ -14,7 +14,7 @@ <form method="post" action="/login"> <input name="username" type="text" placeholder="Enter Username" required> <input type="password" placeholder="Enter Password" name="password" required> - <input type="submit" vallue="Log in"> + <input type="submit" value="Log in"> </div> </div> </body> diff --git a/src/templates/me.html b/src/templates/me.html new file mode 100644 index 0000000..77b5ed4 --- /dev/null +++ b/src/templates/me.html @@ -0,0 +1,27 @@ +<!doctype html> +<html lang="en"> + +<head> + <title>About</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> + <link rel="stylesheet" type="text/css" href="static/styles.css"> +</head> + +<body> + <div class="main"> + <h1>{{name}}</h1> + + {{message}} + <h2>Reset Password</h2> + <form method="post" action="/password"> + <input type="password" placeholder="Old Password" name="old" required> + <input type="password" placeholder="New Password" name="new1" required> + <input type="password" placeholder="New Password (again)" name="new2" required> + <input type="submit" value="Reset"> + </form> + </div> + {{> navigation}} +</body> + +</html>
\ No newline at end of file diff --git a/src/templates/message.html b/src/templates/message.html new file mode 100644 index 0000000..9ee9fd8 --- /dev/null +++ b/src/templates/message.html @@ -0,0 +1,5 @@ +{{#if message}} + <div class="message"> + {{message}} + </div> +{{/if}}
\ No newline at end of file diff --git a/src/templates/navigation.html b/src/templates/navigation.html index c20ccbf..2b7717b 100644 --- a/src/templates/navigation.html +++ b/src/templates/navigation.html @@ -1,4 +1,5 @@ <div class="navigation"> + <h2><a href="/me">{{name}}</a></h2> <div><a href="/ledger">Ledger</a></div> <div><a href="/summary">Summary</a></div> <div><a href="/goals">Goals</a></div> diff --git a/src/templates/summary.html b/src/templates/summary.html index 2759986..4ad6261 100644 --- a/src/templates/summary.html +++ b/src/templates/summary.html @@ -9,7 +9,7 @@ <body> <div class="main"> - <h1>{{name}}'s Budget</h1> + <h1>Summary</h1> <div class="summary"> <div class="summary-panel"> <h2>Weekly</h2> |