From 7417966101a0b0bbd0fefc8723482ae5a2010f19 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 9 Mar 2016 13:38:24 -0500 Subject: add state support --- src/guff/api/methods.cr | 32 ++++++++++++++++++++++++-------- src/guff/api/post.cr | 9 ++++++--- 2 files changed, 30 insertions(+), 11 deletions(-) (limited to 'src/guff/api') diff --git a/src/guff/api/methods.cr b/src/guff/api/methods.cr index f3a7f3c..6c38eb3 100644 --- a/src/guff/api/methods.cr +++ b/src/guff/api/methods.cr @@ -13,7 +13,6 @@ module Guff text: "Search string.", type: :text, required: false, - default: "", }, "year": { @@ -43,17 +42,14 @@ module Guff "tags": { text: "Comma-separated list of tags (union)", - # type: :tag_list, type: :json, required: false, - default: "", }, "sort": { text: "Sort order of results", type: :sort, required: false, - default: "date,desc", }, "cols": { @@ -61,6 +57,19 @@ module Guff type: :text, required: false, }, + + "slug": { + text: "Post slug", + type: :text, + required: false, + }, + + "state": { + text: "Post state (draft, posted, deleted)", + type: :state, + required: false, + default: "posted", + }, }, }, @@ -90,7 +99,13 @@ module Guff # type: :tag_list, type: :json, required: false, - default: "", + }, + + "state": { + text: "Post state (draft, posted, deleted)", + type: :state, + required: false, + default: "draft", }, }, }, @@ -122,9 +137,9 @@ module Guff required: false, }, - "posted": { - text: "Is this post posted?", - type: :bool, + "state": { + text: "Post state (draft, posted, deleted)", + type: :state, required: false, }, }, @@ -326,6 +341,7 @@ module Guff int: /^\d+$/, int_list: /^\d+(?:,\d+)*$/, sort: /^[a-z0-9_]+,(?:asc|desc)$/, + state: /^(?:draft|posted|deleted)$/, # FIXME: lock these down more json: /.*/, diff --git a/src/guff/api/post.cr b/src/guff/api/post.cr index 55abd86..499e7c0 100644 --- a/src/guff/api/post.cr +++ b/src/guff/api/post.cr @@ -8,6 +8,8 @@ module Guff year: "year", month: "month", day: "day", + slug: "slug", + state: "state", } private def do_post_get_posts( @@ -39,6 +41,7 @@ module Guff name: args["name"], body: args["body"], tags: get_tags(args["tags"]?), + state: args["state"]?, ) # return json @@ -53,10 +56,10 @@ module Guff site_id: get_site(context), post_id: args["post_id"].to_i, slug: args["slug"]?, - name: args["name"], - body: args["body"], + name: args["name"]?, + body: args["body"]?, tags: args.has_key?("tags") ? get_tags(args["tags"]?) : nil, - posted: args.has_key?("posted") ? (args["posted"] == "t") : nil, + state: args["state"]?, ) # return json -- cgit v1.2.3