This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

stupidly and manually merged james' changes because I fear trying to …

…diff from master to ansuz-core
  • Loading branch information...
Josh Adams
Josh Adams committed Mar 18, 2009
1 parent 8ea778b commit 332ec482beae079cdcb5bb59169814ff45c7868e
Showing with 22 additions and 0 deletions.
  1. +2 −0 app/controllers/application.rb
  2. +20 −0 lib/ansuz/plugin_manager.rb
@@ -10,6 +10,8 @@ class ApplicationController < ActionController::Base

theme :get_theme_setting

Ansuz::PluginManagerInstance.load_helpers(self)

def set_layout_variables
@root = Page.root || Page.new
@topNav = @root.publishable_children
@@ -11,6 +11,7 @@ class PluginManager
def initialize
@plugins = []
@plugin_nav = []
@helpers = []
@admin_plugin_nav = []
@admin_menu = {}
@admin_menu_top_level_entries = ADMIN_MENU_TOP_LEVEL_ENTRIES.clone
@@ -25,6 +26,7 @@ def register_plugin klass
self.plugins << klass
settings_name = klass.to_s.tableize.gsub(/\//,'_').to_sym
create_settings( settings_name )
require_helpers( klass.to_s )
end

# A plugin can call register_plugin_nav(title, link) to add itself to the
@@ -97,6 +99,24 @@ def plugins_for_routes
(installed_plugins & enabled_plugins).map(&:to_sym)
end

def require_helpers(name)
path = "#{RAILS_ROOT}/ansuz_installed_plugins/**/*#{helper_plugin_name(name)}*/**/*_helper.rb"
Dir[path].each do |f|
@helpers << name
require f
end
end

def load_helpers(controller)
@helpers.each do |helper|
controller.send(:helper, "#{helper}Helper".constantize)
end
end

def helper_plugin_name(klass_name)
klass_name.tableize.singularize.split("\/").last
end

protected
def create_settings(name)
begin

0 comments on commit 332ec48

Please sign in to comment.