diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-07-15 19:46:16 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-07-15 19:46:16 -0400 |
commit | 7577c32a83d2897617fb60f488d6d71cd23be698 (patch) | |
tree | afb2a59e5d70a642cecd132bde1d67b5b71fc8a1 /src/guff.cr | |
parent | fdae24c68dfc35173b0a6c2b6d9e81bb0b3f9b00 (diff) | |
download | guff-7577c32a83d2897617fb60f488d6d71cd23be698.tar.bz2 guff-7577c32a83d2897617fb60f488d6d71cd23be698.zip |
add initial blog list templates
Diffstat (limited to 'src/guff.cr')
-rw-r--r-- | src/guff.cr | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/guff.cr b/src/guff.cr index 2343d12..9791288 100644 --- a/src/guff.cr +++ b/src/guff.cr @@ -2122,8 +2122,33 @@ module Guff ECR.def_to_s("src/views/logout-page.ecr") end + class BlogListItemView < HTMLView + def initialize(context : Context, @post_id : Int64) + super(context) + end + + ECR.def_to_s("src/views/blog/list-item.ecr") + end + + # + # TODO: add y/m/d/page + # class BlogListView < HTMLView - ECR.def_to_s("src/views/blog-list.ecr") + TITLE = "Blog List" + + def initialize(context : Context, @post_ids : Array(Int64)) + super(context) + end + + def posts + String.build do |io| + @post_ids.each do |id| + BlogListItemView.new(@context, id).to_s(io) + end + end + end + + ECR.def_to_s("src/views/blog/list.ecr") end end @@ -2599,7 +2624,8 @@ module Guff context.response.headers["x-frame-options"] = "SAMEORIGIN" context.response.content_type = "text/html; charset=utf-8" context.response.status_code = 200 - context.response << "blog list: ids = #{ids.join(", ")}" + + Views::BlogListView.new(@context, ids).to_s(context.response) else # unknown page call_next(context) |