add site_local_files feature for easy lib/template override
This commit is contained in:
@@ -3,9 +3,16 @@ package App::Netdisco::Configuration;
|
||||
use App::Netdisco::Environment;
|
||||
use Dancer ':script';
|
||||
|
||||
use Path::Class 'dir';
|
||||
|
||||
BEGIN {
|
||||
if (setting('include_paths') and ref [] eq ref setting('include_paths')) {
|
||||
# stuff useful locations into @INC
|
||||
unshift @INC, @{ (setting('include_paths') || []) };
|
||||
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
|
||||
|
||||
@@ -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<views>" subdirectory
|
||||
created.
|
||||
|
||||
=head3 C<site_local_files>
|
||||
|
||||
Value: Boolean. Default: false.
|
||||
|
||||
A shortcut for using C<include_paths> and C<template_paths>. 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</lib> and templates in C</share>
|
||||
within the C<nd-site-local> directory (you have to create this yourself).
|
||||
|
||||
Note that templates may need to have a further "C<views>" subdirectory
|
||||
created.
|
||||
|
||||
=head3 C<external_databases>
|
||||
|
||||
Value: List of Database Configuration Hashes. Default: None.
|
||||
|
||||
@@ -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')) {
|
||||
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} },
|
||||
$path;
|
||||
}
|
||||
@{setting('template_paths')};
|
||||
}
|
||||
|
||||
# load cookie key from database
|
||||
|
||||
@@ -13,6 +13,7 @@ log: 'warning'
|
||||
logger_format: '[%P] %U %L %m'
|
||||
include_paths: []
|
||||
template_paths: []
|
||||
site_local_files: false
|
||||
external_databases: []
|
||||
|
||||
# ------------
|
||||
|
||||
Reference in New Issue
Block a user