From ebcaf364ac82c5c1df2c57386fee56662a0a4b09 Mon Sep 17 00:00:00 2001 From: ngoomie Date: Thu, 8 Aug 2024 02:05:26 -0600 Subject: [PATCH] Move Crypt and Schema into Model namespace (#6) --- lib/CharmBoard.pm | 4 ++-- lib/CharmBoard/Controller/Login.pm | 4 ++-- lib/CharmBoard/Controller/Register.pm | 2 +- lib/CharmBoard/{ => Model}/Crypt/Password.pm | 10 +++++----- lib/CharmBoard/{ => Model}/Crypt/Seasoning.pm | 2 +- lib/CharmBoard/{ => Model}/Schema.pm | 2 +- lib/CharmBoard/{ => Model}/Schema/Set/Categories.pm | 4 ++-- lib/CharmBoard/{ => Model}/Schema/Set/Subforums.pm | 2 +- lib/CharmBoard/{ => Model}/Schema/Set/Threads.pm | 2 +- lib/CharmBoard/{ => Model}/Schema/Source/Categories.pm | 2 +- lib/CharmBoard/{ => Model}/Schema/Source/Posts.pm | 6 +++--- lib/CharmBoard/{ => Model}/Schema/Source/Session.pm | 4 ++-- lib/CharmBoard/{ => Model}/Schema/Source/Subforums.pm | 4 ++-- lib/CharmBoard/{ => Model}/Schema/Source/Threads.pm | 6 +++--- lib/CharmBoard/{ => Model}/Schema/Source/Users.pm | 2 +- 15 files changed, 28 insertions(+), 28 deletions(-) rename lib/CharmBoard/{ => Model}/Crypt/Password.pm (87%) rename lib/CharmBoard/{ => Model}/Crypt/Seasoning.pm (92%) rename lib/CharmBoard/{ => Model}/Schema.pm (86%) rename lib/CharmBoard/{ => Model}/Schema/Set/Categories.pm (80%) rename lib/CharmBoard/{ => Model}/Schema/Set/Subforums.pm (91%) rename lib/CharmBoard/{ => Model}/Schema/Set/Threads.pm (89%) rename lib/CharmBoard/{ => Model}/Schema/Source/Categories.pm (90%) rename lib/CharmBoard/{ => Model}/Schema/Source/Posts.pm (81%) rename lib/CharmBoard/{ => Model}/Schema/Source/Session.pm (86%) rename lib/CharmBoard/{ => Model}/Schema/Source/Subforums.pm (87%) rename lib/CharmBoard/{ => Model}/Schema/Source/Threads.pm (82%) rename lib/CharmBoard/{ => Model}/Schema/Source/Users.pm (94%) diff --git a/lib/CharmBoard.pm b/lib/CharmBoard.pm index 7ec7ede..b24c6e3 100644 --- a/lib/CharmBoard.pm +++ b/lib/CharmBoard.pm @@ -6,7 +6,7 @@ use warnings; use experimental qw(try smartmatch); use Mojo::Base 'Mojolicious', -signatures; -use CharmBoard::Schema; +use CharmBoard::Model::Schema; # this method will run once at server start sub startup { @@ -53,7 +53,7 @@ sub startup { Valid options: 'sqlite', 'mariadb'" } - our $schema = CharmBoard::Schema->connect( + our $schema = CharmBoard::Model::Schema->connect( $_dsn, $config->{database}->{user}, $config->{database}->{pass}, diff --git a/lib/CharmBoard/Controller/Login.pm b/lib/CharmBoard/Controller/Login.pm index 2765840..1d9a978 100644 --- a/lib/CharmBoard/Controller/Login.pm +++ b/lib/CharmBoard/Controller/Login.pm @@ -6,8 +6,8 @@ use warnings; use experimental qw(try smartmatch); use Mojo::Base 'Mojolicious::Controller', -signatures; -use CharmBoard::Crypt::Password; -use CharmBoard::Crypt::Seasoning; +use CharmBoard::Model::Crypt::Password; +use CharmBoard::Model::Crypt::Seasoning; sub login { my $self = shift; diff --git a/lib/CharmBoard/Controller/Register.pm b/lib/CharmBoard/Controller/Register.pm index 138cb5a..5b9e86c 100644 --- a/lib/CharmBoard/Controller/Register.pm +++ b/lib/CharmBoard/Controller/Register.pm @@ -6,7 +6,7 @@ use warnings; use experimental qw(try smartmatch); use Mojo::Base 'Mojolicious::Controller', -signatures; -use CharmBoard::Crypt::Password; +use CharmBoard::Model::Crypt::Password; # initial registration page sub register { diff --git a/lib/CharmBoard/Crypt/Password.pm b/lib/CharmBoard/Model/Crypt/Password.pm similarity index 87% rename from lib/CharmBoard/Crypt/Password.pm rename to lib/CharmBoard/Model/Crypt/Password.pm index b620a9c..810f5ae 100644 --- a/lib/CharmBoard/Crypt/Password.pm +++ b/lib/CharmBoard/Model/Crypt/Password.pm @@ -1,4 +1,4 @@ -package CharmBoard::Crypt::Password; +package CharmBoard::Model::Crypt::Password; use utf8; use strict; @@ -6,7 +6,7 @@ use warnings; use experimental qw(try smartmatch); use Authen::Passphrase::Argon2; -use CharmBoard::Crypt::Seasoning; +use CharmBoard::Model::Crypt::Seasoning; use Exporter qw(import); our @EXPORT = qw(passgen passchk); @@ -42,16 +42,16 @@ sub passchk { __END__ =pod =head1 NAME -CharmBoard::Crypt::Password - password processing module +CharmBoard::Model::Crypt::Password - password processing module =head1 SYNOPSIS =begin perl -use CharmBoard::Crypt::Password; +use CharmBoard::Model::Crypt::Password; ($salt, $hash) = passgen($plaintextPassword); $passwordVerification = passchk($salt, $hash, $plaintextPassword) =end perl =head1 DESCRIPTION -CharmBoard::Crypt::Password processes passwords, either processing +CharmBoard::Model::Crypt::Password processes passwords, either processing new passwords for database storage, or checking passwords entered when logging in to make sure they're correct. diff --git a/lib/CharmBoard/Crypt/Seasoning.pm b/lib/CharmBoard/Model/Crypt/Seasoning.pm similarity index 92% rename from lib/CharmBoard/Crypt/Seasoning.pm rename to lib/CharmBoard/Model/Crypt/Seasoning.pm index 58fecc3..3da074f 100644 --- a/lib/CharmBoard/Crypt/Seasoning.pm +++ b/lib/CharmBoard/Model/Crypt/Seasoning.pm @@ -1,4 +1,4 @@ -package CharmBoard::Crypt::Seasoning; +package CharmBoard::Model::Crypt::Seasoning; use utf8; use strict; diff --git a/lib/CharmBoard/Schema.pm b/lib/CharmBoard/Model/Schema.pm similarity index 86% rename from lib/CharmBoard/Schema.pm rename to lib/CharmBoard/Model/Schema.pm index 6714855..97c6542 100644 --- a/lib/CharmBoard/Schema.pm +++ b/lib/CharmBoard/Model/Schema.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema; +package CharmBoard::Model::Schema; use utf8; use strict; diff --git a/lib/CharmBoard/Schema/Set/Categories.pm b/lib/CharmBoard/Model/Schema/Set/Categories.pm similarity index 80% rename from lib/CharmBoard/Schema/Set/Categories.pm rename to lib/CharmBoard/Model/Schema/Set/Categories.pm index 4841283..bdaac40 100644 --- a/lib/CharmBoard/Schema/Set/Categories.pm +++ b/lib/CharmBoard/Model/Schema/Set/Categories.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Set::Categories; +package CharmBoard::Model::Schema::Set::Categories; use utf8; use strict; @@ -28,7 +28,7 @@ sub title_from_id { __END__ =pod =head1 NAME -CharmBoard::Schema::Set::Categories - DBIC ResultSet for the +CharmBoard::Model::Schema::Set::Categories - DBIC ResultSet for the categories table =head1 SYNOPSIS diff --git a/lib/CharmBoard/Schema/Set/Subforums.pm b/lib/CharmBoard/Model/Schema/Set/Subforums.pm similarity index 91% rename from lib/CharmBoard/Schema/Set/Subforums.pm rename to lib/CharmBoard/Model/Schema/Set/Subforums.pm index a12e3d0..d6daa77 100644 --- a/lib/CharmBoard/Schema/Set/Subforums.pm +++ b/lib/CharmBoard/Model/Schema/Set/Subforums.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Set::Subforums; +package CharmBoard::Model::Schema::Set::Subforums; use utf8; use strict; diff --git a/lib/CharmBoard/Schema/Set/Threads.pm b/lib/CharmBoard/Model/Schema/Set/Threads.pm similarity index 89% rename from lib/CharmBoard/Schema/Set/Threads.pm rename to lib/CharmBoard/Model/Schema/Set/Threads.pm index 7ff32d0..82cf26b 100644 --- a/lib/CharmBoard/Schema/Set/Threads.pm +++ b/lib/CharmBoard/Model/Schema/Set/Threads.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Set::Threads; +package CharmBoard::Model::Schema::Set::Threads; use utf8; use strict; diff --git a/lib/CharmBoard/Schema/Source/Categories.pm b/lib/CharmBoard/Model/Schema/Source/Categories.pm similarity index 90% rename from lib/CharmBoard/Schema/Source/Categories.pm rename to lib/CharmBoard/Model/Schema/Source/Categories.pm index f2c0a1d..6caef19 100644 --- a/lib/CharmBoard/Schema/Source/Categories.pm +++ b/lib/CharmBoard/Model/Schema/Source/Categories.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Source::Categories; +package CharmBoard::Model::Schema::Source::Categories; use utf8; use strict; diff --git a/lib/CharmBoard/Schema/Source/Posts.pm b/lib/CharmBoard/Model/Schema/Source/Posts.pm similarity index 81% rename from lib/CharmBoard/Schema/Source/Posts.pm rename to lib/CharmBoard/Model/Schema/Source/Posts.pm index 3c06fdc..acb96a4 100644 --- a/lib/CharmBoard/Schema/Source/Posts.pm +++ b/lib/CharmBoard/Model/Schema/Source/Posts.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Source::Posts; +package CharmBoard::Model::Schema::Source::Posts; use utf8; use strict; @@ -33,11 +33,11 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('post_id'); __PACKAGE__->belongs_to( - user_id => 'CharmBoard::Schema::Source::Users', + user_id => 'CharmBoard::Model::Schema::Source::Users', 'user_id' ); __PACKAGE__->belongs_to( - thread_id => 'CharmBoard::Schema::Source::Threads', + thread_id => 'CharmBoard::Model::Schema::Source::Threads', 'thread_id' ); diff --git a/lib/CharmBoard/Schema/Source/Session.pm b/lib/CharmBoard/Model/Schema/Source/Session.pm similarity index 86% rename from lib/CharmBoard/Schema/Source/Session.pm rename to lib/CharmBoard/Model/Schema/Source/Session.pm index d6d7eae..b19412f 100644 --- a/lib/CharmBoard/Schema/Source/Session.pm +++ b/lib/CharmBoard/Model/Schema/Source/Session.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Source::Session; +package CharmBoard::Model::Schema::Source::Session; use utf8; use strict; @@ -34,7 +34,7 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('session_key'); __PACKAGE__->belongs_to( - user_id => 'CharmBoard::Schema::Source::Users', + user_id => 'CharmBoard::Model::Schema::Source::Users', 'user_id' ); diff --git a/lib/CharmBoard/Schema/Source/Subforums.pm b/lib/CharmBoard/Model/Schema/Source/Subforums.pm similarity index 87% rename from lib/CharmBoard/Schema/Source/Subforums.pm rename to lib/CharmBoard/Model/Schema/Source/Subforums.pm index a62c3ba..f2fd87a 100644 --- a/lib/CharmBoard/Schema/Source/Subforums.pm +++ b/lib/CharmBoard/Model/Schema/Source/Subforums.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Source::Subforums; +package CharmBoard::Model::Schema::Source::Subforums; use utf8; use strict; @@ -37,7 +37,7 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('subf_id'); __PACKAGE__->belongs_to( - subf_cat => 'CharmBoard::Schema::Source::Categories', + subf_cat => 'CharmBoard::Model::Schema::Source::Categories', { 'foreign.cat_id' => 'self.subf_cat' } ); diff --git a/lib/CharmBoard/Schema/Source/Threads.pm b/lib/CharmBoard/Model/Schema/Source/Threads.pm similarity index 82% rename from lib/CharmBoard/Schema/Source/Threads.pm rename to lib/CharmBoard/Model/Schema/Source/Threads.pm index e94e2fc..ee429f6 100644 --- a/lib/CharmBoard/Schema/Source/Threads.pm +++ b/lib/CharmBoard/Model/Schema/Source/Threads.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Source::Threads; +package CharmBoard::Model::Schema::Source::Threads; use utf8; use strict; @@ -33,11 +33,11 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key('thread_id'); __PACKAGE__->belongs_to( - thread_subf => 'CharmBoard::Schema::Source::Subforums', + thread_subf => 'CharmBoard::Model::Schema::Source::Subforums', { 'foreign.subf_id' => 'self.thread_subf' } ); __PACKAGE__->belongs_to( - thread_op => 'CharmBoard::Schema::Source::Posts', + thread_op => 'CharmBoard::Model::Schema::Source::Posts', { 'foreign.post_id' => 'self.thread_op' } ); diff --git a/lib/CharmBoard/Schema/Source/Users.pm b/lib/CharmBoard/Model/Schema/Source/Users.pm similarity index 94% rename from lib/CharmBoard/Schema/Source/Users.pm rename to lib/CharmBoard/Model/Schema/Source/Users.pm index c24a862..8198d76 100644 --- a/lib/CharmBoard/Schema/Source/Users.pm +++ b/lib/CharmBoard/Model/Schema/Source/Users.pm @@ -1,4 +1,4 @@ -package CharmBoard::Schema::Source::Users; +package CharmBoard::Model::Schema::Source::Users; use utf8; use strict;