Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
stupidly and manually merged james' changes because I fear trying to …
Browse files Browse the repository at this point in the history
…diff from master to ansuz-core
  • Loading branch information
Josh Adams committed Mar 18, 2009
1 parent 8ea778b commit 332ec48
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/controllers/application.rb
Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions lib/ansuz/plugin_manager.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 332ec48

Please sign in to comment.