diff options
author | Paul Duncan <pabs@pablotron.org> | 2016-07-25 22:09:32 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2016-07-25 22:09:32 -0400 |
commit | 7c896b0612180104efc516d1f078b8400fa28fa9 (patch) | |
tree | 613dbfde3d09530321c9742ba7e3fd9aa34f3c65 | |
parent | c2a20d2fdef43cf2967919295ba7cf6ecffe57fc (diff) | |
download | guff-7c896b0612180104efc516d1f078b8400fa28fa9.tar.bz2 guff-7c896b0612180104efc516d1f078b8400fa28fa9.zip |
add theme assets to page renderer
-rw-r--r-- | data/themes/default/guff-manifest.json | 4 | ||||
-rw-r--r-- | 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 |