annotate src/admin/delete.html.luan @ 0:dfc36e7ed22c

init
author Vadim Filimonov <fffilimonov@yandex.ru>
date Thu, 12 May 2022 13:51:59 +0400
parents
children
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 Io = require "luan:Io.luan"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
4 local Http = require "luan:http/Http.luan"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
5 local Shared = require "site:/lib/Shared.luan"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
6 local head = Shared.head or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
7 local header = Shared.admin_header or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
8 local get_user = Shared.get_user or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
9 local config = Shared.config or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
10 local get_raw_config = Shared.get_raw_config or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
11 local save_raw_config = Shared.save_raw_config or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
12 local admin_return = Shared.admin_return or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
13
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
14
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
15 local function handle()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
16 local user = get_user()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
17 local repo_name = Http.request.parameters.repo or error()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
18 local repo = config.repos[repo_name]
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
19 if repo == nil then
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
20 return [[<p error>Repo <b>]]..repo_name..[[</b> doesn't exist</p>]]
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
21 end
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
22 repo.admins[user] or error "not admin"
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
23 local raw_config = get_raw_config()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
24 raw_config.repos[repo_name] = nil
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
25 save_raw_config(raw_config)
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
26 return [[<p>Repo <b>]]..repo_name..[[</b> has been deleted</p>]]..admin_return
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
27 end
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
28
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
29 return function()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
30 Io.stdout = Http.response.text_writer()
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
31 %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
32 <!doctype html>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
33 <html>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
34 <head>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
35 <% head() %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
36 <title>Delete Mercurial Repository</title>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
37 </head>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
38 <body>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
39 <% header() %>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
40 <div content>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
41 <h1>Delete Repository</h1>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
42 <%=handle()%>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
43 </div>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
44 </body>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
45 </html>
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
46 <%
Vadim Filimonov <fffilimonov@yandex.ru>
parents:
diff changeset
47 end