comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:dfc36e7ed22c
1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error
3 local Io = require "luan:Io.luan"
4 local Http = require "luan:http/Http.luan"
5 local Shared = require "site:/lib/Shared.luan"
6 local head = Shared.head or error()
7 local header = Shared.admin_header or error()
8 local get_user = Shared.get_user or error()
9 local config = Shared.config or error()
10 local get_raw_config = Shared.get_raw_config or error()
11 local save_raw_config = Shared.save_raw_config or error()
12 local admin_return = Shared.admin_return or error()
13
14
15 local function handle()
16 local user = get_user()
17 local repo_name = Http.request.parameters.repo or error()
18 local repo = config.repos[repo_name]
19 if repo == nil then
20 return [[<p error>Repo <b>]]..repo_name..[[</b> doesn't exist</p>]]
21 end
22 repo.admins[user] or error "not admin"
23 local raw_config = get_raw_config()
24 raw_config.repos[repo_name] = nil
25 save_raw_config(raw_config)
26 return [[<p>Repo <b>]]..repo_name..[[</b> has been deleted</p>]]..admin_return
27 end
28
29 return function()
30 Io.stdout = Http.response.text_writer()
31 %>
32 <!doctype html>
33 <html>
34 <head>
35 <% head() %>
36 <title>Delete Mercurial Repository</title>
37 </head>
38 <body>
39 <% header() %>
40 <div content>
41 <h1>Delete Repository</h1>
42 <%=handle()%>
43 </div>
44 </body>
45 </html>
46 <%
47 end