Closed JediFreeman closed 12 years ago
Nicely done, Jedi ;)
Let me ask you something. With your proposed configuration, the view files would be on app/assets/themes/views?
I think we are on the right track, but I would prefer to split the themes information like this:
# Assets
app/assets/themes/dark/{stylesheets,javascripts,images}
# Views
app/views/themes/dark/**/*
What do you think?
PS: The good thing about what you did is that you are not breaking compatibility.
Lucas
That is a good point, my implementation currently puts the views in the assets path as well: /app/assets/themes/dark/{stylesheets,javascripts,images,views}
I figured from an organizational standpoint, keeping all the theme related content in the theme folder felt better. However, I have an idea on the view splitting for those that do not want to structure it that way... I will update shortly.
I know, but views should not go there, on the assets folder. That's for static assets files only (IMHO).
Take a look, added a ThemesForRails.config.views_dir
attribute that defaults to {assets_dir}/views
(and assets_dir defaults to themes_dir for non asset pipeline users to continue working). Changing that config in your initializer to a new location, such as app/views/themes
and storing your theme views in /app/views/themes/dark/**/*
works great.
Minor change to the ThemesForRails.config.view_path_for
method to use the views_dir path instead of assets_dir path in the call to theme_path_for. Other calls for static assets (images, stylesheets, javascripts) use assets_dir when calling theme_path_for to continue working properly.
The test cases will need to be tweaked and verified for these new settings, I ran through things on my vagrant vm in dev and prod environments with no issues.
Do you have a couple of minutes? Please, look me up on Skype. I am lucasefe. Thanks
I realized something, with the config using /app/views/themes/theme_name/**/*
you could potentially run into conflict with routes if you actually have a themes controller and views... I think that is something that would need to be addressed with a warning in the readme to avoid conflicts since it is an option to actually move the views path there.
@JediFreeman Hey, after merging I realized this change breaks backward compatibility, since the views_dir needs to be "themes/theme_name/views" and not "themes/views/theme_name".
So, I am thinking about something like what paperclip gem does:
# :root # themes parent dir || Rails.root
# :name # theme name
# Rails 3.0 - No Assets Pipeline.
ThemesForRails.config.themes_dir = ":root/themes"
ThemesForRails.config.assets_dir = ":root/themes/:name"
ThemesForRails.config.views_dir = ":root/themes/:name/views"
# Rails 3.1 - With Assets Pipeline.
ThemesForRails.config.assets_dir = ":root/app/assets/themes"
ThemesForRails.config.views_dir = ":root/app/views/themes"
# defaults
ThemesForRails.config.themes_dir = interpolate ":root/themes"
ThemesForRails.config.assets_dir = interpolate ":root/themes/:name"
ThemesForRails.config.views_dir = interpolate ":root/themes/:name/views
What do you think? This way everything still works.
Good catch... makes the config a bit more robust too.
I did the changes. Tell me what do you think.
Backward compatible configurartion, out of the box.
ThemesForRails.config do |config|
config.themes_dir = ':root/themes'
cconfig.assets_dir = ":root/themes/:name"
config.views_dir = ":root/themes/:name/views"
end
Configuration required to make it work with assets pipeline.
ThemesForRails.config do |config|
config.themes_dir = ':root/themes'
config.assets_dir = ":root/app/assets/themes/:name"
config.views_dir = ":root/app/views/themes/:name"
config.themes_routes_dir = "assets" # by default, it uses themes
end
Need feedback...
Seems it has some kind of problems with the 'compass' gem. Everything works well, but if I try to @import "compass"
within a sass file, I'm getting this error:
Same error also using some more lightweight option like bourbon https://github.com/thoughtbot/bourbon Any clues? Where could I investigate more? Thanks!
Has this feature been tested? It seems to me that's totally broken :) even simple sass partial includes don't work. In the code I cannot find any line in which you add the theme asset paths to the Sprockets engine. Am I missing something?
It's working so far pretty good.
Are you using @import on your scss file?
Can you provide a gist/pastie with a code snippet?
Thanks
I've prepared a vanilla test project here: https://github.com/stefanoverna/themes_for_rails_test, but I'm getting a strange undefined method base_theme_javascript_path
, so it seems that there's some problems with the routes now :( Any clues?
Alright, solved adding themes_for_rails
into routes.rb
. Seems to be working. Will investigate more on the more complex project :)
I have spent some time going through the Asset Pipeline functionality and getting it working with themes_for_rails. Take a look at these commits and let me know what you think.
I have taken some of the refactoring branch code where the routes were cleaned up a bit, etc. as well. I have this working on my rails 3.2.1 app currently.