annotate src/admin/index.html.luan @ 5:a09d8bcdc0f9

lower case repos
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 18 May 2022 00:21:44 -0600
parents 028e74c8889d
children a7187a447835
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
2 local error = Luan.error
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
3 local ipairs = Luan.ipairs or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
4 local Io = require "luan:Io.luan"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
5 local Http = require "luan:http/Http.luan"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
6 local Shared = require "site:/lib/Shared.luan"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
7 local head = Shared.head or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
8 local header = Shared.admin_header or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
9 local get_user = Shared.get_user or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
10 local config = Shared.config or error()
4
028e74c8889d add all_users
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
11 local user_repos = Shared.user_repos or error()
0
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
12
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
13
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
14 return function()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
15 local user = get_user()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
16 Io.stdout = Http.response.text_writer()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
17 %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
18 <!doctype html>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
19 <html>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
20 <head>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
21 <% head() %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
22 <title>Your Mercurial Repositories</title>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
23 <script>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
24 function deleteRepo(name) {
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
25 if( confirm('Are you sure that you want to delete repo "'+name+'"?') )
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
26 location = "delete.html?repo="+name;
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
27 }
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
28 </script>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
29 </head>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
30 <body>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
31 <% header() %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
32 <div content>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
33 <h1>Repositories of <%=user%></h1>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
34 <% for _, repo in ipairs(user_repos[user] or {}) do
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
35 local name = repo.name
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
36 %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
37 <p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
38 <a href="/repo/<%=name%>/"><%=name%></a>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
39 <% if repo.admins[user] then %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
40 - <a href="edit.html?repo=<%=name%>">edit</a>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
41 - <a href="javascript:deleteRepo('<%=name%>')">delete</a>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
42 <% end %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
43 </p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
44 <% end %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
45 <hr>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
46 <h2>Add Repository</h2>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
47 <form action="add.html">
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
48 <p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
49 <label prompt>Repo name</label>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
50 <input type=text name=repo required>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
51 </p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
52 <p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
53 <input type=submit value="Add Repo">
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
54 </p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
55 </form>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
56 <% if config.private==nil or config.private[user] then %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
57 <hr>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
58 <p><a href="/private/">/private/</a></p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
59 <% end %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
60 </div>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
61 </body>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
62 </html>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
63 <%
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
64 end