39 lines
934 B
Crystal
39 lines
934 B
Crystal
|
abstract class MainLayout
|
||
|
include Lucky::HTMLPage
|
||
|
|
||
|
# 'needs current_user : User' makes it so that the current_user
|
||
|
# is always required for pages using MainLayout
|
||
|
needs current_user : User
|
||
|
|
||
|
abstract def content
|
||
|
abstract def page_title
|
||
|
|
||
|
# The default page title. It is passed to `Shared::LayoutHead`.
|
||
|
#
|
||
|
# Add a `page_title` method to pages to override it. You can also remove
|
||
|
# This method so every page is required to have its own page title.
|
||
|
def page_title
|
||
|
"Welcome"
|
||
|
end
|
||
|
|
||
|
def render
|
||
|
html_doctype
|
||
|
|
||
|
html lang: "en" do
|
||
|
mount Shared::LayoutHead.new(page_title: page_title, context: @context)
|
||
|
|
||
|
body do
|
||
|
mount Shared::FlashMessages.new(@context.flash)
|
||
|
render_signed_in_user
|
||
|
content
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
|
||
|
private def render_signed_in_user
|
||
|
text @current_user.email
|
||
|
text " - "
|
||
|
link "Sign out", to: SignIns::Delete, flow_id: "sign-out-button"
|
||
|
end
|
||
|
end
|