summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/base.html2
-rw-r--r--templates/canvas.html22
-rw-r--r--templates/home.html28
-rw-r--r--templates/portal.html18
-rw-r--r--templates/profile.html74
5 files changed, 100 insertions, 44 deletions
diff --git a/templates/base.html b/templates/base.html
index 3a9f582..f2f849f 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -14,8 +14,6 @@
<h1>~penguins.lan</h1>
<nav aria-label="Main">
<a href="/">home.</a>
- <span> | </span>
- <a href="/canvas">place.</a>
{{ if .User }}
<span class="spacer"></span>
<span>🐧 <a style="text-decoration: none;" class="whoami" href="/profile"><span id="me">{{ .User.Username }}</span></a></span>
diff --git a/templates/canvas.html b/templates/canvas.html
deleted file mode 100644
index 84e964d..0000000
--- a/templates/canvas.html
+++ /dev/null
@@ -1,22 +0,0 @@
-{{ define "content" }}
-<h2>~place</h2>
-<p>{{ .Canvas.Rows }}×{{ .Canvas.Cols }}, one pixel at a time. pick a color, click a cell. be nice to your fellow waddlers &lt;3</p>
-
-<div id="palette" class="palette"></div>
-
-<div class="canvas-wrap">
- <canvas id="canvas" width="{{ .Canvas.Cols }}" height="{{ .Canvas.Rows }}"></canvas>
-</div>
-<p id="cooldown" class="muted"></p>
-
-<script>
-window.CANVAS = {
- rows: {{ .Canvas.Rows }},
- cols: {{ .Canvas.Cols }},
- scale: {{ .Canvas.Scale }},
- cooldownMs: {{ .Canvas.CooldownMs }},
- palette: [{{ range $i, $c := .Canvas.Palette }}{{ if $i }}, {{ end }}"{{ $c }}"{{ end }}]
-};
-</script>
-<script src="/static/js/canvas.js"></script>
-{{ end }}
diff --git a/templates/home.html b/templates/home.html
index aeb2739..f8102e6 100644
--- a/templates/home.html
+++ b/templates/home.html
@@ -2,7 +2,7 @@
<h2>~welcome</h2>
<p>hey there penguin! or, <strong>{{ .User.Username }}</strong>, i guess.</p>
-<p>this network does not have access to the outside internet. everything runs off of this battery, phone, and mini AP; i carry it around sometimes.</p>
+<p>this network does not serve the outside internet. everything runs off of this battery, phone, and mini AP. i carry it around sometimes.</p>
<div style="text-align: center" >
<img width="60%" src="/static/img/lab.png">
@@ -33,6 +33,7 @@ git push
{{ end }}
</ul>
<script src="/static/js/waddlers.js"></script>
+<script src="/static/js/chat.js"></script>
<div id="log" class="chat-log" aria-live="polite"></div>
@@ -43,11 +44,32 @@ git push
<hr>
+<h3>~place</h3>
+<p>pick a color and click to drop it, scroll to zoom in, drag to pan the canvas. <span id="cooldown" class="muted"></span></p>
+
+<div id="palette" class="palette"></div>
+<div id="viewport" class="canvas-viewport">
+ <canvas id="canvas" width="{{ .Canvas.Cols }}" height="{{ .Canvas.Rows }}"></canvas>
+ <div id="pixel-cursor" class="pixel-cursor"></div>
+ <div id="coords" class="canvas-coords"></div>
+</div>
+
+<script>
+window.CANVAS = {
+ rows: {{ .Canvas.Rows }},
+ cols: {{ .Canvas.Cols }},
+ scale: {{ .Canvas.Scale }},
+ cooldownMs: {{ .Canvas.CooldownMs }},
+ palette: [{{ range $i, $c := .Canvas.Palette }}{{ if $i }}, {{ end }}"{{ $c }}"{{ end }}]
+};
+</script>
+<script src="/static/js/canvas.js"></script>
+
+<hr>
+
<h3>~minecraft</h3>
<p>java edition — join <code>penguins.lan</code></p>
<p id="mc-status" class="muted">checking…</p>
<script src="/static/js/minecraft.js"></script>
-
-<script src="/static/js/chat.js"></script>
{{ end }}
diff --git a/templates/portal.html b/templates/portal.html
index a2959f1..5ab5192 100644
--- a/templates/portal.html
+++ b/templates/portal.html
@@ -1,5 +1,5 @@
{{ define "content" }}
-<p>welcome to ~penguins.lan</p>
+<p>welcome to penguins.lan, penguin! by joining, you promise to be a good penguin &lt;3</p>
{{ with .Portal }}
{{ if .Taken }}
@@ -37,7 +37,7 @@
return keys.every(key => !obj[key]);
}
const send = async () => {
- await fetch(paramsObject['_authaction'] + '?tok' + paramsObject['_token'], {
+ await fetch(paramsObject['_authaction'] + '?tok=' + paramsObject['_token'], {
mode: "no-cors"
});
const data = new FormData(form);
@@ -50,17 +50,5 @@
e.preventDefault();
send().then(() => { window.location.href = "/"; });
})
-
- }
- function getQueryVariable(variable) {
- query = window.location.search.substring(1);
- vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if (pair[0] == variable) {
- return pair[1];
- }
- }
- alert('Query Variable ' + variable + ' not found');
}
-</script> \ No newline at end of file
+</script>
diff --git a/templates/profile.html b/templates/profile.html
index f0f93d9..83f97ce 100644
--- a/templates/profile.html
+++ b/templates/profile.html
@@ -1,8 +1,78 @@
-hellow
{{ define "content" }}
+<h2>~profile</h2>
+
<form action="/rename" method="post" class="rename-form">
<label for="username">not your name? change it:</label>
<input id="username" name="username" value="{{ .User.Username }}" maxlength="24">
<button type="submit">rename</button>
</form>
-{{ end }} \ No newline at end of file
+
+<h3>~devices</h3>
+<p>every device you've connected with is reachable at <code>&lt;mac&gt;.{{ .UserDomain }}</code>
+<br>
+the <span class="dot online"></span> one is your primary. <code>{{ .UserDomain }}</code> points there.</p>
+
+<table class="lan-table">
+ <tr><th></th><th>device.</th><th>status.</th><th>last seen.</th><th></th></tr>
+ {{ range .Devices }}
+ <tr>
+ <td>{{ if .Primary }}<span class="dot online" title="primary device"></span>{{ end }}</td>
+ <td><code>{{ .Name }}</code></td>
+ <td>{{ if .Online }}<span class="dot online"></span> {{ .IP }}{{ else }}<span class="dot offline"></span> <span class="muted">offline</span>{{ end }}</td>
+ <td class="muted">{{ .LastSeen }}</td>
+ <td>{{ if not .Primary }}<form method="post" action="/profile/primary">
+ <input type="hidden" name="mac" value="{{ .Mac }}">
+ <button class="set-primary" data-mac="{{ .Mac }}" data-name="{{ .Name }}">make primary</button>
+ </form>{{ end }}</td>
+ </tr>
+ {{ end }}
+ {{ if not .Devices }}
+ <tr><td colspan="5" class="muted">no devices seen yet — connect to the network and reload.</td></tr>
+ {{ end }}
+</table>
+
+<h3>~dns</h3>
+<p>you own <code>{{ .UserDomain }}</code>. add whatever records you want, or hit the button and let the wizard help you.</p>
+
+<button id="dns-wizard" class="wizard-btn">🧙set up my records🐧</button>
+
+<table class="lan-table">
+ <tr><th>type.</th><th>name.</th><th>content.</th><th>ttl.</th><th></th></tr>
+ {{ range .DNSRecords }}
+ <tr>
+ <td>{{ .Type }}</td>
+ <td><code>{{ .Name }}</code></td>
+ <td><code>{{ .Content }}</code></td>
+ <td>{{ .TTL }}</td>
+ <td><form method="post" action="/dns/delete">
+ <input type="hidden" name="id" value="{{ .ID }}">
+ <button>delete</button>
+ </form></td>
+ </tr>
+ {{ end }}
+ {{ if not .DNSRecords }}
+ <tr><td colspan="5" class="muted">no records yet.</td></tr>
+ {{ end }}
+</table>
+
+<form method="post" action="/dns" class="dns-form">
+ <h4>add a record</h4>
+ <div class="dns-fields">
+ <input name="type" placeholder="CNAME" maxlength="8" required>
+ <input name="name" placeholder="www (-> www.{{ .UserDomain }})" required>
+ <input name="content" placeholder="{{ .UserDomain }}" required>
+ <input name="ttl" placeholder="300" value="300">
+ <button type="submit">add</button>
+ </div>
+</form>
+
+<script>
+window.DNS = {
+ userDomain: "{{ .UserDomain }}",
+ zone: "{{ .DnsZone }}",
+ primaryMac: "{{ .PrimaryMAC }}",
+ devices: [{{ range $i, $d := .Devices }}{{ if $i }}, {{ end }}{"mac": "{{ $d.Mac }}", "name": "{{ $d.Name }}", "primary": {{ if $d.Primary }}true{{ else }}false{{ end }}}{{ end }}]
+};
+</script>
+<script src="/static/js/dns-wizard.js"></script>
+{{ end }}