diff --git a/lib/App/Netdisco/Configuration.pm b/lib/App/Netdisco/Configuration.pm index 1a8f7739..1be83434 100644 --- a/lib/App/Netdisco/Configuration.pm +++ b/lib/App/Netdisco/Configuration.pm @@ -3,9 +3,16 @@ package App::Netdisco::Configuration; use App::Netdisco::Environment; use Dancer ':script'; +use Path::Class 'dir'; + BEGIN { - # stuff useful locations into @INC - unshift @INC, @{ (setting('include_paths') || []) }; + if (setting('include_paths') and ref [] eq ref setting('include_paths')) { + # stuff useful locations into @INC + push @{setting('include_paths')}, + dir(($ENV{NETDISCO_HOME} || $ENV{HOME}), 'nd-site-local', 'lib')->stringify + if (setting('site_local_files')); + unshift @INC, @{setting('include_paths')}; + } } # set up database schema config from simple config vars diff --git a/lib/App/Netdisco/Manual/Configuration.pod b/lib/App/Netdisco/Manual/Configuration.pod index ead64d46..e1e8ebe0 100644 --- a/lib/App/Netdisco/Manual/Configuration.pod +++ b/lib/App/Netdisco/Manual/Configuration.pod @@ -143,6 +143,21 @@ be loaded before (and hence override) any templates built in to Netdisco. If you do want to copy and override a built in web template, then create the directories necessary (such as "ajax" or "sidebar") in this path. +Note that templates may need to have a further "C" subdirectory +created. + +=head3 C + +Value: Boolean. Default: false. + +A shortcut for using C and C. Setting this to +true will push C<< $home/nd-site-local/{lib,share} >> into those settings, +respectively. You can then put Perl code in C and templates in C +within the C directory (you have to create this yourself). + +Note that templates may need to have a further "C" subdirectory +created. + =head3 C Value: List of Database Configuration Hashes. Default: None. diff --git a/lib/App/Netdisco/Web.pm b/lib/App/Netdisco/Web.pm index 82e55294..9d3b6203 100644 --- a/lib/App/Netdisco/Web.pm +++ b/lib/App/Netdisco/Web.pm @@ -58,10 +58,11 @@ push @{ config->{engines}->{netdisco_template_toolkit}->{INCLUDE_PATH} }, # any template paths in deployment.yml (should override plugins) if (setting('template_paths') and ref [] eq ref setting('template_paths')) { - foreach my $path (setting('template_paths')) { - unshift @{ config->{engines}->{netdisco_template_toolkit}->{INCLUDE_PATH} }, - $path; - } + push @{setting('template_paths')}, + dir(($ENV{NETDISCO_HOME} || $ENV{HOME}), 'nd-site-local', 'share')->stringify + if (setting('site_local_files')); + unshift @{ config->{engines}->{netdisco_template_toolkit}->{INCLUDE_PATH} }, + @{setting('template_paths')}; } # load cookie key from database diff --git a/share/config.yml b/share/config.yml index 5130aedd..017a02b6 100644 --- a/share/config.yml +++ b/share/config.yml @@ -13,6 +13,7 @@ log: 'warning' logger_format: '[%P] %U %L %m' include_paths: [] template_paths: [] +site_local_files: false external_databases: [] # ------------