1
+ − 1 local Luan = require "luan:Luan.luan"
+ − 2 local error = Luan.error
13
+ − 3 local ipairs = Luan.ipairs or error()
+ − 4 local Html = require "luan:Html.luan"
+ − 5 local html_encode = Html.encode or error()
14
+ − 6 local url_encode = Html.url_encode or error()
1
+ − 7 local Io = require "luan:Io.luan"
+ − 8 local Http = require "luan:http/Http.luan"
+ − 9 local Shared = require "site:/lib/Shared.luan"
+ − 10 local head = Shared.head or error()
+ − 11 local header = Shared.header or error()
+ − 12 local footer = Shared.footer or error()
14
+ − 13 local base_url = Shared.base_url or error()
13
+ − 14 local Server = require "site:/lib/Server.luan"
14
+ − 15 local Config = require "site:/lib/Config.luan"
+ − 16 local Logging = require "luan:logging/Logging.luan"
+ − 17 local logger = Logging.logger "servers.html"
1
+ − 18
+ − 19
+ − 20 return function()
13
+ − 21 local servers = Server.get_user_servers()
1
+ − 22 Io.stdout = Http.response.text_writer()
+ − 23 %>
+ − 24 <!doctype html>
+ − 25 <html>
+ − 26 <head>
+ − 27 <% head() %>
+ − 28 <title>Disearch</title>
+ − 29 </head>
+ − 30 <body>
+ − 31 <% header() %>
11
+ − 32
+ − 33 <h1>Your servers</h1>
13
+ − 34 <%
+ − 35 for _, server in ipairs(servers) do
+ − 36 %>
+ − 37 <p>
+ − 38 <%=html_encode(server.name)%>
+ − 39 <% server.write_img_html() %>
+ − 40 <a href="<%=server.invite_url()%>">invite</a>
+ − 41 <a href="javascript:ajax('/delete_server.js?server=<%=server.id%>')">delete</a>
+ − 42 </p>
+ − 43 <%
14
+ − 44 end
+ − 45 local config = Config.get()
+ − 46 local redirect_uri = base_url().."/add_server.html"
+ − 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)
+ − 48
13
+ − 49 %>
14
+ − 50 <p><a href="<%=url%>">add server</a></p>
11
+ − 51
1
+ − 52 <% footer() %>
+ − 53 </body>
+ − 54 </html>
+ − 55 <%
+ − 56 end