aboutsummaryrefslogtreecommitdiffstats
path: root/config/initializers/theme_loader.rb
diff options
context:
space:
mode:
Diffstat (limited to 'config/initializers/theme_loader.rb')
-rw-r--r--config/initializers/theme_loader.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/config/initializers/theme_loader.rb b/config/initializers/theme_loader.rb
new file mode 100644
index 000000000..8908dc07e
--- /dev/null
+++ b/config/initializers/theme_loader.rb
@@ -0,0 +1,14 @@
+# This is a global array of route extensions. Alaveteli modules may add to it.
+# It is used by our config/routes.rb to decide which route extension files to load.
+$alaveteli_route_extensions = []
+
+theme_urls = MySociety::Config.get("THEME_URLS", [])
+if ENV["RAILS_ENV"] != "test" # Don't let the themes interfere with Alaveteli specs
+ for url in theme_urls.reverse
+ theme_name = url.sub(/.*\/(.*).git/, "\\1")
+ theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__
+ if File.exists? theme_main_include
+ require theme_main_include
+ end
+ end
+end