diff options
author | elijah <elijah@riseup.net> | 2013-02-12 21:33:39 -0800 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2013-02-12 21:33:39 -0800 |
commit | 71ec0edea3f87fb69222dbb6fe025c2211402ca2 (patch) | |
tree | 5490323e8686df14165ccf5f37fa2d691fc99b88 /app/controllers/application_controller.rb | |
parent | 00c785b728c5d97335b87e3eb7d10b9ad0c46d35 (diff) |
added capacity for pulling static pages from multiple directory source trees.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index da6cf3e..b2c5762 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,6 +3,10 @@ class ApplicationController < ActionController::Base protect_from_forgery before_filter :set_locale, :initialize_pages + class << self + attr_accessor :current_site # a class instance variable + end + if Rails.env.production? rescue_from Exception, :with => :render_500 rescue_from ActionController::RoutingError, :with => :render_404 @@ -81,25 +85,31 @@ class ApplicationController < ActionController::Base helper_method :page_body ## - ## INITIALIZATION + ## SITE ## # - # run every time in development mode, run once in production mode + # if we ever make this code support multiple sites, this should depend on the request's domain # - def initialize_pages - run_once(:initialize_pages, :unless => Rails.env.development?) do - StaticPage.load(PAGE_DIRECTORY) - Menu.load(PAGE_DIRECTORY + '/menu.txt') - end + def site + self.class.current_site ||= Site.new end + helper_method :site - def run_once(name, options={}) - key_name = "run_once_#{name}" - if !Thread.current[key_name] || options[:unless] - yield + def initialize_pages + if Rails.env.development? + site.load_pages + else + site.reload_pages_if_needed end - Thread.current[key_name] = true end + #def run_once(name, options={}) + # key_name = "run_once_#{name}" + # if !Thread.current[key_name] || options[:unless] + # yield + # end + # Thread.current[key_name] = true + #end + end |