big work on env configs
This commit is contained in:
parent
1fc713ee27
commit
54819ec21d
@ -1,3 +1,3 @@
|
|||||||
# Environment variables for Moonshark
|
# env variables - generated automatically - you can edit this file
|
||||||
# Generated automatically - you can edit this file
|
|
||||||
|
|
||||||
|
game_open=true
|
||||||
|
BIN
data/dk.db
BIN
data/dk.db
Binary file not shown.
@ -1,3 +1,13 @@
|
|||||||
<h1>Config</h1>
|
<h1>Config</h1>
|
||||||
|
|
||||||
Hiiiii!
|
<form action="/admin/config" method="post">
|
||||||
|
<div>
|
||||||
|
<h4>Game Open</h4>
|
||||||
|
<input type="radio" name="game_open" id="open_yes" value="1" {{{ game_open_yes }}}>
|
||||||
|
<label for="open_yes">Open</label>
|
||||||
|
<input type="radio" name="game_open" id="open_no" value="0" {{{ game_open_no }}}>
|
||||||
|
<label for="open_no">Closed</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="ui button primary">Save</button>
|
||||||
|
</form>
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
<section id="main">
|
<section id="main">
|
||||||
{{{ content }}}
|
{{{ html }}}
|
||||||
</section>
|
</section>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
local m = {}
|
local m = {}
|
||||||
|
|
||||||
function m.page(template, title)
|
function m.page(template, title, ext_data)
|
||||||
|
if not title then
|
||||||
|
local title = "Admin"
|
||||||
|
else
|
||||||
local title = "Admin: "..title
|
local title = "Admin: "..title
|
||||||
|
|
||||||
if ctx.headers["X-DK-AJAX"] then
|
|
||||||
return {
|
|
||||||
html = fs_read("templates/admin/"..template),
|
|
||||||
title = title
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return send_html(render(
|
local data = table.merge({
|
||||||
fs_read("templates/admin/layout.html"),
|
|
||||||
{
|
|
||||||
title = title,
|
title = title,
|
||||||
content = fs_read("templates/admin/"..template),
|
|
||||||
version = "v1.0.0",
|
version = "v1.0.0",
|
||||||
build = "Moonlight"
|
build = "Moonlight"
|
||||||
}
|
}, ext_data or {})
|
||||||
))
|
|
||||||
|
data.html = render(fs_read("templates/admin/"..template), data)
|
||||||
|
|
||||||
|
if ctx.headers["X-DK-AJAX"] then return data end
|
||||||
|
|
||||||
|
return send_html(render(fs_read("templates/admin/layout.html"), data))
|
||||||
end
|
end
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
@ -1,2 +1,7 @@
|
|||||||
local admin = require("admin")
|
local admin = require("admin")
|
||||||
return admin.page("config.html", "Config")
|
|
||||||
|
local game_open = env_get("game_open")
|
||||||
|
return admin.page("config.html", "Config", {
|
||||||
|
game_open_yes = game_open and "checked" or "",
|
||||||
|
game_open_no = not game_open and "checked" or ""
|
||||||
|
})
|
||||||
|
7
routes/admin/config/post.lua
Normal file
7
routes/admin/config/post.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
if to_bool(ctx.form.game_open) then
|
||||||
|
env_set("game_open", true)
|
||||||
|
else
|
||||||
|
env_set("game_open", false)
|
||||||
|
end
|
||||||
|
|
||||||
|
http_redirect("/admin/config")
|
Loading…
x
Reference in New Issue
Block a user