diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-09 13:38:24 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-09 13:38:24 -0500 |
commit | 7417966101a0b0bbd0fefc8723482ae5a2010f19 (patch) | |
tree | 9865c76ee5f40a55a7364c316b7cf1c1bb82485c /src/guff/api | |
parent | 019667042398a78cf58e6475c81e5c75c4fff895 (diff) | |
download | old-guff-7417966101a0b0bbd0fefc8723482ae5a2010f19.tar.bz2 old-guff-7417966101a0b0bbd0fefc8723482ae5a2010f19.zip |
add state support
Diffstat (limited to 'src/guff/api')
-rw-r--r-- | src/guff/api/methods.cr | 32 | ||||
-rw-r--r-- | src/guff/api/post.cr | 9 |
2 files changed, 30 insertions, 11 deletions
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 |