aboutsummaryrefslogtreecommitdiff
path: root/src/pages/main_layout.cr
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/main_layout.cr')
-rw-r--r--src/pages/main_layout.cr45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/pages/main_layout.cr b/src/pages/main_layout.cr
new file mode 100644
index 0000000..06a1ed7
--- /dev/null
+++ b/src/pages/main_layout.cr
@@ -0,0 +1,45 @@
+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
+
+ # MainLayout defines a default 'page_title'.
+ #
+ # Add a 'page_title' method to your indivual pages to customize each page's
+ # title.
+ #
+ # Or, if you want to require every page to set a title, change the
+ # 'page_title' method in this layout to:
+ #
+ # abstract def page_title : String
+ #
+ # This will force pages to define their own 'page_title' method.
+ def page_title
+ "Welcome"
+ end
+
+ def render
+ html_doctype
+
+ html lang: "en" do
+ mount Shared::LayoutHead, page_title: page_title
+
+ body do
+ mount Shared::FlashMessages, 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