diff options
Diffstat (limited to 'src/guff/post-model.cr')
-rw-r--r-- | src/guff/post-model.cr | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/guff/post-model.cr b/src/guff/post-model.cr index 0a78458..40e92fb 100644 --- a/src/guff/post-model.cr +++ b/src/guff/post-model.cr @@ -40,7 +40,12 @@ module Guff AND %{filter} ORDER BY %{sort} %{dir} - OFFSET :offset LIMIT :limit + LIMIT :limit OFFSET :offset + ", + + add_post: " + INSERT INTO posts(site_id, slug, name, raw_body, body) + VALUES (:site_id, :slug, :name, :raw_body, :body) ", remove_posts: " @@ -68,6 +73,7 @@ module Guff CROSS JOIN tags b WHERE a.site_id = :site_id + AND a.post_id = :post_id AND b.name IN (%{tags}) ", }) @@ -95,10 +101,10 @@ module Guff clause: "a.body", }, - "html": { - default: true, + "raw_body": { + default: false, sortable: true, - clause: "a.html", + clause: "a.raw_body", }, "posted_at": { @@ -117,13 +123,13 @@ module Guff default: true, sortable: false, clause: " - (SELECT group_agg(d.name, '|') + (SELECT group_concat(d.name, '|') FROM post_tags c JOIN tags d ON (d.tag_id = c.tag_id) - WHERE d.post_id = a.post_id) + WHERE c.post_id = a.post_id) ", }, } @@ -164,8 +170,8 @@ module Guff rows = [] of Post if num_rows > 0 all(:get_posts, sql_args.merge({ - ":offset": ((page - 1) * limit).to_s, - ":limit": limit.to_s, + "offset": ((page - 1) * limit).to_s, + "limit": limit.to_s, }), tmpl_args) do |row| rows << Post.new(row) nil |