From f2691054f86ad45e90eb8473569def04ae3d95cd Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 10 Mar 2016 00:22:20 -0500 Subject: add blog test page --- src/guff/views/ecrs/test.ecr | 167 +++++++++++++++++++++++++++++++++++++++++++ src/guff/views/html/test.cr | 33 +++++++++ 2 files changed, 200 insertions(+) create mode 100644 src/guff/views/ecrs/test.ecr create mode 100644 src/guff/views/html/test.cr (limited to 'src/guff/views') diff --git a/src/guff/views/ecrs/test.ecr b/src/guff/views/ecrs/test.ecr new file mode 100644 index 0000000..d36b62c --- /dev/null +++ b/src/guff/views/ecrs/test.ecr @@ -0,0 +1,167 @@ +

<%= h(TITLE) %>

+ +<% + [{ + id: "draft", + name: "Draft Posts", + + actions: [{ + id: "posted", + name: "Post", + }, { + id: "deleted", + name: "Delete", + }], + }, { + id: "posted", + name: "Posted", + + actions: [{ + id: "draft", + name: "Draft", + }, { + id: "deleted", + name: "Delete", + }], + }, { + id: "deleted", + name: "Deleted Posts", + + actions: [{ + id: "draft", + name: "Draft", + }], + }].each do |kind| +%> +

<%= + h(kind[:name] as String) + %>

+ + + + + + + + + + + + + <% posts(kind[:id] as String).rows.each do |post| %> + + + + + + + + + + <% (kind[:actions] as Array(Hash(Symbol, String))).each do |a| %> + + <% end %> + + <% end %> +
IDCreated AtNameBodyActions
<%= + h(post.row["post_id"].to_s) + %><%= + h(post.row["created_at"].to_s) + %><%= + h(post.row["name"].to_s) + %><%= + post.row["body"].to_s + %> +
+ + + + + +
+
+<% end %> + +
+
+
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ + +
+
diff --git a/src/guff/views/html/test.cr b/src/guff/views/html/test.cr new file mode 100644 index 0000000..e31ebdb --- /dev/null +++ b/src/guff/views/html/test.cr @@ -0,0 +1,33 @@ +require "html" +require "ecr/macros" +require "./page" + +class Guff::TestHTMLView + TITLE = "Guff Tests" + + def self.run(models, context : HTTP::Server::Context) + new(models).run(context) + end + + def initialize(@models : Models) + end + + def run(context) + page = PageHTMLView.new(TITLE, self.to_s) + context.response.content_type = page.content_type + context.response.puts page + end + + private def posts(state : String) + @models.post.get_posts( + tags: [["_blog"]], + filters: { state: state } + ) + end + + def h(s : String) + HTML.escape(s || "") + end + + ECR.def_to_s("./src/guff/views/ecrs/test.ecr") +end -- cgit v1.2.3