changeset 17:74277b56ac3c

home page
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 01 Nov 2023 21:11:25 -0600
parents 552d6f944acb
children 398c823aebe2
files src/index.html.luan src/lib/Db.luan src/lib/Server.luan
diffstat 3 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/index.html.luan	Wed Nov 01 17:34:15 2023 -0600
+++ b/src/index.html.luan	Wed Nov 01 21:11:25 2023 -0600
@@ -1,14 +1,23 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
+local ipairs = Luan.ipairs or error()
+local Time = require "luan:Time.luan"
+local time_now = Time.now or error()
+local Html = require "luan:Html.luan"
+local html_encode = Html.encode or error()
 local Io = require "luan:Io.luan"
 local Http = require "luan:http/Http.luan"
 local Shared = require "site:/lib/Shared.luan"
 local head = Shared.head or error()
 local header = Shared.header or error()
 local footer = Shared.footer or error()
+local ago = Shared.ago or error()
+local Server = require "site:/lib/Server.luan"
+local search_servers = Server.search or error()
 
 
 return function()
+	local servers = search_servers("type:server","server_bumped desc")
 	Io.stdout = Http.response.text_writer()
 %>
 <!doctype html>
@@ -18,9 +27,19 @@
 		<title>Disearch</title>
 	</head>
 	<body>
-<%		header() %>
-		<p>under construction</p>
-<%		footer() %>
+<%		header()
+	local now = time_now()
+	for _, server in ipairs(servers) do
+%>
+		<p>
+			<%=html_encode(server.name)%>
+			<% server.write_img_html() %>
+			<a href="<%=server.invite_url()%>">invite</a>
+			bumped <% ago( now - server.bumped ) %>
+		</p>
+<%
+	end
+		footer() %>
 	</body>
 </html>
 <%
--- a/src/lib/Db.luan	Wed Nov 01 17:34:15 2023 -0600
+++ b/src/lib/Db.luan	Wed Nov 01 21:11:25 2023 -0600
@@ -20,6 +20,7 @@
 
 Db.indexed_fields.server_discord_id = Lucene.type.string
 Db.indexed_fields.server_owner_discord_id = Lucene.type.string
+Db.indexed_fields.server_bumped = Lucene.type.long
 
 function Db.not_in_transaction()
 	logger.error(new_error("not in transaction"))
--- a/src/lib/Server.luan	Wed Nov 01 17:34:15 2023 -0600
+++ b/src/lib/Server.luan	Wed Nov 01 21:11:25 2023 -0600
@@ -85,6 +85,7 @@
 	end
 	return servers
 end
+Server.search = search
 
 function Server.get_user_servers()
 	return search( "server_owner_discord_id:"..get_user() )