aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/themes/default/templates/blog-list-item.html8
-rw-r--r--src/guff/views/blog/list.cr19
-rw-r--r--src/guff/views/template-html.cr3
-rw-r--r--src/views/blog/list-item.ecr4
4 files changed, 23 insertions, 11 deletions
diff --git a/data/themes/default/templates/blog-list-item.html b/data/themes/default/templates/blog-list-item.html
new file mode 100644
index 0000000..f2c6c9f
--- /dev/null
+++ b/data/themes/default/templates/blog-list-item.html
@@ -0,0 +1,8 @@
+<div class='guff-blog-list-item'>
+ <b>%{name|h}</b><br/>
+ <b>
+ by <span class='user'>%{user_name|h}</span>
+ on <span class='date'>%{posted_at_text|h}</span>
+ </b><br/><br/>
+ %{body}
+</div>
diff --git a/src/guff/views/blog/list.cr b/src/guff/views/blog/list.cr
index a98131e..00bd587 100644
--- a/src/guff/views/blog/list.cr
+++ b/src/guff/views/blog/list.cr
@@ -19,15 +19,16 @@ class Guff::Views::Blog::ListView < Guff::Views::TemplateHTMLView
theme_id: site["theme_id"].as(Int64).to_i32,
theme_slug: site["theme_slug"].as(String),
template_id: "blog-list.html",
- data: {
- "name" => TITLE,
- "body" => String.build do |io|
- # render items
- results.rows.each do |row|
- ListItemView.new(context, row).to_s(io)
- end
- end,
- },
)
+
+ self.data = {
+ "name" => TITLE,
+ "body" => String.build do |io|
+ # render items
+ results.rows.each do |row|
+ theme_templates["blog-list-item.html"].run(io, row)
+ end
+ end,
+ } of String => String
end
end
diff --git a/src/guff/views/template-html.cr b/src/guff/views/template-html.cr
index 6ad5859..b7cd8e0 100644
--- a/src/guff/views/template-html.cr
+++ b/src/guff/views/template-html.cr
@@ -1,12 +1,13 @@
class Guff::Views::TemplateHTMLView < Guff::Views::HTMLView
getter :theme_templates
+ property :data
def initialize(
context : Context,
@theme_id : Int32,
@theme_slug : String,
@template_id : String,
- @data : Hash(String, String),
+ @data : Hash(String, String) = {} of String => String,
@extra_assets : Theme::Assets? = nil,
)
super(context)
diff --git a/src/views/blog/list-item.ecr b/src/views/blog/list-item.ecr
index 23b868e..9a3bc72 100644
--- a/src/views/blog/list-item.ecr
+++ b/src/views/blog/list-item.ecr
@@ -1,4 +1,6 @@
-<div class='post'>
+<%
+ # deprecated: replaced with theme templates
+%><div class='post'>
<b><%= h(@item["name"]) %></b><br/>
<b>
by <%= h(@item["user_name"]) %>