Ruby Forum NGINX > Re: mod_strip newline substitution problem

Posted by Rt Ibmer (Guest)
on 03.05.2008 05:29
(Received via mailing list)
Hi Evan


> The problem is that I can't replace newlines before end tags with a space:

Is that going to make it even more challenging to add support for 
removing unnecessary spaces from JavaScript files? Would love to see 
support for that one day. Currently we are doing this with a filter at 
the web server level and I bet doing it at the nginx level would be much 
more efficient.



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile.  Try it now. 
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
Posted by mike (Guest)
on 03.05.2008 06:07
(Received via mailing list)
could also control it from a "build" level

do some minifying or javascript compression, file combining and anything 
else
Posted by Evan Miller (Guest)
on 03.05.2008 20:49
(Received via mailing list)
Rt Ibmer <rtibmx@...> writes:

> 
> 
> Hi Evan
> 
> > The problem is that I can't replace newlines before end tags with a space:
> 
> Is that going to make it even more challenging to add support for removing 
unnecessary spaces from JavaScript files? Would love to see support for 
that
one day. Currently we are doing this with a filter at the web server 
level and
I bet doing it at the nginx level would be much more efficient.

Yes. The module will need to be rewritten to parse other languages. I'd 
like to
use Ragel, a state-machine generator that operates on data buffers.

http://www.cs.queensu.ca/~thurston/ragel/

Evan
Posted by Raul Rivero (Guest)
on 03.05.2008 21:38
(Received via mailing list)
Hi all,

We (soitu.es) has a module which cleans HTML and inserts blocks of HTML.

This is our first released module (called
ngx_http_html_clean_filter_module.c) and you could read the description
(in spanish) at:

     http://www.soitu.es/soitu/2008/04/28/met/1209378259_661127.html

An usage example is:

  location / {
     html_clean_active on;

     # Pixel counter and common JS to all pages.
     html_clean_pxlcntrblock '<div style="display:none">\
<img src="/pxlctl.gif" width="1" height="1" alt="" />\
<script language="Javascript" type="text/javascript" src="/comun.js">\
</script></div>';

     # Only common JS, no pixel counter
     html_clean_xcldpxlcntrblock '<div style="display:none">\
<script language="Javascript" type="text/javascript" src="/comun.js">\
</script></div>';

   }


A few lines about

   * Removes all white spaces at the begining of lines and empty lines.

   * Removes all HTML comments with a pattern like:

       <!-- =what ever[...]= -->

     So, the following comments is deleted:

       <!-- ===== Begin of menu ===== -->

     But not the:

       <!-- Begin of menu -->

   * Blocks surrounded by #IB and #EB are served without modifications:

       <!-- = #IB[...] = -->
       this will be
           served without
               been modified
       <!-- = #EB[...] = -->

   * The text defined in "html_clean_pxlcntrblock" is inserted after
<body> tag (we used to count pixels and common JS includes). The problem
is that we have pages which could not be counted (examples: iframes or
frames), so you'll need a <!-- = #XP = --> before <body> and the text
defined in "html_clean_xcldpxlcntrblock" will be inserted.

We are using in our production NGINX servers.

Cheers,
Posted by Tomek N. (tomek)
on 04.05.2008 00:24
Hi Raul,
Your module works fine :) (also against nginx nginx-0.6.30).
I'm using it on my production server with mod_stripe to cleanup fastcgi 
output code :)

Thanks,
Tomek