Sha256: 06ba93055c097ff7373753ec413bf97133fa9777f92ad4215f36772a40306d6f

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 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
  prepend_before_filter :attach_theme_to_refinery

  def attach_theme_to_refinery
    # remove any paths relating to any theme.
    view_paths.reject! { |v| v.to_s =~ %r{^themes/} }

    # add back theme paths if there is a theme present.
    if (theme = Theme.current_theme(request.env)).present?
      # Set up view path again for the current theme.
      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.
      view_paths.select{|p| p.to_s =~ /^app\/views/}.each do |app_path|
        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
  protected :attach_theme_to_refinery

end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
refinerycms-0.9.6.34 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.33 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.32 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.31 vendor/plugins/themes/rails/init.rb
refinerycms-0.9.6.30 vendor/plugins/themes/rails/init.rb