diff --git a/data/.env b/data/.env index 6e8667a..be0530c 100644 --- a/data/.env +++ b/data/.env @@ -1,3 +1,3 @@ -# Environment variables for Moonshark -# Generated automatically - you can edit this file +# env variables - generated automatically - you can edit this file +game_open=true diff --git a/data/dk.db b/data/dk.db index 99c9d36..e8f4d9b 100644 Binary files a/data/dk.db and b/data/dk.db differ diff --git a/fs/templates/admin/config.html b/fs/templates/admin/config.html index b1f4dd9..31962c2 100644 --- a/fs/templates/admin/config.html +++ b/fs/templates/admin/config.html @@ -1,3 +1,13 @@

Config

-Hiiiii! +
+
+

Game Open

+ + + + +
+ + +
diff --git a/fs/templates/admin/layout.html b/fs/templates/admin/layout.html index e9ccb25..2efc06b 100644 --- a/fs/templates/admin/layout.html +++ b/fs/templates/admin/layout.html @@ -37,7 +37,7 @@
- {{{ content }}} + {{{ html }}}
diff --git a/libs/admin.lua b/libs/admin.lua index aef4fe8..d0bfb5b 100644 --- a/libs/admin.lua +++ b/libs/admin.lua @@ -1,24 +1,23 @@ local m = {} -function m.page(template, title) - local title = "Admin: "..title - - if ctx.headers["X-DK-AJAX"] then - return { - html = fs_read("templates/admin/"..template), - title = title - } +function m.page(template, title, ext_data) + if not title then + local title = "Admin" + else + local title = "Admin: "..title end - return send_html(render( - fs_read("templates/admin/layout.html"), - { + local data = table.merge({ title = title, - content = fs_read("templates/admin/"..template), version = "v1.0.0", 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 return m diff --git a/moonshark b/moonshark index 8307ca9..d046808 100755 Binary files a/moonshark and b/moonshark differ diff --git a/routes/admin/config/get.lua b/routes/admin/config/get.lua index 56a90db..d441c1b 100644 --- a/routes/admin/config/get.lua +++ b/routes/admin/config/get.lua @@ -1,2 +1,7 @@ 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 "" +}) diff --git a/routes/admin/config/post.lua b/routes/admin/config/post.lua new file mode 100644 index 0000000..10a27f3 --- /dev/null +++ b/routes/admin/config/post.lua @@ -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")