annotate src/add_server.html.luan @ 12:3e2cb946d511

form handling
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 30 Oct 2023 14:59:45 -0600
parents 62dd23f0b549
children 80105b716a62
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
11
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
3 local Html = require "luan:Html.luan"
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
4 local html_encode = Html.encode or error()
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Io = require "luan:Io.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Http = require "luan:http/Http.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Shared = require "site:/lib/Shared.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local head = Shared.head or error()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local header = Shared.header or error()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local footer = Shared.footer or error()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 return function()
11
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
14 local parameters = Http.request.parameters
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
15 local id = parameters.id or error()
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
16 local name = parameters.name or error()
12
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
17 name = html_encode(name)
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
18 local icon = parameters.icon or error()
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 Io.stdout = Http.response.text_writer()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 <!doctype html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 <head>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <% head() %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <title>Disearch</title>
12
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
26 <style>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
27 input[type="url"] {
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
28 width: 100%;
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
29 }
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
30 </style>
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 </head>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 <body>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 <% header() %>
11
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
34
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
35 <h1>Add server</h1>
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
36
12
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
37 <form page onsubmit="ajaxForm('/add_server.js',this); return false">
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
38 <input type=hidden name=id value="<%=id%>">
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
39 <input type=hidden name=name value="<%=name%>">
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
40 <input type=hidden name=icon value="<%=icon%>">
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
41 <p><%=name%></p>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
42 <p><img icon src="https://cdn.discordapp.com/icons/<%=id%>/<%=icon%>.png"></p>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
43 <p>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
44 Invite URL:<br>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
45 <input type=url required name=invite>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
46 <span error=invite></span>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
47 </p>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
48 <p><input type=submit></p>
3e2cb946d511 form handling
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
49 </form>
11
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
50
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 <% footer() %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 </body>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 </html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 <%
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 end