0
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
|
4 local Io = require "luan:Io.luan"
|
|
5 local Http = require "luan:http/Http.luan"
|
|
6 local Shared = require "site:/lib/Shared.luan"
|
|
7 local head = Shared.head or error()
|
|
8 local header = Shared.admin_header or error()
|
|
9 local get_user = Shared.get_user or error()
|
|
10 local config = Shared.config or error()
|
4
|
11 local user_repos = Shared.user_repos or error()
|
0
|
12
|
|
13
|
|
14 return function()
|
|
15 local user = get_user()
|
|
16 Io.stdout = Http.response.text_writer()
|
|
17 %>
|
|
18 <!doctype html>
|
|
19 <html>
|
|
20 <head>
|
|
21 <% head() %>
|
|
22 <title>Your Mercurial Repositories</title>
|
|
23 <script>
|
|
24 function deleteRepo(name) {
|
|
25 if( confirm('Are you sure that you want to delete repo "'+name+'"?') )
|
|
26 location = "delete.html?repo="+name;
|
|
27 }
|
|
28 </script>
|
|
29 </head>
|
|
30 <body>
|
|
31 <% header() %>
|
|
32 <div content>
|
|
33 <h1>Repositories of <%=user%></h1>
|
|
34 <% for _, repo in ipairs(user_repos[user] or {}) do
|
|
35 local name = repo.name
|
|
36 %>
|
|
37 <p>
|
|
38 <a href="/repo/<%=name%>/"><%=name%></a>
|
|
39 <% if repo.admins[user] then %>
|
|
40 - <a href="edit.html?repo=<%=name%>">edit</a>
|
|
41 - <a href="javascript:deleteRepo('<%=name%>')">delete</a>
|
|
42 <% end %>
|
|
43 </p>
|
|
44 <% end %>
|
|
45 <hr>
|
|
46 <h2>Add Repository</h2>
|
|
47 <form action="add.html">
|
|
48 <p>
|
|
49 <label prompt>Repo name</label>
|
23
|
50 <input type=text name=repo required pattern="[a-z0-9_][a-z0-9_\-]*">
|
10
|
51 <label prompt>Must match regex: [a-z0-9_][a-z0-9_-]*</label>
|
0
|
52 </p>
|
|
53 <p>
|
|
54 <input type=submit value="Add Repo">
|
|
55 </p>
|
|
56 </form>
|
|
57 <% if config.private==nil or config.private[user] then %>
|
|
58 <hr>
|
|
59 <p><a href="/private/">/private/</a></p>
|
|
60 <% end %>
|
|
61 </div>
|
|
62 </body>
|
|
63 </html>
|
|
64 <%
|
|
65 end
|