Advanced Plugin System

File Structure

plugins/
  my_plugin/
    app/
      controllers/
      models/
      views/
    lib/
      my_plugin.rb
    patches/  #monkey patches for Radiant or Rails
    db/
      migrations/
        01_create_comments_table.rb
        02_create_reviews_table.rb
        ...
      schema.rb
    vendor/
    init.rb
    setup.rb

init.rb

require "my_plugin"
MyPlugin.init

setup.rb

require "my_plugin"
MyPlugin.setup

lib/my_plugin.rb

require 'my_behavior'

class MyPlugin < Radiant::Plugin::Base
  register "My Plugin"
  depends_on :your_plugin, :another_plugin
  
  def activate
    routes.my_route "my/route", :controller => "my_controller", :action => "my_action"
    admin.tabs.add "My Plugin", my_route_url
    behaviors.activate "My Behavior"
  end

  def deactivate
    admin.tabs.remove "My Plugin"
    routes.remove "my/route"
    behaviors.deactivate "My Behavior"
  end
end