Re: [Catalyst] Minify JS/CSS and server as static files

2011-08-11 Thread Pavel Karoukin
On 08/08/2011 12:05 AM, Bill Moseley wrote:
 What I do is define a YAML file that defines resource sets (where a
 resource is anything I want to serve differently in production, like
 css, javascript and even versioned items like background images or PDFs).

 For example, a set might be defined of one or more (typically more)
 css files.  The set has a name (e.g. style) and then in my templates
 I use a macro to include it.  Under development the markup is rendered
 with the individual css files that make up the set.  Under production
 the markup includes a link to a single minified and versioned
 versioned URL (on a CDN).   We can also easily toggle this on
 production via request data (to debug on production someone wanted).
  The versioning is done via an md5 of the compressed file and the
 minified files are cached forever.

 The build process runs a script that builds the minified files.  I've
 often though about trying to integrate it into the Makefile so that
 only changed source files trigger a build of the minified file.



Thank you Bill. This looks like a good approach.

Could you tell me more about your YAML config, is it part of
MyApp.yaml or it is separate? If it is separate - how do you plug it in?

Also, could you tell me more about versioning you use? Do you generate
different filenames for each compressed file or you do something else?

Regards,
Pavel

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Minify JS/CSS and server as static files

2011-08-07 Thread Bill Moseley
On Sun, Jul 31, 2011 at 9:17 PM, Pavel Karoukin hipp...@gmail.com wrote:

 Hello,

 I am looking to develop feature in my project but want to check if
 something already exists or there is existing pattern to implement it.

 Bassically, I want in my TT templates add JS/CSS files into header. And
 in production mode I want minify/aggregate 'em and save on disc so web
 server could serve these minified and aggregated files directly.

 How I plan to do it:

 In TT layout template define array variable and all templates will be
 adding there JS/CSS they need. Then in main template I will generate
 code like:

 link rel=stylesheet type=text/css
 href=/minify/css?files=path/to/file1.css;path/to/file2.css /



What I do is define a YAML file that defines resource sets (where a
resource is anything I want to serve differently in production, like css,
javascript and even versioned items like background images or PDFs).

For example, a set might be defined of one or more (typically more) css
files.  The set has a name (e.g. style) and then in my templates I use a
macro to include it.  Under development the markup is rendered with the
individual css files that make up the set.  Under production the markup
includes a link to a single minified and versioned versioned URL (on a CDN).
  We can also easily toggle this on production via request data (to debug on
production someone wanted).  The versioning is done via an md5 of the
compressed file and the minified files are cached forever.

The build process runs a script that builds the minified files.  I've often
though about trying to integrate it into the Makefile so that only changed
source files trigger a build of the minified file.




 /minify/css will be action of controller minify to join and minify these
 files and save them in /static subfolder as single file. Then I need to
 configure webserver somehow to look for this file (good question - how
 to do it...) and serve it directly instead of firing catalyst action.

 Few problems tho:
 1) How to name files to keep track of: list of files in minified file,
 their update date.
 2) How to remove old files. (probably with cron?)

 Any ideas will be really appreciated!

 Regards,
 Pavel

 ___
 List: Catalyst@lists.scsys.co.uk
 Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
 Searchable archive:
 http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
 Dev site: http://dev.catalyst.perl.org/




-- 
Bill Moseley
mose...@hank.org
___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Minify JS/CSS and server as static files

2011-08-01 Thread Trevor Leffler
If you've a build process, that can also be a good time to create 
minified versions of css/js, pre-process templates, etc. so that 
everything is how you want it for your production environment.


--Trevor


Pavel Karoukin wrote:

Hello,

I am looking to develop feature in my project but want to check if
something already exists or there is existing pattern to implement it.

Bassically, I want in my TT templates add JS/CSS files into header. And
in production mode I want minify/aggregate 'em and save on disc so web
server could serve these minified and aggregated files directly.

How I plan to do it:

In TT layout template define array variable and all templates will be
adding there JS/CSS they need. Then in main template I will generate
code like:

link rel=stylesheet type=text/css
href=/minify/css?files=path/to/file1.css;path/to/file2.css /

/minify/css will be action of controller minify to join and minify these
files and save them in /static subfolder as single file. Then I need to
configure webserver somehow to look for this file (good question - how
to do it...) and serve it directly instead of firing catalyst action.

Few problems tho:
1) How to name files to keep track of: list of files in minified file,
their update date.
2) How to remove old files. (probably with cron?)

Any ideas will be really appreciated!

Regards,
Pavel

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


[Catalyst] Minify JS/CSS and server as static files

2011-07-31 Thread Pavel Karoukin
Hello,

I am looking to develop feature in my project but want to check if
something already exists or there is existing pattern to implement it.

Bassically, I want in my TT templates add JS/CSS files into header. And
in production mode I want minify/aggregate 'em and save on disc so web
server could serve these minified and aggregated files directly.

How I plan to do it:

In TT layout template define array variable and all templates will be
adding there JS/CSS they need. Then in main template I will generate
code like:

link rel=stylesheet type=text/css
href=/minify/css?files=path/to/file1.css;path/to/file2.css /

/minify/css will be action of controller minify to join and minify these
files and save them in /static subfolder as single file. Then I need to
configure webserver somehow to look for this file (good question - how
to do it...) and serve it directly instead of firing catalyst action.

Few problems tho:
1) How to name files to keep track of: list of files in minified file,
their update date.
2) How to remove old files. (probably with cron?)

Any ideas will be really appreciated!

Regards,
Pavel

___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/


Re: [Catalyst] Minify JS/CSS and server as static files

2011-07-31 Thread Mike Raynham

These might get you started:

Catalyst::View::JavaScript::Minifier::XS

and

Catalyst::View::CSS::Minifier::XS

http://search.cpan.org/~frew/Catalyst-View-JavaScript-Minifier-XS-2.101000/lib/Catalyst/View/JavaScript/Minifier/XS.pm

http://search.cpan.org/~frew/Catalyst-View-CSS-Minifier-XS-2.00/lib/Catalyst/View/CSS/Minifier/XS.pm




On 31/07/11 19:17, Pavel Karoukin wrote:

Hello,

I am looking to develop feature in my project but want to check if
something already exists or there is existing pattern to implement it.

Bassically, I want in my TT templates add JS/CSS files into header. And
in production mode I want minify/aggregate 'em and save on disc so web
server could serve these minified and aggregated files directly.

How I plan to do it:

In TT layout template define array variable and all templates will be
adding there JS/CSS they need. Then in main template I will generate
code like:

link rel=stylesheet type=text/css
href=/minify/css?files=path/to/file1.css;path/to/file2.css /

/minify/css will be action of controller minify to join and minify these
files and save them in /static subfolder as single file. Then I need to
configure webserver somehow to look for this file (good question - how
to do it...) and serve it directly instead of firing catalyst action.

Few problems tho:
1) How to name files to keep track of: list of files in minified file,
their update date.
2) How to remove old files. (probably with cron?)

Any ideas will be really appreciated!

Regards,
Pavel


___
List: Catalyst@lists.scsys.co.uk
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
Dev site: http://dev.catalyst.perl.org/