view 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
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local ipairs = Luan.ipairs or 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 user_repos = Shared.user_repos or error()


return function()
	local user = get_user()
	Io.stdout = Http.response.text_writer()
%>
<!doctype html>
<html>
	<head>
<%		head() %>
		<title>Your Mercurial Repositories</title>
		<script>
			function deleteRepo(name) {
				if( confirm('Are you sure that you want to delete repo "'+name+'"?') )
					location = "delete.html?repo="+name;
			}
		</script>
	</head>
	<body>
<%		header() %>
		<div content>
			<h1>Repositories of <%=user%></h1>
<%	for _, repo in ipairs(user_repos[user] or {}) do
		local name = repo.name
%>
			<p>
				<a href="/repo/<%=name%>/"><%=name%></a>
<%		if repo.admins[user] then %>
				- <a href="edit.html?repo=<%=name%>">edit</a>
				- <a href="javascript:deleteRepo('<%=name%>')">delete</a>
<%		end %>
			</p>
<%	end %>
			<hr>
			<h2>Add Repository</h2>
			<form action="add.html">
				<p>
					<label prompt>Repo name</label>
					<input type=text name=repo required pattern="[a-z0-9_][a-z0-9_-]*">
					<label prompt>Must match regex: [a-z0-9_][a-z0-9_-]*</label>
				</p>
				<p>
					<input type=submit value="Add Repo">
				</p>
			</form>
<%	if config.private==nil or config.private[user] then %>
			<hr>
			<p><a href="/private/">/private/</a></p>
<%	end %>
		</div>
	</body>
</html>
<%
end