compress html output

This commit is contained in:
Milan
2019-03-18 15:20:44 +01:00
parent 95ff06592d
commit cb2e1bc30d
6 changed files with 30 additions and 13 deletions

View File

@@ -74,10 +74,21 @@ sub process {
setRelativeUrls( $params, 0 ) unless ( defined $params->{extern} ) && ( $params->{extern} eq '1' ); setRelativeUrls( $params, 0 ) unless ( defined $params->{extern} ) && ( $params->{extern} eq '1' );
$html_template->param($params); $html_template->param($params);
my $output = $html_template->output();
if ($filename=~/html/){
my ($header, $content) = split(/\n\n/, $output, 2);
if ($content){
#$content =~s/\s+/ /g;
$output = $header."\n\n".$content;
}else{
#$output =~s/[ \t]+/ /g;
}
}
if ( ( defined $_[1] ) && ( $_[1] eq 'print' ) ) { if ( ( defined $_[1] ) && ( $_[1] eq 'print' ) ) {
print $html_template->output; print $output;
} else { } else {
$_[1] = $html_template->output; $_[1] = $output;
} }
} }
@@ -105,16 +116,18 @@ sub initTemplate{
} }
return HTML::Template::Compiled->new( return HTML::Template::Compiled->new(
filename => $filename, filename => $filename,
die_on_bad_params => 1, die_on_bad_params => 1,
case_sensitive => 1, case_sensitive => 1,
loop_context_vars => 0, loop_context_vars => 0,
global_vars => 0, global_vars => 0,
tagstyle => '-asp -comment --comment --tt', tagstyle => '-asp -comment --comment --tt',
default_escape => $default_escape, default_escape => $default_escape,
cache => 1, cache => 1,
utf8 => 1, utf8 => 1,
); #pre_chomp => 1,
#post_chomp => 1,
);
} }
# set relative urls in nested params structure # set relative urls in nested params structure

View File

@@ -34,8 +34,8 @@
</tr> </tr>
<tr> <tr>
<!--<th>Wo</th> <TMPL_COMMENT><th>Wo</th>
--> </TMPL_COMMENT>
<TMPL_LOOP weekdays><th><a href="<TMPL_VAR .local_base_url>/<TMPL_VAR .controllers.events>/<TMPL_VAR start_date>/<TMPL_VAR end_date>/<TMPL_VAR weekday>/" onclick="calcms.selectWeekdayEventListener('<TMPL_VAR start_date>','<TMPL_VAR end_date>','<TMPL_VAR weekday>');return false;"><TMPL_VAR "weekday_short_name"></a></th></TMPL_LOOP> <TMPL_LOOP weekdays><th><a href="<TMPL_VAR .local_base_url>/<TMPL_VAR .controllers.events>/<TMPL_VAR start_date>/<TMPL_VAR end_date>/<TMPL_VAR weekday>/" onclick="calcms.selectWeekdayEventListener('<TMPL_VAR start_date>','<TMPL_VAR end_date>','<TMPL_VAR weekday>');return false;"><TMPL_VAR "weekday_short_name"></a></th></TMPL_LOOP>
</tr> </tr>
@@ -44,9 +44,9 @@
<TMPL_LOOP week_and_days> <TMPL_LOOP week_and_days>
<tr> <tr>
<!-- <TMPL_COMMENT>
<TMPL_LOOP week><th class="<TMPL_VAR class>"><a href="<TMPL_VAR .local_base_url>/<TMPL_VAR .controllers.events>/<TMPL_VAR from_date>/<TMPL_VAR till_date>/" title="Woche anzeigen" onclick="calcms.selectDateRangeEventListener('<TMPL_VAR from_date>','<TMPL_VAR till_date>');return false;" ><TMPL_VAR week_of_year></a></th></TMPL_LOOP> <TMPL_LOOP week><th class="<TMPL_VAR class>"><a href="<TMPL_VAR .local_base_url>/<TMPL_VAR .controllers.events>/<TMPL_VAR from_date>/<TMPL_VAR till_date>/" title="Woche anzeigen" onclick="calcms.selectDateRangeEventListener('<TMPL_VAR from_date>','<TMPL_VAR till_date>');return false;" ><TMPL_VAR week_of_year></a></th></TMPL_LOOP>
--> </TMPL_COMMENT>
<TMPL_LOOP days><td class="<TMPL_VAR class>"><a href="<TMPL_VAR .cache_base_url>/<TMPL_VAR .controllers.events>/<TMPL_VAR date>.html" title="<TMPL_VAR day>.<TMPL_VAR month>. zeigen"><TMPL_VAR day></a></td> <TMPL_LOOP days><td class="<TMPL_VAR class>"><a href="<TMPL_VAR .cache_base_url>/<TMPL_VAR .controllers.events>/<TMPL_VAR date>.html" title="<TMPL_VAR day>.<TMPL_VAR month>. zeigen"><TMPL_VAR day></a></td>
</TMPL_LOOP></tr></TMPL_LOOP> </TMPL_LOOP></tr></TMPL_LOOP>
</tbody> </tbody>

View File

@@ -71,7 +71,6 @@
> >
<TMPL_VAR day> <TMPL_VAR day>
</a> </a>
<!--onclick="calcms.selectDateEventListener('<TMPL_VAR date>');return false;"-->
</TMPL_IF> </TMPL_IF>
</td> </td>
</TMPL_LOOP> </TMPL_LOOP>

View File

@@ -31,12 +31,13 @@
<div id="event_menu_<TMPL_VAR event_id>" class="vevent event<TMPL_IF is_running> running</TMPL_IF>" <div id="event_menu_<TMPL_VAR event_id>" class="vevent event<TMPL_IF is_running> running</TMPL_IF>"
title="<TMPL_IF program><TMPL_VAR program> - </TMPL_IF><TMPL_IF series_name><TMPL_VAR series_name> - </TMPL_IF><TMPL_VAR title>" title="<TMPL_IF program><TMPL_VAR program> - </TMPL_IF><TMPL_IF series_name><TMPL_VAR series_name> - </TMPL_IF><TMPL_VAR title>"
> >
<TMPL_COMMENT>
<div class="icon"> <div class="icon">
<TMPL_IF icon><img src="<TMPL_VAR icon>" alt="<TMPL_VAR series_name>" /> <TMPL_IF icon><img src="<TMPL_VAR icon>" alt="<TMPL_VAR series_name>" />
<TMPL_ELSE><img src="<TMPL_VAR static_files_url>image/event.icon.png" /> <TMPL_ELSE><img src="<TMPL_VAR static_files_url>image/event.icon.png" />
</TMPL_IF> </TMPL_IF>
</div> </div>
</TMPL_COMMENT>
<div class="title"> <div class="title">
<TMPL_VAR start_time_name><br /> <TMPL_VAR start_time_name><br />
<TMPL_VAR series_name><TMPL_UNLESS series_name>!<TMPL_VAR title></TMPL_UNLESS>&nbsp; <TMPL_VAR series_name><TMPL_UNLESS series_name>!<TMPL_VAR title></TMPL_UNLESS>&nbsp;

View File

@@ -13,9 +13,11 @@
<a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url>" <a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url>"
> >
<div id="event_playlist_<TMPL_VAR event_id>" class="event" title="<TMPL_VAR full_title><TMPL_IF excerpt>. <TMPL_VAR excerpt></TMPL_IF>"> <div id="event_playlist_<TMPL_VAR event_id>" class="event" title="<TMPL_VAR full_title><TMPL_IF excerpt>. <TMPL_VAR excerpt></TMPL_IF>">
<TMPL_COMMENT>
<div class="icon"> <div class="icon">
<img src="<TMPL_VAR icon>"></img> <img src="<TMPL_VAR icon>"></img>
</div> </div>
</TMPL_COMMENT>
<div class="title"> <div class="title">
<TMPL_VAR weekday_short_name> <TMPL_VAR start_time_name><br /> <TMPL_VAR weekday_short_name> <TMPL_VAR start_time_name><br />
<TMPL_IF series_name><TMPL_VAR series_name><TMPL_ELSE><TMPL_VAR title></TMPL_IF> <TMPL_IF series_name><TMPL_VAR series_name><TMPL_ELSE><TMPL_VAR title></TMPL_IF>

View File

@@ -54,11 +54,13 @@
<TMPL_VAR start_time_name> bis <TMPL_VAR end_time_name> Uhr <TMPL_IF program>(<TMPL_VAR program>)</TMPL_IF></span><br /> <TMPL_VAR start_time_name> bis <TMPL_VAR end_time_name> Uhr <TMPL_IF program>(<TMPL_VAR program>)</TMPL_IF></span><br />
</div> </div>
<div class="content" > <div class="content" >
<TMPL_COMMENT>
<div class="image-attach-teaser" style="width: 150px;"> <div class="image-attach-teaser" style="width: 150px;">
<a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url>"> <a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#<TMPL_VAR event_uri escape=url>">
<img class="image image-thumbnail" src="<TMPL_VAR image>" width="150" height="150" /> <img class="image image-thumbnail" src="<TMPL_VAR image>" width="150" height="150" />
</a> </a>
</div> </div>
</TMPL_COMMENT>
<TMPL_VAR excerpt > <TMPL_VAR excerpt >
</div> </div>
<a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#comments"> <a href="<TMPL_VAR cache_base_url>/<TMPL_VAR .controllers.event>/<TMPL_VAR event_id>.html#comments">