Skip to content

Commit

Permalink
Convert AuthLayout into a module
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Jul 22, 2024
1 parent 3fc3681 commit b7014b9
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 30 deletions.
25 changes: 0 additions & 25 deletions src/pages/auth_layout.cr

This file was deleted.

4 changes: 3 additions & 1 deletion src/pages/current_login/new_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct CurrentLogin::NewPage < AuthLayout
struct CurrentLogin::NewPage
include Mixins::AuthLayout

needs operation : StartCurrentLogin

def page_title
Expand Down
4 changes: 3 additions & 1 deletion src/pages/current_user/new_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct CurrentUser::NewPage < AuthLayout
struct CurrentUser::NewPage
include Mixins::AuthLayout

needs operation : RegisterCurrentUser

include Mixins::PageParamKey
Expand Down
4 changes: 3 additions & 1 deletion src/pages/email_confirmations/new_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct EmailConfirmations::NewPage < AuthLayout
struct EmailConfirmations::NewPage
include Mixins::AuthLayout

needs operation : StartEmailConfirmation

def page_title
Expand Down
27 changes: 27 additions & 0 deletions src/pages/mixins/auth_layout.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Mixins::AuthLayout
macro included
include Lucky::HTMLPage
include Mixins::LinkTextHelpers

# 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
Rex.t(:"page.misc.page_title")
end

def render
html_doctype

html lang: "en" do
mount Shared::LayoutHead, page_title: page_title

body do
mount Shared::FlashMessages, flash: context.flash
content
end
end
end
end
end
4 changes: 3 additions & 1 deletion src/pages/password_resets/edit_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct PasswordResets::EditPage < AuthLayout
struct PasswordResets::EditPage
include Mixins::AuthLayout

needs operation : ResetPassword

def page_title
Expand Down
4 changes: 3 additions & 1 deletion src/pages/password_resets/new_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct PasswordResets::NewPage < AuthLayout
struct PasswordResets::NewPage
include Mixins::AuthLayout

needs operation : StartPasswordReset

def page_title
Expand Down

0 comments on commit b7014b9

Please sign in to comment.