Closed MrDys closed 12 years ago
Original reporter: jrochkind
jrochkind: good enough for now.
jrochkind: Okay, I've been unable to come up with a solution I'm totally happy with. Largely keep running up against a road block in a missing functionality in RAils --- once you've defined a method to determine the layout, it's not possible for that layout to return (eg) a 'true' value meaning "use default layout lookup logic", you NEED to return a specific layout name. That kept getting in the way of all the various ideas I had for elegantly have BL provide a default layout for BL controllers, but make it easy to turn off etc.
So I'm going to do the simplest thing that will improve the most egregious problem with the current setup. There's currently a choose_layout method which you can over-ride in your own application_helper, but you have to over-ride more than you want (logic for suppressing layout for XHR etc). I'm going to factor out a #layout_name method that you can over-ride, over-riding just the layout name without having to copy/fork the logic for supressing in case of XHR too.
Will commit momentarily.
jrochkind: Some more thoughts on layouts.
*. It is in fact possible to do quite substantial_look and feel changes using the built-in layout, just using CSS as well as localizing some of the partials the layout calls out to (like user_util_links or whatever the navbar is called). This is in fact what I've done (or what I should have done -- I think I localized it to add google analytics, before realizing GA could be added using unobtrusive js instead).
-> Using the same layout BOTH for blacklight controllers AND for all the rest of your controllers, AND having this layout include the standard Blacklight functionality.
That's not the only case we want to support, but I think it will be a very common and typical one, especially for less-expert users. I think it's one we want to make very simple. Currently, whether you localize the layout or not, trying to do the above pretty typical case is a bit more confusing/complicated than it should be, and also involves copying some logic (not to display the layout in XHR) to your local app that it would really be better to leave living in BL core (in case it changes in the future).
So that's my basic impetus, to make that use case work as simply as possible for newbies.
CODEBASE-309: In current BL-Rails3, all Blacklight actions use a "blacklight" layout, which is included in the plugin. The point of this is to provide an out-of-the-box fully functional and aesthetically pleasing layout for just BL controllers, without touching other controllers in the app.
However, some (cbeer) have found this confusing to figure out what's going on. Also, a very typical use case is you are going to want blacklight controllers to use your overall application layout same as any other controllers, and it's somewhat trickier to do this than you might want for such a common case.
Keep in mind the BL layout includes some hooks for actual functionality (like link rel=alternative auto-discovery), as well as aesthetic design. You can certainly copy those hooks into your own layout. While some (dfunk) choose to over-ride and not use that functionality, I think it's important people realize they are doing so and choosing to do so, the default path should ideally not lead people doing this by accident and losing functionality.
In Rails2, BL provided it's own "application" layout in the plugin, which the demo app didn't automatically over-ride locally, but you could over-ride it locally. This won't work in Rails3 version, when the initial app is going to already have an application layout.
Possible options I can think of: