Sha256: f8b0e9abf29b4215ab2327cc88efd6bee9f0ae4ac5cb50216df473340cbde59e

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# Set up middleware to serve theme files
config.middleware.use "ThemeServer"

::Refinery::ApplicationController.module_eval do

  # Add or remove theme paths to/from Refinery application
  before_filter do |controller|
    # remove any paths relating to any theme.
    controller.view_paths.reject! { |v| v.to_s =~ %r{^themes/} }

    # add back theme paths if there is a theme present.
    if (theme = Theme.current_theme(controller.request.env)).present?
      # Set up view path again for the current theme.
      controller.view_paths.unshift Rails.root.join("themes", theme, "views").to_s

      # Ensure that routes within the application are top priority.
      # Here we grab all the routes that are under the application's view folder
      # and promote them ahead of any other path.
      controller.view_paths.select{|p| p.to_s =~ /^app\/views/}.each do |app_path|
        controller.view_paths.unshift app_path
      end
    end

    # Set up menu caching for this theme or lack thereof
    RefinerySetting[:refinery_menu_cache_action_suffix] = "#{"#{theme}_" if theme.present?}site_menu" if RefinerySetting.table_exists?
  end

end

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
refinerycms-0.9.6.23 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.22 vendor/plugins/themes/rails/init.rb