view src/admin/delete.html.luan @ 13:94b5c7b54978

rm only logs
author Vadim Filimonov <fffilimonov@yandex.ru>
date Thu, 28 Jul 2022 16:23:57 +0300
parents dfc36e7ed22c
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Io = require "luan:Io.luan"
local Http = require "luan:http/Http.luan"
local Shared = require "site:/lib/Shared.luan"
local head = Shared.head or error()
local header = Shared.admin_header or error()
local get_user = Shared.get_user or error()
local config = Shared.config or error()
local get_raw_config = Shared.get_raw_config or error()
local save_raw_config = Shared.save_raw_config or error()
local admin_return = Shared.admin_return or error()


local function handle()
	local user = get_user()
	local repo_name = Http.request.parameters.repo or error()
	local repo = config.repos[repo_name]
	if repo == nil then
		return [[<p error>Repo <b>]]..repo_name..[[</b> doesn't exist</p>]]
	end
	repo.admins[user] or error "not admin"
	local raw_config = get_raw_config()
	raw_config.repos[repo_name] = nil
	save_raw_config(raw_config)
	return [[<p>Repo <b>]]..repo_name..[[</b> has been deleted</p>]]..admin_return
end

return function()
	Io.stdout = Http.response.text_writer()
%>
<!doctype html>
<html>
	<head>
<%		head() %>
		<title>Delete Mercurial Repository</title>
	</head>
	<body>
<%		header() %>
		<div content>
			<h1>Delete Repository</h1>
			<%=handle()%>
		</div>
	</body>
</html>
<%
end