blob: 95f91bd986a237f25fceb460bbb67bf8e72ebf40 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
class Guff::Views::PageView < Guff::Views::HTMLView
def initialize(context : Context, @item : Hash(String, String))
super(context)
# get theme id
@theme_id = @item[%w{theme_id site_theme_id}.find { |k|
@item[k]? && @item[k].size > 0
}].not_nil!.to_i32 as Int32
# get theme slug
@theme_slug = @context.models.theme.get(@theme_id)["theme_slug"] as String
# get theme assets
@theme_assets = @context.models.theme.assets(@theme_id) as Theme::Assets
# get page assets
@page_assets = @context.models.page.assets(@item["post_id"].to_i64) as Theme::Assets
end
private def scripts
super(@theme_assets.scripts.map { |val|
theme_asset_path(val)
} + @page_assets.scripts)
end
private def styles
super(@theme_assets.styles.map { |val|
theme_asset_path(val)
} + @page_assets.styles)
end
THEME_ASSET_PATH = "/guff/themes/%s/%s"
private def theme_asset_path(asset_path : String)
THEME_ASSET_PATH % [@theme_slug, asset_path]
end
ECR.def_to_s("src/views/page.ecr")
end
|