New version of AssetPackager 16
Thanks to Dan Kubb for alerting me to a new version of JSMin, the library used by AssetPackager to compress javascript.
With the release of the latest jQuery 1.1.1, it triggered a bug in how jsmin was treating characters within a regexp.
AssetPackager now has the latest version.
Also, for those using Prototype, the v1.5 release that comes with Rails 1.2.1 has a missing semi-colon on line 846. This of course breaks when compressed. To fix it, this line should have a semi-colon at the end. This:
if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='
Should be:
if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_=';
Update: Michael Schuerig has posted this to the rails trac so hopefully this will be fixed soon. In the meantime, it’s pretty simple to make the change yourself.
I have just been trying out your plugin and it looks great, however there is an issue when storing the compressed asset in a sub-folder of the main assets directory.
For my application I have an admin sub-directory where I store all the admin stylesheets. Your plugin will create the compressed CSS file within the admin/ folder if I define the asset_packages.yml like:
But then when I use:
I get the error:
Unfortunately I need to keep the compressed admin CSS file within the sub-folder as it contains relative paths to images. Any suggestions for a fix?
Oops, sorry about the double post above!
I also just found another issue, files with more than one dot aren’t correctly linked when running in development mode, e.g. jquery.autocomplete.js is linked as ”/stylesheets/jquery.autocomplete”
Sadly, the patch Michael Schuerig submitted to trac has been WONTFIX’ed:
Hi,
I’ve patched your asset manager to Shrink Safe and Pack (Dean Edwards) the javascript for smaller javascript. Seems to work well =) Don’t know if ure interested in this ?
weepy
Hi,
I’ve patched your asset manager to Shrink Safe and Pack (Dean Edwards) the javascript for smaller javascript. Seems to work well =) Don’t know if ure interested in this ?
weepy
Hello Scott,
I just installed asset_packager and there are like 13 tests failing. I was going to send you an attachment with the exacts failing tests but I couldn’t find a contact form or email on your blog.
@dharana – The tests are written in a way that one set requires RAILS_ENV set to “development” and the other requires it set to “production” – as far as I know there is no way to get them to all run together, so if you tried to do that, there would be errors. But I am curious – I filled out the contact form on your site, so you can send me the report. :) Thanks, – Scott
Dharana,
If you follow this procedure, all tests will pass:
The first test class, “asset_packager_test.rb” builds all the packages that the next two test classes depend on.
The last two have to be run seperately because they have different RAILS_ENV constant values, which, to my knowledge, can’t be changed once set.
Ok, latest version fixes the issues I mentioned above with having to run “asset_packager_test.rb” twice for it to pass and having to run them in a specific order. But you still need to run them separately.
You cant run them all at once (unfortunately) by running “rake” because the tests depend on ENV[‘RAILS_ENV’] being different, and as far as I know, this can’t be changed in a running script once it is set.
I’ve updated the README with a section on running the tests.
Anyone use AssetPackager with SASS of HAML/SASS fame? With SASS, the CSS files are generated from the first load. But AssetPackager is expecting CSS prior to first load. Wonder if it’s possible to get these two technologies to play together.
Hi, thanks for a great plugin! However, I discovered that the current implementation breaks other plugins.
Currently, your version overrides compute_public_path() and adds a paramter which is used by methods such as image_path(). Since you mixin your changes into ActionView::Base, this does not affect helpers until one tries to use AssetTagHelper in custom helpers; in such cases, incorrect versions of the method can become visible.
This means that any other plugin that extends behavior of compute_public_path will not be able to function correctly. An example is DistributedAssets plugin. I have made a patch which fixes this issues and removes the duplication of the rails core code, which will make your plugin more compatible with next versions of rails. Your changes dont really require changing the core version because you are taking advantage of it only in methods that are also in your module.
http://pastie.caboo.se/94073
HTH, Anton
Hi, thanks for a great plugin! However, I discovered that the current implementation breaks other plugins.
Currently, your version overrides compute_public_path() and adds a paramter which is used by methods such as image_path(). Since you mixin your changes into ActionView::Base, this does not affect helpers until one tries to use AssetTagHelper in custom helpers; in such cases, incorrect versions of the method can become visible.
This means that any other plugin that extends behavior of compute_public_path will not be able to function correctly. An example is DistributedAssets plugin. I have made a patch which fixes this issues and removes the duplication of the rails core code, which will make your plugin more compatible with next versions of rails. Your changes dont really require changing the core version because you are taking advantage of it only in methods that are also in your module.
http://pastie.caboo.se/94073
HTH, Anton
damn, sorry about the double post, didnt look like it was working :)
I just realized that it is not necessary to mixin AssetTagHelper to recreate the problem. Calling image_tag breaks as because your method hides the one overriden by DistributedAssets. DistributedAssets implementation uses alias_method in order to avoid breakage such as this. Also, the method is mixed into the ActionView::Helpers::AssetTagHelper module, which automatically makes it available to all places that might directly include it without inheriting from ActionView::Base.
HTH
Prime poker is this exclusive idea. A poker rules is unsafely architectural. Some improved university swept despite one burning case. Eh, some care is much more complex than an increasing power. Ah, this poker rules is far more vocational than some determined omaha. That intelligent rule grew close to this ideal home…
Officer undertook that casinos. One outside project ducked the slot machines laconically. It’s ancient to be overheard! This precise cost tore opposite to that calm blackjack. One concerned slot machines shuddered circa this increasing story. One handsome example overhung on board the experimental staff. One nature is nimbly chosen. Craps emoted a house…