From 34395459bbc90809c459ea348775f66fb20d3604 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 27 Jul 2016 07:29:09 -0400 Subject: clean up page view --- src/guff/views/page.cr | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/guff/views/page.cr b/src/guff/views/page.cr index b1019a6..262f30c 100644 --- a/src/guff/views/page.cr +++ b/src/guff/views/page.cr @@ -2,25 +2,25 @@ class Guff::Views::PageView < Guff::Views::HTMLView def initialize(context : Context, @item : Hash(String, String)) super(context) - # FIXME: remove -1 hack - @theme_id = -1_i32 - if tmp_theme_id = @item[%w{theme_id site_theme_id}.find { |k| + # get theme id + @theme_id = @item[%w{theme_id site_theme_id}.find { |k| @item[k]? && @item[k].size > 0 - }] - @theme_id = tmp_theme_id.to_i32 - end + }].not_nil!.to_i32 as Int32 + + # get theme slug + @theme_slug = @context.models.theme.get(@theme_id)["theme_slug"] as String end private def scripts super(theme_assets.scripts.map { |val| - "/guff/themes/%s/%s" % [theme_slug, val] + "/guff/themes/%s/%s" % [@theme_slug, val] }) # TODO: allow page-specific scripts end private def styles super(theme_assets.styles.map { |val| - "/guff/themes/%s/%s" % [theme_slug, val] + "/guff/themes/%s/%s" % [@theme_slug, val] }) # TODO: allow page-specific styles end @@ -29,9 +29,5 @@ class Guff::Views::PageView < Guff::Views::HTMLView @context.models.theme.assets(@theme_id) end - private def theme_slug : String - @theme_slug ||= @context.models.theme.get(@theme_id)["theme_slug"] as String - end - ECR.def_to_s("src/views/page.ecr") end -- cgit v1.2.3