diff 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
line wrap: on
line diff
--- a/src/add_server.html.luan	Sun Oct 29 22:39:31 2023 -0600
+++ b/src/add_server.html.luan	Mon Oct 30 14:59:45 2023 -0600
@@ -14,7 +14,8 @@
 	local parameters = Http.request.parameters
 	local id = parameters.id or error()
 	local name = parameters.name or error()
-	local icon = parameters.icon
+	name = html_encode(name)
+	local icon = parameters.icon or error()
 	Io.stdout = Http.response.text_writer()
 %>
 <!doctype html>
@@ -22,16 +23,30 @@
 	<head>
 <%		head() %>
 		<title>Disearch</title>
+		<style>
+			input[type="url"] {
+				width: 100%;
+			}
+		</style>
 	</head>
 	<body>
 <%		header() %>
 
 		<h1>Add server</h1>
 
-		<p><%=html_encode(name)%></p>
-<%	if icon ~= nil then %>
-		<p><img src="https://cdn.discordapp.com/icons/<%=id%>/<%=icon%>.png"></p>
-<%	end %>
+		<form page onsubmit="ajaxForm('/add_server.js',this); return false">
+			<input type=hidden name=id value="<%=id%>">
+			<input type=hidden name=name value="<%=name%>">
+			<input type=hidden name=icon value="<%=icon%>">
+			<p><%=name%></p>
+			<p><img icon src="https://cdn.discordapp.com/icons/<%=id%>/<%=icon%>.png"></p>
+			<p>
+				Invite URL:<br>
+				<input type=url required name=invite>
+				<span error=invite></span>
+			</p>
+			<p><input type=submit></p>
+		</form>
 
 <%		footer() %>
 	</body>