Sha256: 274dbc8057ee4ebec6046298833f9fc5070c96234892cdcef7778ed5fac42a7b

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

# Before the application gets setup this will fail badly if there's no database.
if RefinerySetting.table_exists?
  # Set up middleware to serve theme files
  config.middleware.use "ThemeServer"

  # Add or remove theme paths to/from Refinery application
  ::Refinery::ApplicationController.module_eval do
    before_filter do |controller|
      controller.view_paths.reject! { |v| v.to_s =~ %r{^themes/} }
      if (theme = RefinerySetting[:theme]).present?
        # Set up view path again for the current theme.
        controller.view_paths.unshift Rails.root.join("themes", theme, "views").to_s

        RefinerySetting[:refinery_menu_cache_action_suffix] = "#{theme}_site_menu"
      else
        # Set the cache key for the site menu (thus expiring the fragment cache if theme changes).
        RefinerySetting[:refinery_menu_cache_action_suffix] = "site_menu"
      end
    end
  end

  if (theme = RefinerySetting[:theme]).present?
    # Set up controller paths, which can only be brought in with a server restart, sorry. (But for good reason)
    controller_path = Rails.root.join("themes", theme, "controllers").to_s

    ::ActiveSupport::Dependencies.load_paths.unshift controller_path
    config.controller_paths.unshift controller_path
  end

  # Include theme functions into application helper.
  Refinery::ApplicationHelper.send :include, ThemesHelper
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refinerycms-0.9.6.19 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.18 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.17 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.16 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.15 vendor/plugins/themes/rails/init.rb