This all seems like a bad way to implement whatever bandwidth and client-side storage savings you will get from whitespace-stripping. Koha really shouldn't be in the business of trying to reinvent mod_deflate, gzip compression or minify. Notably, those guys all:
- take affect outside the application, and therefore - don't involve a regular expression being compiled and parsing through the entirety of script output every page load, and - they do a cleaner job of what FilterWhiteSpace is trying to do, - with better performance, - and bring their considerably higher-order features as well. - Oh, and no extra syspref. I understand the motivation for minifying Koha output, and I agree with that idea rather strongly, but I think we should be using existing tools and Apache features unless they prove unsatisfactory. --Joe On Mon, Mar 30, 2009 at 10:29 PM, Chris Cormack <[email protected]>wrote: > --- > C4/Output.pm | 7 ++++--- > installer/data/mysql/en/mandatory/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 +++++++ > kohaversion.pl | 2 +- > 4 files changed, 13 insertions(+), 4 deletions(-) > > diff --git a/C4/Output.pm b/C4/Output.pm > index 443383c..f800ef4 100644 > --- a/C4/Output.pm > +++ b/C4/Output.pm > @@ -366,10 +366,10 @@ sub output_html_with_http_headers ($$$;$) { > my $html = shift; > > # strip new lines or whitespace > - if (C4::Context->preference('FilterWhiteSpace') eq 'stripwhitespace'){ > + if (C4::Context->preference('StripWhiteSpace') eq 'stripwhitespace'){ > $html = remove_white_space($html); > } > - elsif (C4::Context->preference('FilterWhiteSpace') eq > 'stripnewlines'){ > + elsif (C4::Context->preference('StripWhiteSpace') eq 'stripnewlines'){ > $html = remove_newline($html); > } > > @@ -401,7 +401,8 @@ sub is_ajax () { > } > > sub remove_white_space { > - $_[0] =~ s/^\s+$//mgo; > + $_[0] =~ s/^\s*$//mgo; > + $_[0] =~ s/^\n//mg; > return $_[0]; > } > > diff --git a/installer/data/mysql/en/mandatory/sysprefs.sql > b/installer/data/mysql/en/mandatory/sysprefs.sql > index ef70ba6..8ef5f09 100644 > --- a/installer/data/mysql/en/mandatory/sysprefs.sql > +++ b/installer/data/mysql/en/mandatory/sysprefs.sql > @@ -229,3 +229,4 @@ INSERT INTO systempreferences > (variable,value,explanation,options,type) VALUES ( > INSERT INTO systempreferences (variable,value,explanation,options,type) > VALUES ('SyndeticsCoverImageSize', 'MC', 'Choose the size of the Syndetics > Cover Image to display on the OPAC detail page, MC is Medium, LC is > Large','MC|LC','Choice'); > INSERT INTO systempreferences (variable,value,explanation,options,type) > VALUES ('OPACAmazonCoverImages', '0', 'Display cover images on OPAC from > Amazon Web Services','','YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) > VALUES ('AmazonCoverImages', '0', 'Display Cover Images in Staff Client from > Amazon Web Services','','YesNo'); > +INSERT INTO systempreferences (variable,value,explanation,options,type) > VALUES ('StripWhiteSpace', 'off', 'Choose what filterin you want for html > output stripnewlines removes all newlines, stripwhitespace whitespace and > blank lines, and off does nothing', > 'off|stripnewlines|stripwhitespace','Choice'); > \ No newline at end of file > diff --git a/installer/data/mysql/updatedatabase.pl > b/installer/data/mysql/updatedatabase.pl > index 7e161b5..c4243d5 100755 > --- a/installer/data/mysql/updatedatabase.pl > +++ b/installer/data/mysql/updatedatabase.pl > @@ -2272,6 +2272,13 @@ if (C4::Context->preference("Version") < > TransformToNum($DBversion)) { > SetVersion ($DBversion); > } > > +$DBversion = '3.01.00.016'; > +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > + $dbh->do("INSERT INTO systempreferences > (variable,value,explanation,options,type) VALUES ('StripWhiteSpace', 'off', > 'Choose what filtering you want for html output stripnewlines removes all > newlines, stripwhitespace whitespace and blank lines, and off does > nothing','off|stripnewlines|stripwhitespace','Choice')"); > + print "Upgrade to $DBversion done (added Strip White space > filters)\n"; > + SetVersion ($DBversion); > +} > + > =item DropAllForeignKeys($table) > > Drop all foreign keys of the table $table > diff --git a/kohaversion.pl b/kohaversion.pl > index a0c6437..fc73c47 100644 > --- a/kohaversion.pl > +++ b/kohaversion.pl > @@ -10,7 +10,7 @@ > use strict; > > sub kohaversion { > - our $VERSION = '3.01.00.015'; > + our $VERSION = '3.01.00.016'; > # version needs to be set this way > # so that it can be picked up by Makefile.PL > # during install > -- > 1.5.6.3 > > _______________________________________________ > Koha-patches mailing list > [email protected] > http://lists.koha.org/mailman/listinfo/koha-patches >
_______________________________________________ Koha-patches mailing list [email protected] http://lists.koha.org/mailman/listinfo/koha-patches
