class Refinery::ThemingEngine

Public Instance Methods

attach_theme_to_refinery() click to toggle source
# File lib/refinerycms-theming.rb, line 16
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 ::Theme.current_theme_dir.join("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 =~ %r{^#{Rails.root.join('app', 'views')}}}.each do |app_path|
      view_paths.unshift app_path
    end
  end

  # Set up menu caching for this theme or lack thereof
  if RefinerySetting.table_exists? and
     RefinerySetting.get(:refinery_menu_cache_action_suffix) != (suffix = "#{"#{theme}_" if theme.present?}site_menu")
    RefinerySetting.set(:refinery_menu_cache_action_suffix, suffix)
  end
end
image_submit_tag(source, options = {}) click to toggle source
Calls superclass method
# File lib/refinerycms-theming.rb, line 69
def image_submit_tag(source, options = {})
  theme = (options.delete(:theme) == true)

  tag = super
  # inject /theme/ into the image tag src if this is themed.
  tag.gsub!(/src=[\"|\']/) { |m| "#{m}/theme/" }.gsub!("//", "/") if theme
  tag.gsub(/theme=(.+?)\ /, '') # we need to remove any addition of theme='false' etc.
end
image_tag(source, options={}) click to toggle source
Calls superclass method
# File lib/refinerycms-theming.rb, line 45
def image_tag(source, options={})
  theme = (options.delete(:theme) == true)
  tag = super
  # inject /theme/ into the image tag src if this is themed.
  tag.gsub!(/src=[\"|\']/) { |m| "#{m}/theme/" }.gsub!("//", "/") if theme
  tag.gsub(/theme=(.+?)\ /, '') # we need to remove any addition of theme='false' etc.
end
javascript_include_tag(*sources) click to toggle source
Calls superclass method
# File lib/refinerycms-theming.rb, line 53
def javascript_include_tag(*sources)
  theme = (arguments = sources.dup).extract_options![:theme] == true # don't ruin the current sources object
  tag = super
  # inject /theme/ into the javascript include tag src if this is themed.
  tag.gsub!(/\/javascripts\//, "/theme/javascripts/") if theme
  tag.gsub(/theme=(.+?)\ /, '') # we need to remove any addition of theme='false' etc.
end