summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2013-02-12 21:33:39 -0800
committerelijah <elijah@riseup.net>2013-02-12 21:33:39 -0800
commit71ec0edea3f87fb69222dbb6fe025c2211402ca2 (patch)
tree5490323e8686df14165ccf5f37fa2d691fc99b88 /app/controllers/application_controller.rb
parent00c785b728c5d97335b87e3eb7d10b9ad0c46d35 (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.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