Module: ThemesForRails

Defined in:
lib/themes_for_rails/railtie.rb,
lib/themes_for_rails.rb,
lib/themes_for_rails/config.rb,
lib/themes_for_rails/routes.rb,
lib/themes_for_rails/version.rb,
lib/themes_for_rails/url_helpers.rb,
lib/themes_for_rails/view_helpers.rb,
lib/themes_for_rails/common_methods.rb,
lib/themes_for_rails/mailer_methods.rb,
lib/themes_for_rails/assets_controller.rb,
lib/themes_for_rails/controller_methods.rb,
lib/generators/themes_for_rails/theme_generator.rb,
lib/generators/themes_for_rails/install_generator.rb

Overview

ActiveSupport.on_load(:action_view) { include Devise::Controllers::UrlHelpers }

Defined Under Namespace

Modules: CommonMethods, ControllerMethods, Generators, MailerMethods, Routes, UrlHelpers, ViewHelpers Classes: AssetsController, Config, Railtie

Constant Summary collapse

VERSION =
"0.4.2"

Class Method Summary collapse

Class Method Details

.add_themes_path_to_sassObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/themes_for_rails.rb', line 19

def add_themes_path_to_sass
  if ThemesForRails.config.sass_is_available?
    each_theme_dir do |dir|
      if File.directory?(dir) # Need to get rid of the '.' and '..'

        sass_dir = "#{dir}/stylesheets/sass"
        css_dir = "#{dir}/stylesheets"

        unless already_configured_in_sass?(sass_dir)
          Sass::Plugin.add_template_location sass_dir, css_dir 
        end
      end
    end 
  else
    raise "Sass is not available. What are you trying to do?"
  end
end

.already_configured_in_sass?(sass_dir) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/themes_for_rails.rb', line 37

def already_configured_in_sass?(sass_dir)
  Sass::Plugin.template_location_array.map(&:first).include?(sass_dir)
end

.available_theme_namesObject



15
16
17
# File 'lib/themes_for_rails.rb', line 15

def available_theme_names
  available_themes.map {|theme| File.basename(theme) } 
end

.available_themes(&block) ⇒ Object Also known as: each_theme_dir



10
11
12
# File 'lib/themes_for_rails.rb', line 10

def available_themes(&block)
  Dir.glob(File.join(config.themes_path, "*"), &block) 
end

.config {|@config| ... } ⇒ Object

Yields:



4
5
6
7
8
# File 'lib/themes_for_rails.rb', line 4

def config
  @config ||= ThemesForRails::Config.new
  yield(@config) if block_given?
  @config
end