Skip to content

Commit

Permalink
Merge pull request #7251 from ehuelsmann/cleanup/centralize-dep-injec…
Browse files Browse the repository at this point in the history
…ted-paths

SQL directory centralization and more UI refs
  • Loading branch information
ehuelsmann committed Mar 3, 2023
2 parents 9ec6896 + bb6b0ba commit dca06fd
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 12 deletions.
17 changes: 13 additions & 4 deletions bin/ledgersmb-server.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ db:
$class: LedgerSMB::Database::Factory
connect_data:
sslmode: prefer
source_dir:
$ref: paths/sql
default_locale:
$class: LedgerSMB::LanguageResolver
directory:
Expand Down Expand Up @@ -198,7 +200,13 @@ paths:
$class: Beam::Wire
config:
locale: ./locale/po/
sql: ./sql/
templates: ./templates/
UI: ./UI/
UI_cache: lsmb_templates/
workflows:
- workflows/
- custom_workflows/
printers:
$class: LedgerSMB::Printers
printers: {}
Expand Down Expand Up @@ -259,13 +267,14 @@ ui:
$class: LedgerSMB::Template::UI
$method: new_UI
$lifecycle: eager
cache: lsmb_templates/
root: ./UI/
cache:
$ref: paths/UI_cache
root:
$ref: paths/UI
workflows:
$class: LedgerSMB::Workflow::Loader
$lifecycle: eager
$method: load
directories:
- workflows/
- custom_workflows/
- $ref: paths/workflows
lifecycle: eager
4 changes: 3 additions & 1 deletion doc/conf/ledgersmb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ db:
$class: LedgerSMB::Database::Factory
connect_data:
sslmode: prefer
source_dir:
$ref: paths/sql

default_locale:
$class: LedgerSMB::LanguageResolver
Expand Down Expand Up @@ -75,14 +77,14 @@ paths:
$class: Beam::Wire
config:
locale: ./locale/po/
sql: ./sql/
templates: ./templates/
UI: ./UI/
UI_cache: lsmb_templates/
workflows:
- ./workflows/
- ./custom_workflows/


printers:
$class: LedgerSMB::Printers
printers:
Expand Down
15 changes: 14 additions & 1 deletion lib/LedgerSMB/Database/Factory.pm
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ have been loaded. When none is provided, the default ('public') is assumed.

has schema => (is => 'ro', default => 'public');

=head2 source_dir
Indicates the path to the directory which holds the 'Pg-database.sql' file
and the associated changes, charts and gifi files.
The default value is relative to the current directory, which is assumed
to be the root of the LedgerSMB source tree.
=cut

has source_dir => (is => 'ro', default => './sql');

=head1 METHODS
=head2 instance( user => $username, password => $password, %overriden_connect_data )
Expand All @@ -84,7 +96,8 @@ sub instance {
$self->connect_data->%*,
%args
},
schema => $self->schema );
schema => $self->schema,
source_dir => $self->source_dir);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/LedgerSMB/PSGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ sub setup_url_space {
}
};

mount '/' => Plack::App::File->new( root => 'UI' )->to_app;
mount '/' => Plack::App::File->new( root => $wire->get('paths/UI') )->to_app;
};

}
Expand Down
7 changes: 5 additions & 2 deletions old/lib/LedgerSMB/Sysconfig.pm
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ sub ini2wire {
'$class' => 'Beam::Wire',
config => {
locale => scalar $cfg->val( 'paths', 'localepath', './locale/po/' ),
sql => scalar $cfg->val( 'paths', 'sql', './sql/'),
templates => scalar $cfg->val( 'paths', 'templates', './templates/' ),
UI => scalar $cfg->val( 'paths', 'UI', './UI/' ),
UI_cache => scalar $cfg->val( 'paths', 'UI_cache', 'lsmb_templates/' ),
}
};

Expand All @@ -196,8 +199,8 @@ sub ini2wire {
lifecycle => 'eager',
method => 'new_UI',
args => {
cache => scalar $cfg->val(
'paths', 'templates_cache', 'lsmb_templates/' ),
cache => { '$ref' => 'paths/UI_cache' },
root => { '$ref' => 'paths/UI' },
}
};

Expand Down
10 changes: 9 additions & 1 deletion t/16-schema-upgrade-html.t
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,19 @@ sub test_request {
directory => './locale/po/',
}
},
paths => {
class => 'Beam::Wire',
args => {
config => {
UI => './UI/'
}
}
},
ui => {
class => 'LedgerSMB::Template::UI',
method => 'new_UI',
args => {
root => './UI/',
root => { '$ref' => 'paths/UI' }
}
}
});
Expand Down
8 changes: 6 additions & 2 deletions t/ledgersmb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ paths:
$class: Beam::Wire
config:
locale: ./locale/po/
UI: ./UI/
UI_cache: lsmb_templates/

ui:
class: LedgerSMB::Template::UI
method: new_UI
lifecycle: eager
args:
cache: lsmb_templates/
root: ./UI/
cache:
$ref: paths/UI_cache
root:
$ref: paths/UI

0 comments on commit dca06fd

Please sign in to comment.