Pass in admin information when rendering all pages

This commit is contained in:
Alex Ling 2020-04-03 23:31:24 +00:00
parent b7c0515af7
commit 1d4237d687

View File

@ -3,7 +3,17 @@ require "big"
IMGS_PER_PAGE = 5
macro layout(name)
begin
cookie = env.request.cookies.find { |c| c.name == "token" }
is_admin = false
unless cookie.nil?
is_admin = @context.storage.verify_admin cookie.value
end
render "src/views/#{{{name}}}.ecr", "src/views/layout.ecr"
rescue e
message = e.to_s
render "message"
end
end
macro send_img(env, img)