template: custom themes for agenda

For agenda a custom theme can be configured in locations/theme.
Templates are read from the subdirectory "templates/<theme>/".  The
default theme is "default".  All Templates are moved to
templates/default.
This commit is contained in:
Milan
2023-02-25 11:06:52 +01:00
parent e067bc1448
commit ebd521452a
38 changed files with 8 additions and 12 deletions

View File

@@ -169,8 +169,6 @@ sub setRelativeUrls {
return $params;
}
#requires read config
#TODO:add config
sub check($;$$) {
my $config = shift;
my $template = shift || '';
@@ -195,12 +193,14 @@ sub check($;$$) {
}
$template = ( split( /\//, $template ) )[-1];
my $cwd = Cwd::getcwd();
$template .= '.html' unless ( $template =~ /\./ );
log::error( $config, "template not found: '$cwd/$template'" )
unless -e $cwd . '/templates/' . $template;
$template = $cwd . '/templates/' . $template;
my $dir = "templates";
my $cwd = Cwd::getcwd();
my $theme = $config->{locations}->{theme} //= 'default';
$dir .= "/$theme" if $cwd =~ m{/agenda$} && $theme;
log::error( $config, "template not found: '$dir'" )
unless -e "$cwd/$dir/$template";
$template = "$cwd/$dir/$template";
return $template;
}