3 use Module::Runtime qw(use_module);
7 with 'App::SCS::Role::WithConfig';
9 has plugins => (is => 'ro', default => sub { [] });
11 has root_dir => (is => 'lazy');
15 # Need to pass '.' rather than undef in the default case - otherwise
16 # IO::All 0.47+ resolves to / (previously undef or '' was '.')
17 io->dir(io->dir($self->config->{root_dir}||'.')->absolute);
20 has share_dir => (is => 'lazy');
22 sub _build_share_dir {
24 io->dir($self->config->{share_dir}||$self->root_dir->catdir('share'));
27 has page_plugin_config => (is => 'lazy');
29 sub _build_page_plugin_config {
34 my %map = map $_->page_plugins, reverse @{$self->plugins};
35 ref($_) or $_ = { class => $_, config => sub {} } for values %map;
40 map $_->default_page_plugins, @{$self->plugins}
45 has pages => (is => 'lazy');
49 return use_module('App::SCS::PageSet')->new(
50 base_dir => $self->share_dir->catdir('pages'),
51 plugin_config => $self->page_plugin_config,
55 has web => (is => 'lazy');
59 return use_module('App::SCS::Web')->new(
66 $self->load_plugin(Core => {});
67 my @plist = @{$self->config->{plugins}||[]};
68 while (my ($name, $conf) = splice @plist, 0, 2) {
69 $self->load_plugin($name, $conf);
74 my ($self, $name, $config) = @_;
75 my $class = ($name =~ s/^\+// ? $name : "App::SCS::Plugin::${name}");
78 use_module($class)->new(
91 $code ||= $self->web->to_psgi_app;
107 foreach my $p (@{$self->plugins}) {
108 return if $p->run_cli($env);