diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/guff/views/page.cr | 20 |
1 files 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 |