This looks pretty reasonable, at least in principal.  Care to providean example 
of what one of the existing sidebars would look like, andhow the sidebar views 
fit into the picture?

Scott
On 3/20/06, Piers Cawley <[EMAIL PROTECTED]> wrote:> I love sidebars, sidebars 
are cool.>> I'm less enamoured of our current implementation of 'em, because> 
they're components and components are slow and a pain in the bum to> test.>> 
With that in mind I've been playing with turning them into plugins> that 
delegate to a controller for almost everything. The basic parent> might look 
something like (with lots of handwaving)>> class PluggableSidebar>   
@@subclasses = {}>   cattr_accessor :controller>   class << self>     # Keep 
track of our subclasses and have them keep track of theirs>     def inherited; 
...; end>     def subclasses; ... ; end>>     def available_sidebars>       
subclasses.select {|sidebar| sidebar.subclasses.empty?}>     end>   end>>   
class SetupSidebarFilter>     class << self>       def before(controller)>      
   PluggableSidebar.controller = controller>       end>       def 
after(controller)>         PluggableSidebar.controller = nil>       end>     en!
d>   end>>   def method_missing(*args)>     if @@controller>       
@@controller.send(*args)>     else>       raise NoMethodError, "undefined 
method #{args[0]} for #{self.class}">     end>   end>>   def render(*args)>     
@performed = true>     @@controller.render_to_string(*args)>   end>>   def 
performed?>     @performed || false>   end>>   def configuration_wrapper>     
with_include_path(self.class.view_path) do>       configure>       render 
:partial => "configure", :locals => {sidebar => self} unless peformed?>     
end>   end>>   def index>     with_include_path(self.class.view_path) do>       
content>       render :partial => "content", :locals => {sidebar => self} 
unless peformed?>     end>   end> end>> Lots of stuff missing, obviously, but 
the basic goal is to turn> the Sidebar parent class into something that *feels* 
like a controller> to someone writing one, but which can be called with a 
helper without> having to go through the rather heavyweight process of renderin!
g a> component.>> Also, I want to be able unify the current Sidebar and> 
SidebarController classes in such a way that a Sidebar can be> serialized to 
YAML and stored on the blog object, and in a> :staged_sidebars key in the 
flash.>> Thoughts?>> --> Piers Cawley <[EMAIL PROTECTED]>> 
http://www.bofh.org.uk/> _______________________________________________> 
Typo-list mailing list> [email protected]> 
http://rubyforge.org/mailman/listinfo/typo-list>
_______________________________________________
Typo-list mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/typo-list

Reply via email to