aboutsummaryrefslogtreecommitdiff
path: root/src/guff.cr
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-05-24 21:14:13 -0400
committerPaul Duncan <pabs@pablotron.org>2016-05-24 21:14:13 -0400
commitc5da1e620c07697c2b7b5d4b51db73ef0fc143e4 (patch)
tree395c5d57bf9025d8ffc544fb2f4c32efc5efc883 /src/guff.cr
parentfbff52e48d4591a752d83fbebb49a3a355eef5ae (diff)
downloadguff-c5da1e620c07697c2b7b5d4b51db73ef0fc143e4.tar.bz2
guff-c5da1e620c07697c2b7b5d4b51db73ef0fc143e4.zip
add state filter and dropdown.js
Diffstat (limited to 'src/guff.cr')
-rw-r--r--src/guff.cr28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/guff.cr b/src/guff.cr
index 121f150..d3817d0 100644
--- a/src/guff.cr
+++ b/src/guff.cr
@@ -460,11 +460,11 @@ module Guff
LIMIT = 50
def get_posts(
- site_id : Int64? = nil,
- post_type : String? = nil,
- state : String? = nil,
- q : String? = nil,
- page : Int32 = 1,
+ site_id : Int64? = nil,
+ type : String? = nil,
+ state : String? = nil,
+ q : String? = nil,
+ page : Int32 = 1,
)
filters = %w{1}
args = [] of String
@@ -478,9 +478,9 @@ module Guff
args << site_id.to_s
end
- if post_type
+ if type
# add type filter
- filters << case post_type
+ filters << case type
when "blog"
"x.post_id IS NOT NULL"
when "page"
@@ -491,11 +491,11 @@ module Guff
# allow "all"
"1"
else
- raise "unknown post type: #{post_type}"
+ raise "unknown post type: #{type}"
end
end
- if state
+ if state && state != "default"
# add state filter
filters << "b.state = ?"
args << state
@@ -1450,11 +1450,11 @@ module Guff
module PostAPI
def do_post_get_posts(params : HTTP::Params)
@context.models.post.get_posts(
- site_id: params["site_id"]? ? params["site_id"].to_i64 : nil,
- state: params["state"]?,
- post_type: params["post_type"]?,
- q: params["q"]?,
- page: params["page"].to_i32,
+ site_id: params["site_id"]? ? params["site_id"].to_i64 : nil,
+ state: params["state"]?,
+ type: params["type"]?,
+ q: params["q"]?,
+ page: params["page"].to_i32,
)
end
end