disguise 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -48,7 +48,16 @@ Disguise can run in two modes. The first is the default which let's an administ
48
48
  via the built in admin interface. The second looks at the url of the incoming request and matches it to a theme.
49
49
  To enable this second mode create an initializer in /config/initializers/disguise.rb and enter the following contents:
50
50
 
51
- Disguise::USE_DOMAIN_FOR_THEMES = true
51
+ Disguise.use_domain_for_themes = false
52
+
53
+ # These options are also available to configure disguise. In most cases the defaults should work fine.
54
+ Disguise.themes_enabled = true
55
+ Disguise.theme_path = 'themes'
56
+ Disguise.theme_full_base_path = File.join(RAILS_ROOT, Disguise.theme_path)
57
+
58
+ == Notes
59
+ After installing Disguise be sure to generate a theme and set that theme as the default theme. Not setting a theme
60
+ will result in the application continually resetting the current theme which can cause performance problems.
52
61
 
53
62
  == Copyright
54
63
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.11
1
+ 0.3.12
@@ -4,7 +4,7 @@ class DomainTheme < ActiveRecord::Base
4
4
 
5
5
  class << self
6
6
  def use_domain_themes?
7
- Disguise::USE_DOMAIN_FOR_THEMES
7
+ Disguise.use_domain_for_themes
8
8
  end
9
9
 
10
10
  def get_theme(request)
data/app/models/theme.rb CHANGED
@@ -12,7 +12,7 @@ class Theme < ActiveRecord::Base
12
12
  # along with a preview image.
13
13
  def self.available_themes(selected_theme)
14
14
  themes = []
15
- theme_path = File.join(RAILS_ROOT, Disguise::THEME_PATH)
15
+ theme_path = File.join(RAILS_ROOT, Disguise.theme_path)
16
16
  current_theme = nil
17
17
 
18
18
  Dir.glob("#{theme_path}/*").each do |theme_directory|
data/disguise.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{disguise}
8
- s.version = "0.3.11"
8
+ s.version = "0.3.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball"]
12
- s.date = %q{2009-10-27}
12
+ s.date = %q{2010-01-20}
13
13
  s.description = %q{Add themes to your Rails application to easily change the view layer and impress everyone you know}
14
14
  s.email = %q{justinball@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -245,3 +245,4 @@ Gem::Specification.new do |s|
245
245
  else
246
246
  end
247
247
  end
248
+
@@ -23,11 +23,13 @@ module ActionController
23
23
  protected
24
24
 
25
25
  def setup_theme
26
+ return if !Disguise.themes_enabled
26
27
  return if current_theme.blank? || current_theme.name.blank?
27
- theme_view_path = File.join(Disguise::THEME_FULL_BASE_PATH, current_theme.name, 'views')
28
+ theme_view_path = File.join(Disguise.theme_full_base_path, current_theme.name, 'views')
28
29
  if self.view_paths.first == theme_view_path
29
30
  return
30
31
  else
32
+ return if !theme_exists(theme_view_path)
31
33
  clean_theme_view_path
32
34
  self.prepend_view_path(theme_view_path)
33
35
  clean_theme_locale
@@ -36,12 +38,17 @@ module ActionController
36
38
  end
37
39
  end
38
40
 
41
+ def theme_exists(theme_view_path)
42
+ @themes_exists ||= {}
43
+ @themes_exists[theme_view_path] ||= File.exists?(theme_view_path)
44
+ end
45
+
39
46
  def clean_theme_view_path
40
- self.view_paths.delete_if {|view_path| view_path.to_s.index(Disguise::THEME_PATH) == 0}
47
+ self.view_paths.delete_if {|view_path| view_path.to_s.index(Disguise.theme_path) == 0}
41
48
  end
42
49
 
43
50
  def clean_theme_locale
44
- I18n.load_path.delete_if {|localization_path| localization_path.index(Disguise::THEME_FULL_BASE_PATH) == 0}
51
+ I18n.load_path.delete_if {|localization_path| localization_path.index(Disguise.theme_full_base_path) == 0}
45
52
  end
46
53
 
47
54
  def set_theme_locale
data/lib/disguise.rb CHANGED
@@ -2,8 +2,19 @@ ActionController::Base.send :include, ActionController::DisguiseApplication
2
2
 
3
3
  I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locales', '*.{rb,yml}') ]
4
4
 
5
- module Disguise
6
- THEME_PATH = 'themes'
7
- THEME_FULL_BASE_PATH = File.join(RAILS_ROOT, THEME_PATH)
8
- USE_DOMAIN_FOR_THEMES = false
9
- end
5
+ class Disguise
6
+
7
+ class << self
8
+ attr_accessor :themes_enabled
9
+ attr_accessor :use_domain_for_themes
10
+ attr_accessor :theme_path
11
+ attr_accessor :theme_full_base_path
12
+ end
13
+
14
+ end
15
+
16
+ # Set defaults
17
+ Disguise.themes_enabled = true
18
+ Disguise.use_domain_for_themes = false
19
+ Disguise.theme_path = 'themes'
20
+ Disguise.theme_full_base_path = File.join(RAILS_ROOT, Disguise.theme_path)
@@ -1,4 +1,4 @@
1
- RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
1
+ RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
2
2
 
3
3
  require File.join(File.dirname(__FILE__), 'boot')
4
4
 
@@ -1 +1,2 @@
1
- USE_DOMAIN_FOR_THEMES = false
1
+ Disguise.themes_enabled = true
2
+ Disguise.use_domain_for_themes = false
@@ -25,11 +25,11 @@ class ActiveSupport::TestCase
25
25
  end
26
26
 
27
27
  def clean_theme_view_path(controller)
28
- controller.view_paths.delete_if {|view_path| view_path.to_s.index(Disguise::THEME_PATH) == 0}
28
+ controller.view_paths.delete_if {|view_path| view_path.to_s.index(Disguise.theme_path) == 0}
29
29
  end
30
30
 
31
31
  def clean_theme_locale
32
- I18n.load_path.delete_if {|localization_path| localization_path.index(Disguise::THEME_FULL_BASE_PATH) == 0}
32
+ I18n.load_path.delete_if {|localization_path| localization_path.index(Disguise.theme_full_base_path) == 0}
33
33
  end
34
34
 
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disguise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Ball
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-27 00:00:00 -06:00
12
+ date: 2010-01-20 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15