|
|
@@ -6,6 +6,8 @@ use warnings;
|
|
|
no warnings 'experimental';
|
|
|
use feature qw{signatures state};
|
|
|
|
|
|
+use FindBin::libs;
|
|
|
+
|
|
|
use Trog::Vars;
|
|
|
use Trog::Config;
|
|
|
|
|
|
@@ -15,15 +17,18 @@ Utility functions for getting themed paths.
|
|
|
|
|
|
=cut
|
|
|
|
|
|
-my $conf = Trog::Config::get();
|
|
|
our $template_dir = 'www/templates';
|
|
|
-our $theme_dir = '';
|
|
|
-$theme_dir = "www/themes/" . $conf->param('general.theme') if $conf->param('general.theme') && -d "www/themes/" . $conf->param('general.theme');
|
|
|
-our $td = $theme_dir ? "/$theme_dir" : '';
|
|
|
+
|
|
|
+my $get_theme_dir = sub {
|
|
|
+ my $conf = Trog::Config::get();
|
|
|
+ state $tdir;
|
|
|
+ $tdir = "www/themes/" . $conf->param('general.theme') if $conf->param('general.theme') && -d "www/themes/" . $conf->param('general.theme');
|
|
|
+ return $tdir;
|
|
|
+};
|
|
|
|
|
|
sub template_dir ( $template, $content_type, $is_component = 0, $is_dir = 0 ) {
|
|
|
my $ct = $Trog::Vars::byct{$content_type};
|
|
|
- my ( $mtd, $mtemp ) = ( "$theme_dir/templates/$ct", "$template_dir/$ct" );
|
|
|
+ my ( $mtd, $mtemp ) = ( $get_theme_dir->() . "/templates/$ct", "$template_dir/$ct" );
|
|
|
if ($is_component) {
|
|
|
$mtd .= "/components";
|
|
|
$mtemp .= "/components";
|
|
|
@@ -36,6 +41,7 @@ sub template_dir ( $template, $content_type, $is_component = 0, $is_dir = 0 ) {
|
|
|
|
|
|
# Pick appropriate dir based on whether theme override exists
|
|
|
sub _dir_for_resource ($resource) {
|
|
|
+ my $theme_dir = $get_theme_dir->();
|
|
|
return $theme_dir && -f "$theme_dir/$resource" ? $theme_dir : '';
|
|
|
}
|
|
|
|