aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-27 07:29:09 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-27 07:29:09 -0400
commit34395459bbc90809c459ea348775f66fb20d3604 (patch)
treeedc9fd7e715178bc8385790e3d5e5ff2368c5dff /src
parent7c896b0612180104efc516d1f078b8400fa28fa9 (diff)
downloadguff-34395459bbc90809c459ea348775f66fb20d3604.tar.bz2
guff-34395459bbc90809c459ea348775f66fb20d3604.zip
clean up page view
Diffstat (limited to 'src')
-rw-r--r--src/guff/views/page.cr20
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