annotate src/private/tools/all_users.html.luan @ 4:028e74c8889d

add all_users
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 12 May 2022 16:54:11 -0600
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local pairs = Luan.pairs or error()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local ipairs = Luan.ipairs or error()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Io = require "luan:Io.luan"
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Http = require "luan:http/Http.luan"
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Shared = require "site:/lib/Shared.luan"
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local head = Shared.head or error()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local header = Shared.private_header or error()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local config = Shared.config or error()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local user_repos = Shared.user_repos or error()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 return function()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 Io.stdout = Http.response.text_writer()
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 <!doctype html>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 <html>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 <head>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 <% head() %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 <title>Mercurial All Users</title>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <script>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 function deleteUser(name) {
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 if( confirm('Are you sure that you want to delete user "'+name+'"?') )
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 location = "delete_user.html?user="+name;
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 }
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 </script>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 </head>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <body>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <% header() %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 <div content>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 <h1>All Users</h1>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 <% for user in pairs(config.users) do %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 <p>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 <%=user%>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 <% local repos = user_repos[user]
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 if repos == nil then %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 [] <a href="javascript:deleteUser('<%=user%>')">delete user</a>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 <% else %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 [
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 <% for _, repo in ipairs(repos) do %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 <a href="/repo/<%=repo.name%>/"><%=repo.name%></a>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 <% end %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 ]
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 <% end %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 </p>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 <% end %>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 </div>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 </body>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 </html>
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 <%
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 end