aboutsummaryrefslogtreecommitdiff
path: root/src/guff/api-methods.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/guff/api-methods.cr')
-rw-r--r--src/guff/api-methods.cr55
1 files changed, 54 insertions, 1 deletions
diff --git a/src/guff/api-methods.cr b/src/guff/api-methods.cr
index 14c71c2..334be88 100644
--- a/src/guff/api-methods.cr
+++ b/src/guff/api-methods.cr
@@ -77,6 +77,41 @@ module Guff
},
},
+ "update_post": {
+ text: "Update existing post.",
+ args: {
+ "name": {
+ text: "Post title.",
+ type: :text,
+ required: false,
+ },
+
+ "slug": {
+ text: "Post slug.",
+ type: :slug,
+ required: false,
+ },
+
+ "body": {
+ text: "Post body.",
+ type: :text,
+ required: false,
+ },
+
+ "tags": {
+ text: "Post tags.",
+ type: :json,
+ required: false,
+ },
+
+ "posted": {
+ text: "Is this post posted?",
+ type: :bool,
+ required: false,
+ },
+ },
+ },
+
"remove_posts": {
text: "Remove existing posts.",
@@ -353,7 +388,7 @@ module Guff
site_id: get_site(context),
slug: args["slug"],
name: args["name"],
- body: args["name"],
+ body: args["body"],
tags: get_tags(args["tags"]?),
)
@@ -361,6 +396,24 @@ module Guff
{ post_id: post_id }.to_json
end
+ private def do_post_update_post(
+ context : HTTP::Server::Context,
+ args : Hash(String, String)
+ )
+ post_id = @models.post.update_post(
+ site_id: get_site(context),
+ post_id: args["post_id"].to_i,
+ slug: args["slug"]?,
+ name: args["name"],
+ body: args["body"],
+ tags: args.has_key?("tags") ? get_tags(args["tags"]?) : nil,
+ posted: args["posted"]?,
+ )
+
+ # return json
+ { ok: true }.to_json
+ end
+
private def do_post_remove_posts(
context : HTTP::Server::Context,
args : Hash(String, String)