diff --git a/lib/calcms/template.pm b/lib/calcms/template.pm index af3a68b..6e9cd5e 100644 --- a/lib/calcms/template.pm +++ b/lib/calcms/template.pm @@ -6,6 +6,7 @@ use strict; use Data::Dumper; use HTML::Template::Compiled(); use HTML::Template::Compiled::Plugin::XMLEscape(); +#use HTML::Template::JIT(); use JSON(); use Cwd(); @@ -64,47 +65,14 @@ sub process { return; } - #print STDERR $filename."\n"; - log::error( $config, "cannot find template $filename " ) unless -e $filename; - log::error( $config, "cannot read template $filename " ) unless -r $filename; - - my $default_escape = '0'; - $default_escape = 'JS' if ( $filename =~ /\.js$/ ); - $default_escape = 'JS' if ( $filename =~ /\.json$/ ); - $default_escape = 'HTML_ALL' if ( $filename =~ /\.html$/ ); - - my $html_template = undef; - - unless ( $filename =~ /\.xml$/ ) { - $html_template = HTML::Template::Compiled->new( - filename => $filename, - die_on_bad_params => 0, - case_sensitive => 0, - loop_context_vars => 0, - global_vars => 0, - tagstyle => '-asp -comment', - default_escape => $default_escape, - cache => 0, - utf8 => 1, - ); - } else { - $html_template = HTML::Template::Compiled->new( - filename => $filename, - die_on_bad_params => 0, - case_sensitive => 1, - loop_context_vars => 0, - global_vars => 0, - tagstyle => '-asp -comment', - default_escape => 'XML', - plugin => [qw(HTML::Template::Compiled::Plugin::XMLEscape)], - utf8 => 1 - ); + unless (-r $filename){ + log::error($config, qq{template "$filename" does not exist}) unless -e $filename; + log::error($config, qq{missing permissions to read "$filename"}); } + my $html_template = initTemplate($filename); - #$params= setRelativeUrls( $params, 0 ) unless ( defined $params->{extern} ) && ( $params->{extern} eq '1' ); - # HTML::Template::Compiled->preload($cache_dir); $html_template->param($params); if ( ( defined $_[1] ) && ( $_[1] eq 'print' ) ) { print $html_template->output; @@ -113,6 +81,42 @@ sub process { } } +sub initTemplate{ + my $filename=shift; + + my $default_escape = 'none'; + $default_escape = 'js' if ( $filename =~ /\.js$/ ); + $default_escape = 'js' if ( $filename =~ /\.json$/ ); + $default_escape = 'html_all' if ( $filename =~ /\.html$/ ); + + if ( $filename =~ /\.xml$/ ) { + return HTML::Template::Compiled->new( + filename => $filename, + die_on_bad_params => 1, + case_sensitive => 1, + loop_context_vars => 0, + global_vars => 0, + tagstyle => '-asp -comment --comment --tt', + default_escape => 'XML', + cache => 1, + utf8 => 1, + plugin => [qw(HTML::Template::Compiled::Plugin::XMLEscape)], + ); + } + + return HTML::Template::Compiled->new( + filename => $filename, + die_on_bad_params => 1, + case_sensitive => 1, + loop_context_vars => 0, + global_vars => 0, + tagstyle => '-asp -comment --comment --tt', + default_escape => $default_escape, + cache => 1, + utf8 => 1, + ); +} + # set relative urls in nested params structure sub setRelativeUrls { my $params = shift; diff --git a/website/agenda/planung/templates/edit_comment.html b/website/agenda/planung/templates/edit_comment.html index f55ee52..5e567ad 100644 --- a/website/agenda/planung/templates/edit_comment.html +++ b/website/agenda/planung/templates/edit_comment.html @@ -19,8 +19,8 @@ - - + + diff --git a/website/agenda/planung/templates/edit_event.html b/website/agenda/planung/templates/edit_event.html index b060456..03f58b9 100644 --- a/website/agenda/planung/templates/edit_event.html +++ b/website/agenda/planung/templates/edit_event.html @@ -157,7 +157,7 @@ + + - + @@ -191,14 +191,14 @@ @@ -393,7 +393,7 @@
-
+
@@ -433,7 +433,7 @@ - + @@ -444,7 +444,7 @@ - + @@ -499,34 +499,34 @@ -
- - - - - - - - - - - - - - - - - - -
+
+ + + + + + + + + + + + + + + + + + +
diff --git a/website/agenda/planung/templates/edit_image.html b/website/agenda/planung/templates/edit_image.html index 38f42ac..aeb8591 100644 --- a/website/agenda/planung/templates/edit_image.html +++ b/website/agenda/planung/templates/edit_image.html @@ -9,7 +9,7 @@ found no image
- +
@@ -23,10 +23,10 @@ found no image
-
+

-
+


@@ -35,18 +35,18 @@ found no image checked="checked" value="1"value="0" />
- + - +


- : {{|}}
+ : {{|}}
diff --git a/website/agenda/planung/templates/image.html b/website/agenda/planung/templates/image.html index 070af86..3cde819 100644 --- a/website/agenda/planung/templates/image.html +++ b/website/agenda/planung/templates/image.html @@ -78,8 +78,8 @@
- - + +

diff --git a/website/agenda/planung/templates/imageUpload.html b/website/agenda/planung/templates/imageUpload.html index 79d6c9b..9a2ecbf 100644 --- a/website/agenda/planung/templates/imageUpload.html +++ b/website/agenda/planung/templates/imageUpload.html @@ -31,18 +31,18 @@ - + Name: - + Beschreibung: - + diff --git a/website/agenda/planung/templates/upload_audio_recordings.html b/website/agenda/planung/templates/upload_audio_recordings.html index 8c285fb..e290e2c 100644 --- a/website/agenda/planung/templates/upload_audio_recordings.html +++ b/website/agenda/planung/templates/upload_audio_recordings.html @@ -44,7 +44,7 @@ - " + " diff --git a/website/agenda/templates/categories.html b/website/agenda/templates/categories.html index 6f002dc..a4fa4c9 100644 --- a/website/agenda/templates/categories.html +++ b/website/agenda/templates/categories.html @@ -8,7 +8,7 @@ @@ -17,13 +17,13 @@
- diff --git a/website/agenda/templates/comments.html b/website/agenda/templates/comments.html index 7c8996c..01acd5c 100644 --- a/website/agenda/templates/comments.html +++ b/website/agenda/templates/comments.html @@ -34,9 +34,9 @@
- , + , - -
+
diff --git a/website/agenda/templates/event_details.html b/website/agenda/templates/event_details.html index df493ad..16f8564 100644 --- a/website/agenda/templates/event_details.html +++ b/website/agenda/templates/event_details.html @@ -59,7 +59,7 @@ - + Wiederholung vom
diff --git a/website/agenda/templates/series_names.html b/website/agenda/templates/series_names.html index 8d6dc46..b8cf198 100644 --- a/website/agenda/templates/series_names.html +++ b/website/agenda/templates/series_names.html @@ -11,15 +11,15 @@