aboutsummaryrefslogtreecommitdiff
path: root/src/guff/views
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-03-10 09:51:51 -0500
committerPaul Duncan <pabs@pablotron.org>2016-03-10 09:51:51 -0500
commit003dddfb60e8768d0a481734626fb7c829fe326d (patch)
tree8e34541f48cf993574346eef3ce2756a63a96068 /src/guff/views
parentf7b868318bbe6ddb0b1005af5bb88955f0cbe95f (diff)
downloadold-guff-003dddfb60e8768d0a481734626fb7c829fe326d.tar.bz2
old-guff-003dddfb60e8768d0a481734626fb7c829fe326d.zip
add count to set title
Diffstat (limited to 'src/guff/views')
-rw-r--r--src/guff/views/ecrs/test-blog.ecr8
-rw-r--r--src/guff/views/html/test-blog.cr12
2 files changed, 16 insertions, 4 deletions
diff --git a/src/guff/views/ecrs/test-blog.ecr b/src/guff/views/ecrs/test-blog.ecr
index c5e2d9b..1ce4347 100644
--- a/src/guff/views/ecrs/test-blog.ecr
+++ b/src/guff/views/ecrs/test-blog.ecr
@@ -3,9 +3,11 @@
<table>
<thead>
<tr><% POST_SETS.each do |set| %>
- <th><h2><%=
- h(set[:name] as String)
- %></h2></th>
+ <th>
+ <h2><%=
+ h(set_name(set))
+ %></h2>
+ </th>
<% end %></tr>
</thead>
diff --git a/src/guff/views/html/test-blog.cr b/src/guff/views/html/test-blog.cr
index 9ad91f3..696bfbb 100644
--- a/src/guff/views/html/test-blog.cr
+++ b/src/guff/views/html/test-blog.cr
@@ -42,6 +42,7 @@ class Guff::TestBlogHTMLView
end
def initialize(@models : Models)
+ @posts = {} of String => Results(Post)
end
def run(context)
@@ -51,12 +52,21 @@ class Guff::TestBlogHTMLView
end
private def posts(state : String)
- @models.post.get_posts(
+ @posts[state] ||= @models.post.get_posts(
tags: [["_blog"]],
filters: { state: state }
)
end
+ SET_TITLE_FORMAT = "%s (%d posts)"
+
+ private def set_name(set)
+ "%s (%d posts)" % [
+ set[:name] as String,
+ posts(set[:id] as String).num_rows
+ ]
+ end
+
def h(s : String)
HTML.escape(s || "")
end