diff --git a/fs/templates/admin/config.html b/fs/templates/admin/config.html index 31962c2..f3a17c8 100644 --- a/fs/templates/admin/config.html +++ b/fs/templates/admin/config.html @@ -1,4 +1,8 @@ -

Config

+{{ if has_flash_success() then }} +
+ {{ get_flash_success() }} +
+{{ end }}
diff --git a/fs/templates/admin/news.html b/fs/templates/admin/news.html new file mode 100644 index 0000000..842e8a6 --- /dev/null +++ b/fs/templates/admin/news.html @@ -0,0 +1,27 @@ +

Here you can write a new news article. This will replace the current one on town pages.

+ + + +
+ + +
+ + + + diff --git a/moonshark b/moonshark index d046808..467589d 100755 Binary files a/moonshark and b/moonshark differ diff --git a/public/css/buttons.css b/public/css/buttons.css index deaf8df..d96d6b0 100644 --- a/public/css/buttons.css +++ b/public/css/buttons.css @@ -2,7 +2,6 @@ cursor: pointer; display: inline-block; border: none; - font-size: 1rem; background: #f7f8fa linear-gradient(rgba(255, 255, 255, 0), rgba(0, 0, 0, 0.1)); box-shadow: 0 1px 0 1px rgba(255, 255, 255, 0.3) inset, 0 0 0 1px #adb2bb inset; color: #111111; diff --git a/routes/admin/config/post.lua b/routes/admin/config/post.lua index 10a27f3..876f195 100644 --- a/routes/admin/config/post.lua +++ b/routes/admin/config/post.lua @@ -4,4 +4,5 @@ else env_set("game_open", false) end -http_redirect("/admin/config") +redirect_with_success("/admin/config", "Config saved successfully") +--http_redirect("/admin/config") diff --git a/routes/admin/news/get.lua b/routes/admin/news/get.lua new file mode 100644 index 0000000..95bfcc7 --- /dev/null +++ b/routes/admin/news/get.lua @@ -0,0 +1,5 @@ +local a = require("admin") + +local d = sqlite("dk"):get_one("SELECT username FROM users WHERE id = :i", {i = session_get("user_id")}) + +return a.page("news.html", "News", {username = d.username}) diff --git a/routes/admin/news/post.lua b/routes/admin/news/post.lua new file mode 100644 index 0000000..4f4b18a --- /dev/null +++ b/routes/admin/news/post.lua @@ -0,0 +1,12 @@ +local content = string.trim(ctx.form.content) +if content == "" then return { success = 0, message = "Content is required" } end + +local author = string.trim(ctx.form.author) +if author == "" then return { success = 0, message = "Author is required" } end + +sqlite("dk"):insert("news", { + content = content, + author = author +}) + +return { success = 1, message = "News posted successfully" } diff --git a/setup_database.lua b/setup.lua similarity index 99% rename from setup_database.lua rename to setup.lua index b7aed82..ff4b3c9 100644 --- a/setup_database.lua +++ b/setup.lua @@ -140,6 +140,7 @@ db:create_table("monsters", db:create_table("news", "id INTEGER PRIMARY KEY AUTOINCREMENT", "posted INTEGER NOT NULL DEFAULT (unixepoch())", + "type INTEGER NOT NULL DEFAULT 0", "author TEXT NOT NULL DEFAULT 'Guild Master'", "content TEXT NOT NULL" )