Mercurial Hosting > hghosting
comparison src/admin/add.html.luan @ 21:b14073ab9d07
update luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 14 Sep 2024 22:17:26 -0600 |
parents | a7187a447835 |
children | 7c9a45368af2 |
comparison
equal
deleted
inserted
replaced
20:8b4481769cc6 | 21:b14073ab9d07 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local String = require "luan:String.luan" | 3 local String = require "luan:String.luan" |
4 local matches = String.matches or error() | |
5 local Io = require "luan:Io.luan" | 4 local Io = require "luan:Io.luan" |
6 local Http = require "luan:http/Http.luan" | 5 local Http = require "luan:http/Http.luan" |
7 local Shared = require "site:/lib/Shared.luan" | 6 local Shared = require "site:/lib/Shared.luan" |
8 local head = Shared.head or error() | 7 local head = Shared.head or error() |
9 local header = Shared.admin_header or error() | 8 local header = Shared.admin_header or error() |
10 local get_user = Shared.get_user or error() | 9 local get_user = Shared.get_user or error() |
11 local get_raw_config = Shared.get_raw_config or error() | 10 local get_raw_config = Shared.get_raw_config or error() |
12 local save_raw_config = Shared.save_raw_config or error() | 11 local save_raw_config = Shared.save_raw_config or error() |
13 local admin_return = Shared.admin_return or error() | 12 local admin_return = Shared.admin_return or error() |
14 | 13 |
14 local name_regex = String.regex("^[a-z0-9_][a-z0-9_-]*$") | |
15 | 15 |
16 local function handle() | 16 local function handle() |
17 local user = get_user() | 17 local user = get_user() |
18 local repo_name = Http.request.parameters.repo or error() | 18 local repo_name = Http.request.parameters.repo or error() |
19 matches( repo_name, "^[a-z0-9_][a-z0-9_-]*$" ) or error "invalid regex name" | 19 name_regex.matches( repo_name ) or error "invalid regex name" |
20 if repo_name=="_all" or repo_name=="_private" then | 20 if repo_name=="_all" or repo_name=="_private" then |
21 return [[<p error>Invalid rep name</p>]] | 21 return [[<p error>Invalid rep name</p>]] |
22 end | 22 end |
23 local raw_config = get_raw_config() | 23 local raw_config = get_raw_config() |
24 if raw_config.repos[repo_name] ~= nil then | 24 if raw_config.repos[repo_name] ~= nil then |