jellybob / activo-rails

Activo is a theme for Web-app-theme, Formtastic and Attrtastic. This is a Rails plugin to make it painfully easy to use.
http://dmfrancisco.github.com/activo/
MIT License
42 stars 8 forks source link

Rails 3.1 Asset Management #8

Closed tobsch closed 13 years ago

tobsch commented 13 years ago

Hi there,

this version supports basic rails 3.1 asset management/delivery. it breaks 3.0 compat, hope this is allright.

best,

tobias

jellybob commented 13 years ago

Hi there,

I like it in principle, however I think it's probably a bit early to entirely drop support for Rails 3.0, especially since I don't see there's a huge amount of benefit from switching to Sprockets to build the master CSS file, instead of using Rails asset caching to build a single file at the layout level. By updating the engine initializer it should still be possible to serve Activo's assets from the same path 3.1 would use.

My other concern is referencing assets as being at /assets/ from the stylesheets, which is going to break should the application be mounted on a sub-directory. I've not done a lot with the new asset pipeline, but surely there's still a way to reference them relatively.

Thanks for the patch, but unless those problems can be fixed, I'm going to have to leave it - at least until 3.1 is officially released, and I've tried updating some of the applications I'm using this with to see what effect it has.

tobsch commented 13 years ago

Should be possible to keep the asset management stuff rails 3.0 compatible. But IMHO this should not be an option. Maybe you could open up an experimental branch and we throw stuff together like the block and the asset management for the next "major release"?

jellybob commented 13 years ago

Ok, lets do that. The more I think about it, the more it seems that the majority of users are going to migrate to 3.1 anyway, and those who aren't can stick with the current version. I'm going to add you as a committer to the master repository, so feel free to start a branch for whatever the next version is... it seems a little early to be bouncing to 2.0, but if we're going to be breaking backwards compatibility, we may as well do it in style.

pithyless commented 13 years ago

@tobsch trying out your fork on a 3.1 project, firebug shows missing jQuery:

$ is not defined
$(document).ready(function() -> application.js (line 4)

Just taking a wild guess, I think the problem may be layouts/activo.html.erb:

<%= javascript_include_tag 'activo-rails/application' %>

Perusing your branch, it looks like all the sprocket imports are in activo-rails/activo-rails, not activo-rails/application. Is this a typo? Or am I barking up the wrong tree? I'd love to use activo-rails in this 3.1 project, but I'm a bit lost on how to get all the parts working with sprockets.

Would love some advice! :)

tobsch commented 13 years ago

@pithyless now it should work. there's gonna be a problem in production mode though: rails won't precompile application.js due to wrong settings. I opened an issue over there...

tobsch commented 13 years ago

hope I'll have some time for activo next weekend.

pithyless commented 13 years ago

@tobsch Cool, I'll keep an eye on this, thanks!

As far as production mode is concerned, I'm sure there will be other issues: all the url(..)'s will not be pointing to precompiled and cached versions. In another 3.1 project, I've got my sass files first going through erb and <%= asset_path(..) %>, but that is a really ugly hack. There has got to be a better way...

tobsch commented 13 years ago

yeah right. i know that. did it in another project too. hope they'll come up with a solution soon. lucky us that activo is not really for hightraffic stuff so we could use it without precompiled assets...

jellybob commented 13 years ago

Given Activo is distributed as a gem we could just make precompiling part of the release process. On Jun 7, 2011 10:12 PM, "tobsch" < reply@reply.github.com> wrote:

yeah right. i know that. did it in another project too. hope they'll come up with a solution soon. lucky us that activo is not really for hightraffic stuff so we could use it without precompiled assets...

Reply to this email directly or view it on GitHub: https://github.com/jellybob/activo-rails/pull/8#issuecomment-1322610

pithyless commented 13 years ago

I've been poking around Rails 3.1 assets, and it seems to me that the manifest file activo-rails/application.rb should in fact be called activo-rails/index.rb and then %= javascript_include_tag 'activo-rails' %> would pick up the index.rb manifest automagically and load all dependencies. And there would no longer be name conflicts with having two manifest application.rb files.

tobsch commented 13 years ago

I opened a branch called "rails3_1" holding all the changes.

tobsch commented 13 years ago

@pithyless in general, calling it index.js/css would be much cleaner, thanks for the tip. at this moment the "rake assets:precompile" - task won't cleanly recognize this and translate it to "activo-rails.js" so I'll stick with application.js so far. Please see the readme in my branch.