1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
|