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 +10 -1
- data/VERSION +1 -1
- data/app/models/domain_theme.rb +1 -1
- data/app/models/theme.rb +1 -1
- data/disguise.gemspec +5 -4
- data/lib/action_controller/disguise_application.rb +10 -3
- data/lib/disguise.rb +16 -5
- data/test/rails_root/config/environment.rb +1 -1
- data/test/rails_root/config/initializers/disguise.rb +2 -1
- data/test/rails_root/test/test_helper.rb +2 -2
- metadata +2 -2
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
|
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.
|
1
|
+
0.3.12
|
data/app/models/domain_theme.rb
CHANGED
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
|
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
|
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.
|
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{
|
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
|
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
|
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
|
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
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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 +1,2 @@
|
|
1
|
-
|
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
|
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
|
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.
|
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:
|
12
|
+
date: 2010-01-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|