Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/themes_on_rails/action_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/themes_on_rails/controller_additions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 11 additions & 13 deletions lib/themes_on_rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down