Mercurial Hosting > hghosting
comparison src/admin/add.txt.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 get_user = Shared.get_user or error() | |
7 local get_raw_config = Shared.get_raw_config or error() | |
8 local save_raw_config = Shared.save_raw_config or error() | |
9 | |
10 | |
11 return function() | |
12 local user = get_user() | |
13 local repo_name = Http.request.parameters.repo or error "missing repo param" | |
14 repo_name~="_all" and repo_name~="_private" or error() | |
15 local mode = Http.request.parameters.mode or error "missing mode param" | |
16 mode=="public" or mode=="private" or error() | |
17 Io.stdout = Http.response.text_writer() | |
18 local raw_config = get_raw_config() | |
19 local repo = raw_config.repos[repo_name] | |
20 if repo == nil then | |
21 raw_config.repos[repo_name] = { | |
22 mode = mode | |
23 users = {user} | |
24 admins = {user} | |
25 } | |
26 save_raw_config(raw_config) | |
27 %>added<% | |
28 else | |
29 repo.mode==mode or error "mode mismatch" | |
30 %>exists<% | |
31 end | |
32 end |