mattmccray

 
« More Zebras | Home | Radiant's Radiance »

Rails Theme Support Plugin v 1.4

» Published April 09, 2006 under Rails, Software, Theme Support
I've just checked in version 1.4 of the theme_support plugin. It contains quite a few bugfixes and updates. This version also integrates a couple of patches from akg and D.J. Vogel. Thanks guys! Version 1.4 adds:
  • Bugfixes, of course
  • Better Rails 1.1 support
  • ActionMailer theme support (experimental)
  • Updates to the themeitem liquid tag
  • Support for theme sub-directories
  • Fleshed out the Theme object to make is easy to list all of the installed Themes
As a little background, the plugin is based on the theme system developed by the Typo guys and adds support for:
  • Multiple concurrent themes
  • A rails generator for creating a theme folder structure
  • Rake tasks for pre-caching all of the themes for increased security and performance
  • Overriding views with theme-specific rhtml or liquid templates (based on early Typo code)
  • Forcing theme views to only allow liquid templates
  • Made supporting themes as easy as using layouts
To install the plugin, go to your rails application root folder and run:
  ./script/plugin install http://mattmccray.com/svn/rails/plugins/theme_support
or, for you Windows folks:
  ruby script\\plugin install http://mattmccray.com/svn/rails/plugins/theme_support
Look at the README in $/vendor/plugins/theme_support for more on implementing themes in your application.

27 comments

04.17.06 @ 19:43 Whitney Young said...
I’ve got a small addition that I’d like to add. Can you email me so I can send you a patch? The plugin’s great, by the way!
04.17.06 @ 10:44 Lee Hambley said...
Nice one Matt, been looking forward to this – Kudos on making it work a bit better with 1.1 – I’ll be sure to write a Turorial for this, maybe for the Wiki – might help a few newbies here and there.

Keep up the good work!
04.19.06 @ 12:11 Nigel Ball said...
Thanks for making this plugin available.

It seems that it does not work when using ActionMailer templates for content typing.

For example, if the mailer viewa are named order.text.html.rhtml and order.text.plain.rhtml to automatically generate multi-pert/alternative emails the plugin either generates this error…

No rhtml, rxml, or delegate template found for order_mailer/sent.text.html.rhtml

If it does not generate the error, it appears to put itself into an endless loop.

Can you confirm that this is the case? Any ideas on a fix?

Thanks, Nigel
04.19.06 @ 18:01 M@ said...
Hmm

I haven’t seen this… But I didn’t test for that specifically, either. I’ll have a look and get back to you.
05.16.06 @ 11:35 Andreas Alin said...
Very nice!
But, there’s one thing. If I generated my controller with script/generate admin/pages, theme_stylesheet_link_tag will try to include /stylesheets/stylesheetname.css, instead of /themes/admin/stylesheets/stylesheetname.css .
Do you have any idea on how to solve this?
05.16.06 @ 11:47 Andreas Alin said...
Oops. Sorry, that was my own fault.
I had put: layout ‘admin/admin’ in my admin/pages-controller. :)
Now, there’s only one thing to say: This plugin rocks!
06.13.06 @ 12:47 Christian Zuckschwerdt said...
I prefer plugins over generators so this is very handy for me. Thanks!
I noticed one error in the README. It talks about the ‘javascripts’ directory but your plugin uses ‘javascript’ (plural vs. singular).
06.22.06 @ 14:37 EleoChan said...
This plugin is super useful and easy to use.
07.17.06 @ 03:00 cedric said...
Hello,

seems to be an error in line 35 of file:
http://mattmccray.com/svn/rails/plugins/..

STERR.puts must be STDERR.puts

;-)

(I had some performance issue with caching in production…)

Regards.
08.05.06 @ 16:28 Chris said...
I’m trying to use your plugin w/ edge rails… looks like it breaks due to some of the routing changes. I’m just manually including the routes in my routes.rb file for now. Have you looked into how include those theme routes automatically w/ edge rails?
08.19.06 @ 01:21 Nate said...
This plugin is awesome. Very useful resource. Thank you for the contribution!

It did however break my REST webservices that make calls like:

render :action => “list.rxml”, :layout => false

I haven’t plunged into the code a great deal, but i know basically actionview_ex.rb doesn’t catch the original template using pick_template_extension(theme_path) and it throws the error after the loop:

ActionView::ActionViewError (No rhtml, rxml, or delegate template found for trades/list.rxml).

I got rid of the raising of this error and let the processing fall into just calling the original render file:

return __render_file(template_path, use_full_path, local_assigns)

This gave the original the chance to render the XML template and lo and behold it was able to.

Can anyone else confirm this problem?
08.20.06 @ 17:38 Jonas Bengtsson said...
Chris: I had some problems with the routing as well. I’ve rewritten routeset_ex.rb to make it work. Does it solve your problems as well?
http://jira.openqa.org/browse/SOR-1#acti..
08.22.06 @ 00:05 Chris Abad said...
Jonas,

Here’s what I’m using right now for Edge Rails:
http://pastie.caboo.se/9651

This works fine, but I also recognized that this solution can only be used once, and therefore not as scalable as I’d like.

I’ve been looking to investigate less-destructive methods. I’ll have to try your way when I get a chance.
08.31.06 @ 02:43 jomyoot said...
I am not sure if this is normal, but my themes directory is placed right in RAILS_ROOT, and not RAILS_ROOT/public
08.31.06 @ 02:52 jomyoot said...
Not sure if this is related, but the loading of images from /themes/[theme]/images is very very very slow when using webrick — much slower than without using this theme plugin

What can I do for this? Do I need to run some kind of rakes to precache the images?
08.31.06 @ 04:06 M@ said...
Yes, RAILS_ROOT/themes is correct. In production mode, Rails will cache the theme files for you in the public/ folder.
08.31.06 @ 04:06 M@ said...
There is, in fact, a rake task to pre-cache the theme files:

rake theme_create_cache

In development mode it is easier/faster — if the theme isn’t changing too much.
09.09.06 @ 14:29 Niklas said...
Nate: Yes, I can confirm this behaviour. The theme plugin does not find .rjs templates, either if you use respond_to for a RESTful interface. Your quickfix helped me a lot, thank you.

@Matt: It would be awesome if you could fix that. Go on, this plugin is great!
09.12.06 @ 08:52 M@ said...
Yeah, I need to show this plugin some love — it’s been a while since I’ve updated it. I’ve received quite a few patches I need to apply (thanks for sending those in!)nnLook for a new release in the next week or so.
12.27.06 @ 17:52 Gitte Wange said...
Hi!

Awsome plugin! It works like a charm!
There’s just one thing not working – integration tests! Whenever I run an integration test, I end up with this error:
ActionView::ActionViewError (No rhtml, rxml, or delegate template found for layouts/site)

What am I missing? Should I require something from within my integration test?
12.27.06 @ 18:04 Gitte Wange said...
And just forget all about that bug report – I was the bug :-)

Just didn’t read my own code for setting the current theme very well …
02.08.07 @ 07:34 Vicent said...
I have install the theme_support, and now when I make ‘ruby script/server’ I get:
vicent@debian:~/RoR/openticket$ ruby script/server
=> Booting WEBrick…
Liquid doesn’t seem to be loaded… uninitialized constant Liquid
./script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:27:in `create_theme_routes’: undefined method `named_route’ for # (NoMethodError)
from ./script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:13:in `draw’
from ./script/../config/../config/routes.rb:1
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in `load’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in `load’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:343:in `new_constants_in’
from /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/dependencies.rb:489:in `load’
from /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/routing.rb:1154:in `load_routes!’
from /usr/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/routing.rb:1146:in `reload’
... 16 levels…
from /usr/lib/ruby/gems/1.8/gems/rails-1.2.1/lib/commands/server.rb:39
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
from script/server:3
03.25.07 @ 01:38 Adam Salter said...
Vincent the solution is given in the comments above:
See Jonas Bengtsson’s link or Chris Abad’s for answer.

Note: Jonas has the solution in the comments.

Cheers,
04.30.07 @ 15:05 sergio said...
if you are running themes using imaspy’s patch and working on a working copy of a project, you might want to check my blurb on using the patch with subversion..

it is here:
http://www.village-buzz.com/2007/04/30/t..
06.08.07 @ 20:18 loppr said...
[sergio:24]

Imaspy site is down. :(

I have rails 1.2.3 and I can’t running this plugin
11.28.07 @ 03:12 Damien said...
I’ve written an article on how to install this plugin in rails 1.2.6

You’ll find it on my blog
01.09.08 @ 05:19 Damien said...
You’ll find an article on how to use this plugin with rails 2.0 on my blog

No trackbacks

Trackback link:

Please enable javascript to generate a trackback url


You may use Textile, or simple html tags (B,I). Feel free to use Emoticons too. Oh, and please limit yourself to only five links per comment. Anything more and you'll probably get detained by the spam police.