annotate src/servers.html.luan @ 14:80105b716a62

start bot
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 31 Oct 2023 23:56:48 -0600
parents af2b95854072
children
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
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
3 local ipairs = Luan.ipairs or error()
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
4 local Html = require "luan:Html.luan"
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
5 local html_encode = Html.encode or error()
14
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
6 local url_encode = Html.url_encode or error()
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Io = require "luan:Io.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Http = require "luan:http/Http.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Shared = require "site:/lib/Shared.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local head = Shared.head or error()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local header = Shared.header or error()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local footer = Shared.footer or error()
14
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
13 local base_url = Shared.base_url or error()
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
14 local Server = require "site:/lib/Server.luan"
14
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
15 local Config = require "site:/lib/Config.luan"
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
16 local Logging = require "luan:logging/Logging.luan"
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
17 local logger = Logging.logger "servers.html"
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 return function()
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
21 local servers = Server.get_user_servers()
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 Io.stdout = Http.response.text_writer()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <!doctype html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 <head>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <% head() %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 <title>Disearch</title>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 </head>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <body>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 <% header() %>
11
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
32
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
33 <h1>Your servers</h1>
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
34 <%
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
35 for _, server in ipairs(servers) do
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
36 %>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
37 <p>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
38 <%=html_encode(server.name)%>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
39 <% server.write_img_html() %>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
40 <a href="<%=server.invite_url()%>">invite</a>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
41 <a href="javascript:ajax('/delete_server.js?server=<%=server.id%>')">delete</a>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
42 </p>
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
43 <%
14
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
44 end
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
45 local config = Config.get()
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
46 local redirect_uri = base_url().."/add_server.html"
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
47 local url = "https://discord.com/oauth2/authorize?client_id="..config.discord.client_id.."&scope=bot&response_type=code&redirect_uri="..url_encode(redirect_uri)
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
48
13
af2b95854072 add server records
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
49 %>
14
80105b716a62 start bot
Franklin Schmidt <fschmidt@gmail.com>
parents: 13
diff changeset
50 <p><a href="<%=url%>">add server</a></p>
11
62dd23f0b549 start add server
Franklin Schmidt <fschmidt@gmail.com>
parents: 3
diff changeset
51
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 <% footer() %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 </body>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 </html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 <%
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 end