From 5d7cd9615840341d2ccab1d8b7acfd49d6a5b743 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 10 Mar 2016 09:25:07 -0500 Subject: rename test to test-blog --- src/guff/views/ecrs/test-blog.ecr | 137 +++++++++++++++++++++++++++++++ src/guff/views/ecrs/test.ecr | 167 -------------------------------------- src/guff/views/html/test-blog.cr | 65 +++++++++++++++ src/guff/views/html/test.cr | 33 -------- 4 files changed, 202 insertions(+), 200 deletions(-) create mode 100644 src/guff/views/ecrs/test-blog.ecr delete mode 100644 src/guff/views/ecrs/test.ecr create mode 100644 src/guff/views/html/test-blog.cr delete mode 100644 src/guff/views/html/test.cr (limited to 'src/guff/views') diff --git a/src/guff/views/ecrs/test-blog.ecr b/src/guff/views/ecrs/test-blog.ecr new file mode 100644 index 0000000..f28966a --- /dev/null +++ b/src/guff/views/ecrs/test-blog.ecr @@ -0,0 +1,137 @@ +

<%= h(TITLE) %>

+ +<% + POST_SETS.each do |set| +%> +

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

+ + + + + + + + + + + + + <% posts(set[:id] as String).rows.each do |post| %> + + + + + + + + + + <% (set[: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/ecrs/test.ecr b/src/guff/views/ecrs/test.ecr deleted file mode 100644 index d36b62c..0000000 --- a/src/guff/views/ecrs/test.ecr +++ /dev/null @@ -1,167 +0,0 @@ -

<%= 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-blog.cr b/src/guff/views/html/test-blog.cr new file mode 100644 index 0000000..9ad91f3 --- /dev/null +++ b/src/guff/views/html/test-blog.cr @@ -0,0 +1,65 @@ +require "html" +require "ecr/macros" +require "./page" + +class Guff::TestBlogHTMLView + TITLE = "Guff Blog Test" + + POST_SETS = [{ + id: "draft", + name: "Drafts", + + 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", + }], + }] + + 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-blog.ecr") +end diff --git a/src/guff/views/html/test.cr b/src/guff/views/html/test.cr deleted file mode 100644 index 37317e5..0000000 --- a/src/guff/views/html/test.cr +++ /dev/null @@ -1,33 +0,0 @@ -require "html" -require "ecr/macros" -require "./page" - -class Guff::TestHTMLView - TITLE = "Guff Blog Test" - - 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