2020-03-07 05:39:00 +01:00
|
|
|
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
|
2020-03-07 23:32:07 +01:00
|
|
|
text @current_user.name
|
2020-03-07 05:39:00 +01:00
|
|
|
text " - "
|
2020-03-07 23:32:07 +01:00
|
|
|
link "Sign out", to: SignIn::Delete, flow_id: "sign-out-button"
|
2020-03-07 05:39:00 +01:00
|
|
|
end
|
|
|
|
end
|