summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb34
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