diff --git a/lib/themes_on_rails/action_controller.rb b/lib/themes_on_rails/action_controller.rb index 1368e24..6701bac 100644 --- a/lib/themes_on_rails/action_controller.rb +++ b/lib/themes_on_rails/action_controller.rb @@ -42,7 +42,7 @@ def before_filter_method(options) case Rails::VERSION::MAJOR when 3 options.delete(:prepend) ? :prepend_before_filter : :before_filter - when 4, 5 + when 4, 5, 6, 7 options.delete(:prepend) ? :prepend_before_action : :before_action end end diff --git a/lib/themes_on_rails/controller_additions.rb b/lib/themes_on_rails/controller_additions.rb index 0dddd91..40961e8 100644 --- a/lib/themes_on_rails/controller_additions.rb +++ b/lib/themes_on_rails/controller_additions.rb @@ -2,7 +2,7 @@ module ThemesOnRails module ControllerAdditions extend ActiveSupport::Concern - module ClassMethods + class_methods do def theme(theme, options={}) @_theme = theme @_theme_options = options diff --git a/lib/themes_on_rails/engine.rb b/lib/themes_on_rails/engine.rb index d636be4..22a2dac 100644 --- a/lib/themes_on_rails/engine.rb +++ b/lib/themes_on_rails/engine.rb @@ -19,19 +19,17 @@ class Engine < ::Rails::Engine end initializer 'themes_on_rails.precompile' do |app| - app.config.assets.precompile << Proc.new do |path, fn| - if fn =~ /app\/themes/ - basename = path.split('/').last - if !%w(.js .css).include?(File.extname(path)) - true - elsif path =~ /^[^\/]+\/all((_|-).+)?\.(js|css)$/ - # 1. don't allow nested: theme_a/responsive/all.js - # 2. allow start_with all_ or all- - # 3. allow all.js and all.css - true - else - false - end + themes_root = Pathname.new("#{Rails.root}/app/themes") + allowed_assets_regex = /^[^\/]+\/assets\/(stylesheets|javascripts)\/[^\/]+\/all((_|-).+)?\.(js|css)$/ + + Dir.glob(themes_root.join("*/assets/**/*").to_s).each do |entry| + next unless File.file?(entry) + # 1. don't allow nested: theme_a/responsive/all.js + # 2. allow start_with all_ or all- + # 3. allow all.js and all.css + relative_entry = Pathname.new(entry).relative_path_from(themes_root).to_s + if !%w(.js .css).include?(File.extname(entry)) || relative_entry =~ allowed_assets_regex + app.config.assets.precompile << entry end end end