Changeset 3

Show
Ignore:
Timestamp:
07/17/2006 03:42:25 AM (2 years ago)
Author:
matthew
Message:

Added support for "controller includes" in plugins, which are modules to
be included into the controller -- allowing plugins to add custom
actions.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/auto-admin/lib/auto_admin_configuration.rb

    r1 r3  
    1818  def self.asset_root; theme.asset_root; end 
    1919  def self.helpers; theme.respond_to?( :helpers ) ? [theme.helpers].flatten : []; end 
     20  def self.controller_includes; theme.respond_to?( :controller_includes ) ? [theme.controller_includes].flatten : []; end 
    2021 
    2122  def self.set_site_info full_url, site_name, admin_site_title='Site Administration' 
  • trunk/auto-admin/lib/auto_admin_controller.rb

    r2 r3  
    2121  verify :method => :post, :only => %w( save delete ) 
    2222    #, :redirect_to => { :action => 'confirm_post' } 
     23 
    2324  helper AutoAdmin::AutoAdminConfiguration.helpers 
     25  AutoAdmin::AutoAdminConfiguration.controller_includes.each do |inc| 
     26    include inc 
     27  end 
    2428 
    2529  #model :user 
  • trunk/auto-admin/lib/auto_admin_simple_theme.rb

    r1 r3  
    66    def asset_root 
    77      directory 'public' 
     8    end 
     9    def controller_includes *includes, &proc 
     10      @controller_includes ||= [] 
     11      includes.each do |mod| 
     12        @controller_includes << mod 
     13      end 
     14      if block_given? 
     15        @controller_includes << Module.new(&proc) 
     16      end 
     17      @controller_includes 
    818    end 
    919    def helpers 
     
    3646 
    3747    def table_header(field_type, field_name, options) 
    38       %(<th>#{yield}</th>
     48      content_tag('th', yield, options[:attributes] || {}
    3949    end 
    4050    def table_cell(field_type, field_name, options) 
    41       %(<td>#{yield}</td>
     51      content_tag('td', yield, options[:attributes] || {}
    4252    end 
    4353