diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-03-08 23:22:03 -0500 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-03-08 23:22:03 -0500 |
commit | 94529553ac724a11b6821dd1374c98b0f51b4f14 (patch) | |
tree | 61217fd1d344a57a90456e12f62a0358a4863f8b /src/guff/models | |
parent | 6d3952936c2408f7525941e677db25fb59d34d9b (diff) | |
download | old-guff-94529553ac724a11b6821dd1374c98b0f51b4f14.tar.bz2 old-guff-94529553ac724a11b6821dd1374c98b0f51b4f14.zip |
initial page rendering
Diffstat (limited to 'src/guff/models')
-rw-r--r-- | src/guff/models/post.cr | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/guff/models/post.cr b/src/guff/models/post.cr index 580a9b7..3c4212b 100644 --- a/src/guff/models/post.cr +++ b/src/guff/models/post.cr @@ -96,6 +96,12 @@ module Guff clause: "a.post_id", }, + "slug": { + default: true, + sortable: true, + clause: "a.slug", + }, + "name": { default: true, sortable: true, @@ -103,7 +109,7 @@ module Guff }, "body": { - default: false, + default: true, sortable: true, clause: "a.body", }, @@ -215,6 +221,10 @@ module Guff strftime('%s', a.posted_at) + 0 = %d )" + SLUG_FILTER_CLAUSE = "( + a.slug = '%s' + )" + private def get_filter_clause( filters : Hash(Symbol, String) ) : String @@ -236,6 +246,11 @@ module Guff # TODO end + # add slug filter + if filters.has_key?(:slug) + r << SLUG_FILTER_CLAUSE % [@db.quote(filters[:slug])] + end + # return result r.join(" AND ") end |