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;
}

View File

@@ -87,6 +87,7 @@ domain ${DOMAIN}
# multi language support
admin_pot_dir ${BASE_DIR}/agenda/planung/pot/
email info@${DOMAIN}
theme default
</locations>
<permissions>

View File

@@ -3,7 +3,6 @@
Access-Control-Allow-Origin: *
<!DOCTYPE html>
<TMPL_IF extern_access><TMPL_INCLUDE ../index.html>gesucht und gefunden...<TMPL_ELSE>
<html>
<body>
<TMPL_IF no_result>
@@ -90,5 +89,3 @@ Access-Control-Allow-Origin: *
</TMPL_LOOP>
</body>
</html>
</TMPL_IF>

View File

@@ -3,7 +3,6 @@
Access-Control-Allow-Origin: *
<!DOCTYPE html>
<TMPL_IF extern_access><TMPL_INCLUDE ../index.html>gesucht und gefunden...<TMPL_ELSE>
<html>
<body>
<TMPL_IF no_result>
@@ -77,7 +76,6 @@ Access-Control-Allow-Origin: *
<TMPL_UNLESS __last__><hr /></TMPL_UNLESS>
</TMPL_IF>
</TMPL_LOOP>
</TMPL_IF>
<!--end of content -->