diff options
Diffstat (limited to 'src/views')
-rw-r--r-- | src/views/dashboard.pug | 44 | ||||
-rw-r--r-- | src/views/index.pug | 3 | ||||
-rw-r--r-- | src/views/subs.pug | 20 |
3 files changed, 44 insertions, 23 deletions
diff --git a/src/views/dashboard.pug b/src/views/dashboard.pug new file mode 100644 index 0000000..be6c6f3 --- /dev/null +++ b/src/views/dashboard.pug | |||
@@ -0,0 +1,44 @@ | |||
1 | include ../mixins/header | ||
2 | include ../mixins/head | ||
3 | include ../utils | ||
4 | |||
5 | doctype html | ||
6 | html | ||
7 | +head("dashboard") | ||
8 | body | ||
9 | main#content | ||
10 | +header(user) | ||
11 | div.hero | ||
12 | h1 dashboard | ||
13 | |||
14 | if message | ||
15 | div.dashboard-error-message | ||
16 | | #{message} | ||
17 | |||
18 | if isAdmin | ||
19 | h2 invites | ||
20 | |||
21 | if invites | ||
22 | table.invite-table | ||
23 | tr | ||
24 | th.invite-table-header link | ||
25 | th.invite-table-header created | ||
26 | th.invite-table-header claimed | ||
27 | th.invite-table-header delete | ||
28 | each invite in invites | ||
29 | tr | ||
30 | td.invite-link | ||
31 | a(href=`/register?token=${invite.token}`) #{invite.token} | ||
32 | td #{timeDifference(Date.now(), invite.createdAt)} ago | ||
33 | if invite.usedAt | ||
34 | td #{timeDifference(Date.now(), invite.usedAt)} ago | ||
35 | else | ||
36 | td unclaimed | ||
37 | td | ||
38 | a(href=`/delete-invite/${invite.id}`) delete | ||
39 | |||
40 | a(href="/create-invite") create invite | ||
41 | |||
42 | else | ||
43 | p you aren't an admin and therefore there is nothing to see here yet | ||
44 | |||
diff --git a/src/views/index.pug b/src/views/index.pug index ace8922..140cd57 100644 --- a/src/views/index.pug +++ b/src/views/index.pug | |||
@@ -1,13 +1,10 @@ | |||
1 | include ../mixins/post | 1 | include ../mixins/post |
2 | include ../mixins/sub | ||
3 | include ../mixins/header | 2 | include ../mixins/header |
4 | include ../mixins/head | 3 | include ../mixins/head |
5 | include ../utils | 4 | include ../utils |
6 | - var subs = [] | ||
7 | doctype html | 5 | doctype html |
8 | html | 6 | html |
9 | +head("home") | 7 | +head("home") |
10 | +subMgmt() | ||
11 | script(defer). | 8 | script(defer). |
12 | async function subscribe(sub) { | 9 | async function subscribe(sub) { |
13 | await doThing(sub, 'subscribe'); | 10 | await doThing(sub, 'subscribe'); |
diff --git a/src/views/subs.pug b/src/views/subs.pug index 86de604..41f29ce 100644 --- a/src/views/subs.pug +++ b/src/views/subs.pug | |||
@@ -1,29 +1,9 @@ | |||
1 | include ../mixins/sub | ||
2 | include ../mixins/header | 1 | include ../mixins/header |
3 | include ../mixins/head | 2 | include ../mixins/head |
4 | 3 | ||
5 | doctype html | 4 | doctype html |
6 | html | 5 | html |
7 | +head("subscriptions") | 6 | +head("subscriptions") |
8 | +subMgmt() | ||
9 | script. | ||
10 | function newSubItem(sub) { | ||
11 | const p = document.createElement("p"); | ||
12 | const a = document.createElement("a"); | ||
13 | a.href = `/r/${sub}`; | ||
14 | a.innerText = `r/${sub}`; | ||
15 | p.appendChild(a); | ||
16 | return p; | ||
17 | } | ||
18 | |||
19 | function buildSubList() { | ||
20 | var subList = document.getElementById('subList'); | ||
21 | getSubs().forEach((sub)=>{ | ||
22 | subList.appendChild(newSubItem(sub)); | ||
23 | }); | ||
24 | } | ||
25 | |||
26 | document.addEventListener('DOMContentLoaded', buildSubList); | ||
27 | body | 7 | body |
28 | main#content | 8 | main#content |
29 | +header(user) | 9 | +header(user) |