aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-27 22:09:34 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-27 22:09:34 -0400
commit911d4fa9eb9f42e65facfa63e46ffcba660766ad (patch)
tree31691585e7f8ceca8f51c878022f840e2e81618d /src
parent955d28062d6926b5ba30b4e306715e3b0454bd1b (diff)
downloadguff-911d4fa9eb9f42e65facfa63e46ffcba660766ad.tar.bz2
guff-911d4fa9eb9f42e65facfa63e46ffcba660766ad.zip
use theme templates for blog-post
Diffstat (limited to 'src')
-rw-r--r--src/guff/handlers.cr11
-rw-r--r--src/guff/views/blog/post.cr23
-rw-r--r--src/views/blog/post.ecr4
3 files changed, 27 insertions, 11 deletions
diff --git a/src/guff/handlers.cr b/src/guff/handlers.cr
index f0a8571..2670f89 100644
--- a/src/guff/handlers.cr
+++ b/src/guff/handlers.cr
@@ -444,20 +444,21 @@ module Guff::Handlers
$}x
def call(context : HTTP::Server::Context)
- if r = get(context.request)
+ site_id, r = get(context.request)
+ if site_id && r
context.response.headers["x-frame-options"] = "SAMEORIGIN"
context.response.content_type = "text/html; charset=utf-8"
context.response.status_code = 200
- Views::Blog::PostView.new(@context, r).to_s(context.response)
+ Views::Blog::PostView.new(@context, site_id, r).to_s(context.response)
else
# unknown page
call_next(context)
end
end
- private def get(request : HTTP::Request) : Hash(String, String)?
- r = nil
+ private def get(request : HTTP::Request)
+ site_id, r = nil, nil
if request.method == "GET"
if md = PATH_RE.match(request.path.not_nil!)
@@ -478,7 +479,7 @@ module Guff::Handlers
end
# return result
- r
+ {site_id, r}
end
end
diff --git a/src/guff/views/blog/post.cr b/src/guff/views/blog/post.cr
index 4b1dc1e..4bc5282 100644
--- a/src/guff/views/blog/post.cr
+++ b/src/guff/views/blog/post.cr
@@ -1,7 +1,20 @@
-class Guff::Views::Blog::PostView < Guff::Views::HTMLView
- def initialize(context : Context, @item : Hash(String, String))
- super(context)
- end
+require "../template-html"
+
+class Guff::Views::Blog::PostView < Guff::Views::TemplateHTMLView
+ def initialize(
+ context : Context,
+ site_id : Int64,
+ item : Hash(String, String)
+ )
+ # get site details
+ site = context.models.site.get(site_id)
- ECR.def_to_s("src/views/blog/post.ecr")
+ super(
+ context: context,
+ theme_id: site["theme_id"].as(Int64).to_i32,
+ theme_slug: site["theme_slug"].as(String),
+ template_id: "blog-post.html",
+ data: item,
+ )
+ end
end
diff --git a/src/views/blog/post.ecr b/src/views/blog/post.ecr
index d0aa534..08ac564 100644
--- a/src/views/blog/post.ecr
+++ b/src/views/blog/post.ecr
@@ -1,4 +1,6 @@
-<!DOCTYPE html>
+<%
+ # deprecated: switched to theme templates
+%><!DOCTYPE html>
<html lang='en-US'>
<head>
<meta charset="utf-8"/>