annotate src/index.html.luan @ 22:082b97b7f1d9

minor
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 15 Sep 2024 08:16:58 -0600
parents 74277b56ac3c
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
17
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
3 local ipairs = Luan.ipairs or error()
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
4 local Time = require "luan:Time.luan"
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
5 local time_now = Time.now or error()
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
6 local Html = require "luan:Html.luan"
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
7 local html_encode = Html.encode or error()
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Io = require "luan:Io.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Http = require "luan:http/Http.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local Shared = require "site:/lib/Shared.luan"
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local head = Shared.head or error()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local header = Shared.header or error()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 local footer = Shared.footer or error()
17
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
14 local ago = Shared.ago or error()
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
15 local Server = require "site:/lib/Server.luan"
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
16 local search_servers = Server.search or error()
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 return function()
17
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
20 local servers = search_servers("type:server","server_bumped desc")
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 Io.stdout = Http.response.text_writer()
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 %>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 <!doctype html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <head>
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 <title>Disearch</title>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 </head>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <body>
17
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
30 <% header()
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
31 local now = time_now()
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
32 for _, server in ipairs(servers) do
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
33 %>
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
34 <p>
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
35 <%=html_encode(server.name)%>
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
36 <% server.write_img_html() %>
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
37 <a href="<%=server.invite_url()%>">invite</a>
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
38 bumped <% ago( now - server.bumped ) %>
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
39 </p>
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
40 <%
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
41 end
74277b56ac3c home page
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
42 footer() %>
1
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 </body>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 </html>
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 <%
d19b150ecb83 add Shared
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 end