Skip to content

Commit

Permalink
Convert MainLayout into a module
Browse files Browse the repository at this point in the history
  • Loading branch information
akadusei committed Jul 22, 2024
1 parent b7014b9 commit 425edb0
Show file tree
Hide file tree
Showing 26 changed files with 105 additions and 55 deletions.
4 changes: 3 additions & 1 deletion src/pages/bearer_logins/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct BearerLogins::IndexPage < MainLayout
struct BearerLogins::IndexPage
include Mixins::MainLayout

needs bearer_logins : Array(BearerLogin)
needs pages : Lucky::Paginator

Expand Down
4 changes: 3 additions & 1 deletion src/pages/bearer_logins/show_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# struct BearerLogins::ShowPage < MainLayout
# struct BearerLogins::ShowPage
# include Mixins::MainLayout

# needs bearer_login : BearerLogin

# def page_title
Expand Down
4 changes: 3 additions & 1 deletion src/pages/bearer_logins/token/show_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct BearerLogins::Token::ShowPage < MainLayout
struct BearerLogins::Token::ShowPage
include Mixins::MainLayout

needs bearer_login : BearerLogin
needs token : String

Expand Down
4 changes: 3 additions & 1 deletion src/pages/current_user/bearer_logins/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct CurrentUser::BearerLogins::IndexPage < MainLayout
struct CurrentUser::BearerLogins::IndexPage
include Mixins::MainLayout

needs bearer_logins : Array(BearerLogin)
needs pages : Lucky::Paginator

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

needs operation : CreateBearerLogin

include Mixins::PageParamKey
Expand Down
4 changes: 3 additions & 1 deletion src/pages/current_user/edit_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct CurrentUser::EditPage < MainLayout
struct CurrentUser::EditPage
include Mixins::MainLayout

needs operation : UpdateCurrentUser

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

needs email_confirmations : Array(EmailConfirmation)
needs pages : Lucky::Paginator

Expand Down
4 changes: 3 additions & 1 deletion src/pages/current_user/logins/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct CurrentUser::Logins::IndexPage < MainLayout
struct CurrentUser::Logins::IndexPage
include Mixins::MainLayout

needs logins : Array(Login)
needs pages : Lucky::Paginator

Expand Down
4 changes: 3 additions & 1 deletion src/pages/current_user/password_resets/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct CurrentUser::PasswordResets::IndexPage < MainLayout
struct CurrentUser::PasswordResets::IndexPage
include Mixins::MainLayout

needs password_resets : Array(PasswordReset)
needs pages : Lucky::Paginator

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

needs user : User

def page_title
Expand Down
4 changes: 3 additions & 1 deletion src/pages/email_confirmations/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct EmailConfirmations::IndexPage < MainLayout
struct EmailConfirmations::IndexPage
include Mixins::MainLayout

needs email_confirmations : Array(EmailConfirmation)
needs pages : Lucky::Paginator

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

# needs email_confirmation : EmailConfirmation

# def page_title
Expand Down
4 changes: 3 additions & 1 deletion src/pages/home/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Home::IndexPage < MainLayout
struct Home::IndexPage
include Mixins::MainLayout

def page_title
""
end
Expand Down
4 changes: 3 additions & 1 deletion src/pages/logins/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Logins::IndexPage < MainLayout
struct Logins::IndexPage
include Mixins::MainLayout

needs logins : Array(Login)
needs pages : Lucky::Paginator

Expand Down
4 changes: 3 additions & 1 deletion src/pages/logins/show_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# struct Logins::ShowPage < MainLayout
# struct Logins::ShowPage
# include Mixins::MainLayout

# needs login : Login

# def page_title
Expand Down
31 changes: 0 additions & 31 deletions src/pages/main_layout.cr

This file was deleted.

33 changes: 33 additions & 0 deletions src/pages/mixins/main_layout.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Mixins::MainLayout
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
if current_user?.try(&.level.admin?)
mount Menus::AdminPrimary
else
mount Menus::Primary
end

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

needs password_resets : Array(PasswordReset)
needs pages : Lucky::Paginator

Expand Down
4 changes: 3 additions & 1 deletion src/pages/password_resets/show_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# struct PasswordResets::ShowPage < MainLayout
# struct PasswordResets::ShowPage
# include Mixins::MainLayout

# needs password_reset : PasswordReset

# def page_title
Expand Down
4 changes: 3 additions & 1 deletion src/pages/users/bearer_logins/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Users::BearerLogins::IndexPage < MainLayout
struct Users::BearerLogins::IndexPage
include Mixins::MainLayout

needs bearer_logins : Array(BearerLogin)
needs user : User
needs pages : Lucky::Paginator
Expand Down
4 changes: 3 additions & 1 deletion src/pages/users/edit_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Users::EditPage < MainLayout
struct Users::EditPage
include Mixins::MainLayout

needs operation : UpdateUser

def page_title
Expand Down
4 changes: 3 additions & 1 deletion src/pages/users/email_confirmations/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Users::EmailConfirmations::IndexPage < MainLayout
struct Users::EmailConfirmations::IndexPage
include Mixins::MainLayout

needs email_confirmations : Array(EmailConfirmation)
needs user : User
needs pages : Lucky::Paginator
Expand Down
4 changes: 3 additions & 1 deletion src/pages/users/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Users::IndexPage < MainLayout
struct Users::IndexPage
include Mixins::MainLayout

needs users : Array(User)
needs pages : Lucky::Paginator

Expand Down
4 changes: 3 additions & 1 deletion src/pages/users/logins/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Users::Logins::IndexPage < MainLayout
struct Users::Logins::IndexPage
include Mixins::MainLayout

needs logins : Array(Login)
needs user : User
needs pages : Lucky::Paginator
Expand Down
4 changes: 3 additions & 1 deletion src/pages/users/password_resets/index_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Users::PasswordResets::IndexPage < MainLayout
struct Users::PasswordResets::IndexPage
include Mixins::MainLayout

needs password_resets : Array(PasswordReset)
needs user : User
needs pages : Lucky::Paginator
Expand Down
4 changes: 3 additions & 1 deletion src/pages/users/show_page.cr
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
struct Users::ShowPage < MainLayout
struct Users::ShowPage
include Mixins::MainLayout

needs user : User

def page_title
Expand Down

0 comments on commit 425edb0

Please sign in to comment.