From 7c896b0612180104efc516d1f078b8400fa28fa9 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Mon, 25 Jul 2016 22:09:32 -0400 Subject: add theme assets to page renderer --- data/themes/default/guff-manifest.json | 4 ++-- src/guff/views/page.cr | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/data/themes/default/guff-manifest.json b/data/themes/default/guff-manifest.json index 2f402df..44e7abe 100644 --- a/data/themes/default/guff-manifest.json +++ b/data/themes/default/guff-manifest.json @@ -8,7 +8,7 @@ }, "assets": { - "scripts": [], - "styles": [] + "scripts": ["script.js"], + "styles": ["style.css"] } } diff --git a/src/guff/views/page.cr b/src/guff/views/page.cr index eb53dec..b1019a6 100644 --- a/src/guff/views/page.cr +++ b/src/guff/views/page.cr @@ -12,12 +12,16 @@ class Guff::Views::PageView < Guff::Views::HTMLView end private def scripts - super(theme_assets.scripts) + super(theme_assets.scripts.map { |val| + "/guff/themes/%s/%s" % [theme_slug, val] + }) # TODO: allow page-specific scripts end private def styles - super(theme_assets.styles) + super(theme_assets.styles.map { |val| + "/guff/themes/%s/%s" % [theme_slug, val] + }) # TODO: allow page-specific styles end @@ -25,5 +29,9 @@ 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