annotate src/admin/index.html.luan @ 12:c560b4e2f056

subdir for repos logs
author Vadim Filimonov <fffilimonov@yandex.ru>
date Thu, 28 Jul 2022 16:16:22 +0300
parents a7187a447835
children 7c9a45368af2
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>
10
a7187a447835 restrict repo names
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
50 <input type=text name=repo required pattern="[a-z0-9_][a-z0-9_-]*">
a7187a447835 restrict repo names
Franklin Schmidt <fschmidt@gmail.com>
parents: 4
diff changeset
51 <label prompt>Must match regex: [a-z0-9_][a-z0-9_-]*</label>
0
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
52 </p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
53 <p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
54 <input type=submit value="Add Repo">
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
55 </p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
56 </form>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
57 <% if config.private==nil or config.private[user] then %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
58 <hr>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
59 <p><a href="/private/">/private/</a></p>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
60 <% end %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
61 </div>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
62 </body>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
63 </html>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
64 <%
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
65 end