diff options
| author | Robin Houston <robin.houston@gmail.com> | 2012-06-05 10:53:49 +0100 | 
|---|---|---|
| committer | Robin Houston <robin.houston@gmail.com> | 2012-06-05 10:53:49 +0100 | 
| commit | 0b10c9002481d80d4a70ca224fc49aa5970c6294 (patch) | |
| tree | da2fa512c6c6b467591ca3d8422dc24b203ba451 | |
| parent | e3cfe550fe835c68b25d693abd40aedd954913b3 (diff) | |
Multi-theme support for custom routes
A simple mechanism for allowing multiple themes to register
custom routes.
| -rw-r--r-- | config/initializers/theme_loader.rb | 6 | ||||
| -rw-r--r-- | config/routes.rb | 4 | 
2 files changed, 8 insertions, 2 deletions
| diff --git a/config/initializers/theme_loader.rb b/config/initializers/theme_loader.rb index 4ddce6910..8908dc07e 100644 --- a/config/initializers/theme_loader.rb +++ b/config/initializers/theme_loader.rb @@ -1,5 +1,9 @@ +# 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 theme interfere with Alaveteli specs +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__ diff --git a/config/routes.rb b/config/routes.rb index c0d65042c..814deb760 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,7 +7,9 @@  # $Id: routes.rb,v 1.92 2009-10-14 22:01:27 francis Exp $  # Allow easy extension from themes. Note these will have the highest priority. -load File.join('config', 'custom-routes.rb') +$alaveteli_route_extensions.each do |f| +    load File.join('config', f) +end  ActionController::Routing::Routes.draw do |map| | 
