active_theme 0.5.0.pre
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +91 -0
- data/LICENSE +21 -0
- data/README.textile +3 -0
- data/Rakefile +11 -0
- data/active_theme.gemspec +25 -0
- data/doc/README.textile +332 -0
- data/doc/REVIEW_NOTES +0 -0
- data/doc/TODO.textile +3 -0
- data/lib/active_theme.rb +58 -0
- data/lib/active_theme/action_controller.rb +32 -0
- data/lib/active_theme/action_mailer.rb +22 -0
- data/lib/active_theme/action_view.rb +59 -0
- data/lib/active_theme/assets_controller.rb +66 -0
- data/lib/active_theme/common_methods.rb +66 -0
- data/lib/active_theme/config.rb +74 -0
- data/lib/active_theme/interpolation.rb +11 -0
- data/lib/active_theme/railtie.rb +32 -0
- data/lib/active_theme/routes.rb +27 -0
- data/lib/active_theme/url_helpers.rb +27 -0
- data/lib/active_theme/version.rb +4 -0
- data/lib/generators/active_theme/create_generator.rb +14 -0
- data/lib/generators/active_theme/install_generator.rb +16 -0
- data/lib/generators/active_theme/templates/theme/images/.gitkeep +0 -0
- data/lib/generators/active_theme/templates/theme/javascripts/.gitkeep +0 -0
- data/lib/generators/active_theme/templates/theme/stylesheets/.gitkeep +0 -0
- data/lib/generators/active_theme/templates/theme/views/layouts/.gitkeep +0 -0
- data/lib/tasks/active_theme.rake +22 -0
- data/test/dummy_app/.gitignore +4 -0
- data/test/dummy_app/Gemfile +30 -0
- data/test/dummy_app/Rakefile +7 -0
- data/test/dummy_app/another_themes/another_default/images/logo.png +0 -0
- data/test/dummy_app/another_themes/another_default/images/nested/logo.png +0 -0
- data/test/dummy_app/another_themes/another_default/javascripts/app.js +1 -0
- data/test/dummy_app/another_themes/another_default/stylesheets/style.css +0 -0
- data/test/dummy_app/another_themes/another_default/stylesheets/style2.css +3 -0
- data/test/dummy_app/another_themes/another_default/views/layouts/default.html.erb +10 -0
- data/test/dummy_app/another_themes/another_default/views/products/index.html.erb +0 -0
- data/test/dummy_app/app/controllers/application_controller.rb +3 -0
- data/test/dummy_app/app/helpers/application_helper.rb +2 -0
- data/test/dummy_app/app/views/layouts/application.html.erb +14 -0
- data/test/dummy_app/config.ru +4 -0
- data/test/dummy_app/config/application.rb +42 -0
- data/test/dummy_app/config/boot.rb +13 -0
- data/test/dummy_app/config/database.yml +18 -0
- data/test/dummy_app/config/environment.rb +5 -0
- data/test/dummy_app/config/environments/development.rb +26 -0
- data/test/dummy_app/config/environments/production.rb +49 -0
- data/test/dummy_app/config/environments/test.rb +35 -0
- data/test/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy_app/config/initializers/inflections.rb +10 -0
- data/test/dummy_app/config/initializers/mime_types.rb +5 -0
- data/test/dummy_app/config/initializers/secret_token.rb +7 -0
- data/test/dummy_app/config/initializers/session_store.rb +8 -0
- data/test/dummy_app/config/locales/en.yml +5 -0
- data/test/dummy_app/config/routes.rb +4 -0
- data/test/dummy_app/db/seeds.rb +7 -0
- data/test/dummy_app/empty_themes/.gitkeep +0 -0
- data/test/dummy_app/lib/tasks/.gitkeep +0 -0
- data/test/dummy_app/public/404.html +26 -0
- data/test/dummy_app/public/422.html +26 -0
- data/test/dummy_app/public/500.html +26 -0
- data/test/dummy_app/public/favicon.ico +0 -0
- data/test/dummy_app/public/images/rails.png +0 -0
- data/test/dummy_app/public/index.html +239 -0
- data/test/dummy_app/public/javascripts/application.js +2 -0
- data/test/dummy_app/public/javascripts/controls.js +965 -0
- data/test/dummy_app/public/javascripts/dragdrop.js +974 -0
- data/test/dummy_app/public/javascripts/effects.js +1123 -0
- data/test/dummy_app/public/javascripts/prototype.js +6001 -0
- data/test/dummy_app/public/javascripts/rails.js +175 -0
- data/test/dummy_app/public/robots.txt +5 -0
- data/test/dummy_app/public/stylesheets/.gitkeep +0 -0
- data/test/dummy_app/script/rails +6 -0
- data/test/dummy_app/themes/default/images/logo.png +0 -0
- data/test/dummy_app/themes/default/images/nested/logo.png +0 -0
- data/test/dummy_app/themes/default/javascripts/app.js +1 -0
- data/test/dummy_app/themes/default/javascripts/app.min.js +0 -0
- data/test/dummy_app/themes/default/stylesheets/images/logo.png +0 -0
- data/test/dummy_app/themes/default/stylesheets/style.css +0 -0
- data/test/dummy_app/themes/default/stylesheets/style2.css +3 -0
- data/test/dummy_app/themes/default/views/layouts/default.html.erb +10 -0
- data/test/dummy_app/themes/default/views/products/index.html.erb +0 -0
- data/test/lib/action_controller_test.rb +170 -0
- data/test/lib/action_mailer_test.rb +35 -0
- data/test/lib/action_view_test.rb +54 -0
- data/test/lib/assets_controller_test.rb +73 -0
- data/test/lib/common_methods_test.rb +28 -0
- data/test/lib/config_test.rb +26 -0
- data/test/lib/integration_test.rb +12 -0
- data/test/lib/routes_test.rb +40 -0
- data/test/lib/themes_for_rails_test.rb +18 -0
- data/test/support/extensions.rb +19 -0
- data/test/test_helper.rb +12 -0
- metadata +276 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rvm use 1.9.3@themes_for_rails --create
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
active_theme (0.5.0.pre)
|
|
5
|
+
rails (>= 3.0.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
abstract (1.0.0)
|
|
11
|
+
actionmailer (3.0.11)
|
|
12
|
+
actionpack (= 3.0.11)
|
|
13
|
+
mail (~> 2.2.19)
|
|
14
|
+
actionpack (3.0.11)
|
|
15
|
+
activemodel (= 3.0.11)
|
|
16
|
+
activesupport (= 3.0.11)
|
|
17
|
+
builder (~> 2.1.2)
|
|
18
|
+
erubis (~> 2.6.6)
|
|
19
|
+
i18n (~> 0.5.0)
|
|
20
|
+
rack (~> 1.2.1)
|
|
21
|
+
rack-mount (~> 0.6.14)
|
|
22
|
+
rack-test (~> 0.5.7)
|
|
23
|
+
tzinfo (~> 0.3.23)
|
|
24
|
+
activemodel (3.0.11)
|
|
25
|
+
activesupport (= 3.0.11)
|
|
26
|
+
builder (~> 2.1.2)
|
|
27
|
+
i18n (~> 0.5.0)
|
|
28
|
+
activerecord (3.0.11)
|
|
29
|
+
activemodel (= 3.0.11)
|
|
30
|
+
activesupport (= 3.0.11)
|
|
31
|
+
arel (~> 2.0.10)
|
|
32
|
+
tzinfo (~> 0.3.23)
|
|
33
|
+
activeresource (3.0.11)
|
|
34
|
+
activemodel (= 3.0.11)
|
|
35
|
+
activesupport (= 3.0.11)
|
|
36
|
+
activesupport (3.0.11)
|
|
37
|
+
arel (2.0.10)
|
|
38
|
+
builder (2.1.2)
|
|
39
|
+
contest (0.1.2)
|
|
40
|
+
erubis (2.6.6)
|
|
41
|
+
abstract (>= 1.0.0)
|
|
42
|
+
i18n (0.5.0)
|
|
43
|
+
json (1.6.5)
|
|
44
|
+
mail (2.2.19)
|
|
45
|
+
activesupport (>= 2.3.6)
|
|
46
|
+
i18n (>= 0.4.0)
|
|
47
|
+
mime-types (~> 1.16)
|
|
48
|
+
treetop (~> 1.4.8)
|
|
49
|
+
mime-types (1.17.2)
|
|
50
|
+
mocha (0.9.12)
|
|
51
|
+
polyglot (0.3.3)
|
|
52
|
+
rack (1.2.5)
|
|
53
|
+
rack-mount (0.6.14)
|
|
54
|
+
rack (>= 1.0.0)
|
|
55
|
+
rack-test (0.5.7)
|
|
56
|
+
rack (>= 1.0)
|
|
57
|
+
rails (3.0.11)
|
|
58
|
+
actionmailer (= 3.0.11)
|
|
59
|
+
actionpack (= 3.0.11)
|
|
60
|
+
activerecord (= 3.0.11)
|
|
61
|
+
activeresource (= 3.0.11)
|
|
62
|
+
activesupport (= 3.0.11)
|
|
63
|
+
bundler (~> 1.0)
|
|
64
|
+
railties (= 3.0.11)
|
|
65
|
+
railties (3.0.11)
|
|
66
|
+
actionpack (= 3.0.11)
|
|
67
|
+
activesupport (= 3.0.11)
|
|
68
|
+
rake (>= 0.8.7)
|
|
69
|
+
rdoc (~> 3.4)
|
|
70
|
+
thor (~> 0.14.4)
|
|
71
|
+
rake (0.9.2.2)
|
|
72
|
+
rdoc (3.12)
|
|
73
|
+
json (~> 1.4)
|
|
74
|
+
sqlite3 (1.3.5)
|
|
75
|
+
test-unit (2.2.0)
|
|
76
|
+
thor (0.14.6)
|
|
77
|
+
treetop (1.4.10)
|
|
78
|
+
polyglot
|
|
79
|
+
polyglot (>= 0.3.1)
|
|
80
|
+
tzinfo (0.3.31)
|
|
81
|
+
|
|
82
|
+
PLATFORMS
|
|
83
|
+
ruby
|
|
84
|
+
|
|
85
|
+
DEPENDENCIES
|
|
86
|
+
active_theme!
|
|
87
|
+
contest
|
|
88
|
+
mocha
|
|
89
|
+
rails (= 3.0.11)
|
|
90
|
+
sqlite3
|
|
91
|
+
test-unit
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Lucas Florio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.textile
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
# -*- encoding: utf-8 -*-
|
|
3
|
+
require File.expand_path('../lib/active_theme/version', __FILE__)
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |gem|
|
|
6
|
+
gem.authors = ["Devin Zhang"]
|
|
7
|
+
gem.email = ["daqing1986@gmail.com"]
|
|
8
|
+
gem.summary = "Theme Support for Rails 3"
|
|
9
|
+
gem.description = %q{It allows an application to have many different ways of rendering static assets and dynamic views.}
|
|
10
|
+
gem.homepage = "https://github.com/daqing/active_theme"
|
|
11
|
+
|
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
15
|
+
gem.name = "active_theme"
|
|
16
|
+
gem.require_paths = ["lib"]
|
|
17
|
+
gem.version = ActiveTheme::VERSION
|
|
18
|
+
|
|
19
|
+
gem.add_dependency('rails', [">= 3.0.0"])
|
|
20
|
+
gem.add_development_dependency "sqlite3"
|
|
21
|
+
gem.add_development_dependency "test-unit"
|
|
22
|
+
gem.add_development_dependency "contest"
|
|
23
|
+
gem.add_development_dependency "mocha"
|
|
24
|
+
gem.add_development_dependency('rails', ["= 3.0.11"])
|
|
25
|
+
end
|
data/doc/README.textile
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
h1. ActiveTheme (Theme Support For Rails 3)
|
|
2
|
+
|
|
3
|
+
h2. Instructions
|
|
4
|
+
|
|
5
|
+
Add active_theme to your Gemfile.
|
|
6
|
+
|
|
7
|
+
<pre>
|
|
8
|
+
gem 'active_theme'
|
|
9
|
+
</pre>
|
|
10
|
+
|
|
11
|
+
Add active_theme to your config/routes.rb
|
|
12
|
+
|
|
13
|
+
<pre>
|
|
14
|
+
MySuperDuperApp::Application.routes.draw do
|
|
15
|
+
# ...
|
|
16
|
+
active_theme
|
|
17
|
+
# ...
|
|
18
|
+
end
|
|
19
|
+
</pre>
|
|
20
|
+
|
|
21
|
+
h3. Additional Instructions for using the Rails Asset Pipeline
|
|
22
|
+
|
|
23
|
+
In order to use active_theme with the asset pipeline, you will need to configure a few settings and place your themes in the asset pipeline directory.
|
|
24
|
+
|
|
25
|
+
First, move your assets into the asset pipeline. For example:
|
|
26
|
+
|
|
27
|
+
<pre>
|
|
28
|
+
$app_root
|
|
29
|
+
app/
|
|
30
|
+
assets/
|
|
31
|
+
images/ <-- default asset pipeline folder
|
|
32
|
+
javascripts/ <-- default asset pipeline folder
|
|
33
|
+
stylesheets/ <-- default asset pipeline folder
|
|
34
|
+
themes/ <-- your themes root
|
|
35
|
+
[theme_name]
|
|
36
|
+
images/
|
|
37
|
+
stylesheets/
|
|
38
|
+
javascripts/
|
|
39
|
+
views/ <- you can override application views
|
|
40
|
+
layouts/ <- layout .rhtml or .liquid templates
|
|
41
|
+
</pre>
|
|
42
|
+
|
|
43
|
+
Create an initializer for themes in your {Rails.root}/config/initializers directory and set the themes_dir and assets_dir settings appropriately.
|
|
44
|
+
|
|
45
|
+
<pre>
|
|
46
|
+
# Rails.root/config/initializers/active_theme.rb (for instance)
|
|
47
|
+
ActiveTheme.config do |config|
|
|
48
|
+
#
|
|
49
|
+
# If you have placed your themes like the example path above within the asset pipeline:
|
|
50
|
+
config.themes_dir = 'assets'
|
|
51
|
+
config.assets_dir = 'app/assets/themes'
|
|
52
|
+
# ...
|
|
53
|
+
end
|
|
54
|
+
</pre>
|
|
55
|
+
|
|
56
|
+
In your theme stylesheets directory, you can create an application.css file using the Sprockets require methods:
|
|
57
|
+
|
|
58
|
+
<pre>
|
|
59
|
+
/*
|
|
60
|
+
*= require global_stylesheet_name
|
|
61
|
+
*= require theme_name/stylesheets/stylesheet_name
|
|
62
|
+
*/
|
|
63
|
+
</pre>
|
|
64
|
+
|
|
65
|
+
As you can see, if you do not preface with the theme_name/stylesheets it will reference the root /app/assets/stylesheets path for global stylesheets (great for mixins and reset styles)
|
|
66
|
+
|
|
67
|
+
Currently, one unresolved issue with this setup is that you must pass the theme_name/images path into your sass image-url helper methods. For example, if you are including an image in the 'default' theme: <pre>image-url('default/images/background.png')</pre>
|
|
68
|
+
|
|
69
|
+
If you do not want to have your views inside the asset pipeline dir, you can alternatively configure your application like this:
|
|
70
|
+
|
|
71
|
+
<pre>
|
|
72
|
+
$app_root
|
|
73
|
+
app/
|
|
74
|
+
assets/
|
|
75
|
+
images/ <-- default asset pipeline folder
|
|
76
|
+
javascripts/ <-- default asset pipeline folder
|
|
77
|
+
stylesheets/ <-- default asset pipeline folder
|
|
78
|
+
themes/ <-- your themes root
|
|
79
|
+
[theme_name]
|
|
80
|
+
images/
|
|
81
|
+
stylesheets/
|
|
82
|
+
javascripts/
|
|
83
|
+
views/
|
|
84
|
+
themes/ <-- note themes folder lives under views in this scenario
|
|
85
|
+
[theme_name]
|
|
86
|
+
layouts/ <- layout .rhtml or .liquid templates
|
|
87
|
+
</pre>
|
|
88
|
+
|
|
89
|
+
and in your initializer, you will need to set the views_dir config setting like so:
|
|
90
|
+
|
|
91
|
+
<pre>
|
|
92
|
+
# Rails.root/config/initializers/active_theme.rb (for instance)
|
|
93
|
+
ActiveTheme.config do |config|
|
|
94
|
+
#
|
|
95
|
+
# If you have placed your themes like the example path above within the asset pipeline:
|
|
96
|
+
config.themes_dir = 'assets'
|
|
97
|
+
config.assets_dir = 'app/assets/themes'
|
|
98
|
+
config.views_dir = 'app/views/themes'
|
|
99
|
+
# ...
|
|
100
|
+
end
|
|
101
|
+
</pre>
|
|
102
|
+
|
|
103
|
+
After that, the rest of the config for asset pipeline styles and whatnot mentioned above will work.
|
|
104
|
+
|
|
105
|
+
h3. And then?
|
|
106
|
+
|
|
107
|
+
Now you'll be able to use themes like this:
|
|
108
|
+
|
|
109
|
+
Inside method, for some explicit action:
|
|
110
|
+
|
|
111
|
+
<pre>
|
|
112
|
+
class MyController < ApplicationController
|
|
113
|
+
def show
|
|
114
|
+
theme "purple"
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
</pre>
|
|
118
|
+
|
|
119
|
+
Or at class level definition, in order to set a theme for more than one action. I think this is is prettier, and less invasive.
|
|
120
|
+
|
|
121
|
+
<pre>
|
|
122
|
+
class MyController < ApplicationController
|
|
123
|
+
theme "purple" # all actions will use this theme
|
|
124
|
+
def show
|
|
125
|
+
...
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
</pre>
|
|
129
|
+
|
|
130
|
+
You could also enable a theme for some actions only
|
|
131
|
+
|
|
132
|
+
<pre>
|
|
133
|
+
class MyController < ApplicationController
|
|
134
|
+
theme "purple", :only => :show
|
|
135
|
+
def show
|
|
136
|
+
# with theme
|
|
137
|
+
end
|
|
138
|
+
def edit
|
|
139
|
+
# no theme
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
</pre>
|
|
143
|
+
|
|
144
|
+
As a plus, you could do this to defer theme name resolution to a method:
|
|
145
|
+
|
|
146
|
+
<pre>
|
|
147
|
+
class MyController < ApplicationController
|
|
148
|
+
theme :theme_resolver
|
|
149
|
+
# ...
|
|
150
|
+
private
|
|
151
|
+
def theme_resolver
|
|
152
|
+
current_user.theme # or anything else that return a string.
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
</pre>
|
|
156
|
+
|
|
157
|
+
As a general rule, when passing a String, that becomes the theme name, but when a Symbol is sent, it gets treated as method message.
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
h3. Action Mailer integration:
|
|
161
|
+
|
|
162
|
+
As a plus, you can use it from Action Mailer too (thanks to rafaelss) like this:
|
|
163
|
+
|
|
164
|
+
<pre>
|
|
165
|
+
class MyMailer < ActionMailer::Base
|
|
166
|
+
|
|
167
|
+
def notify_someone
|
|
168
|
+
mail :theme => "blue" , :to => "some@one.com"
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
end
|
|
172
|
+
</pre>
|
|
173
|
+
|
|
174
|
+
Or set the theme by default like this (thanks to maxjgon):
|
|
175
|
+
|
|
176
|
+
<pre>
|
|
177
|
+
class MyMailer < ActionMailer::Base
|
|
178
|
+
|
|
179
|
+
default :theme => "blue"
|
|
180
|
+
|
|
181
|
+
def notify_someone
|
|
182
|
+
mail :to => "some@one.com"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
end
|
|
186
|
+
</pre>
|
|
187
|
+
|
|
188
|
+
h3. Url Helpers
|
|
189
|
+
|
|
190
|
+
In your views you should be able to access your assets like this (given the theme 'default' is set):
|
|
191
|
+
|
|
192
|
+
<pre>
|
|
193
|
+
current_theme_image_path('logo.png') # => /themes/default/images/logo.png
|
|
194
|
+
current_theme_stylesheet_path('style') # => /themes/default/stylesheets/logo.css
|
|
195
|
+
current_theme_javascript_path('app') # => /themes/default/stylesheets/app.js
|
|
196
|
+
</pre>
|
|
197
|
+
|
|
198
|
+
Or a given theme:
|
|
199
|
+
|
|
200
|
+
<pre>
|
|
201
|
+
current_theme_image_path('logo.png', 'purple') # => /themes/purple/images/logo.png
|
|
202
|
+
</pre>
|
|
203
|
+
|
|
204
|
+
In your application views, there are theme specific helper tags
|
|
205
|
+
available to you. For ERb templates they are:
|
|
206
|
+
|
|
207
|
+
<pre>
|
|
208
|
+
theme_image_tag
|
|
209
|
+
theme_image_path
|
|
210
|
+
theme_javascript_include_tag
|
|
211
|
+
theme_javascript_path
|
|
212
|
+
theme_stylesheet_link_tag
|
|
213
|
+
theme_stylesheet_path
|
|
214
|
+
</pre>
|
|
215
|
+
|
|
216
|
+
h2. Generators
|
|
217
|
+
|
|
218
|
+
For now, it only creates the theme folder and add the "active_theme" route in the routes.rb.
|
|
219
|
+
|
|
220
|
+
<pre>
|
|
221
|
+
rails generate active_theme:install
|
|
222
|
+
</pre>
|
|
223
|
+
|
|
224
|
+
Inside the themes folder, it create a structure for my_theme.
|
|
225
|
+
|
|
226
|
+
<pre>
|
|
227
|
+
rails generate active_theme:create my_theme
|
|
228
|
+
</pre>
|
|
229
|
+
|
|
230
|
+
h2. Changing things
|
|
231
|
+
|
|
232
|
+
At least for now, you can change the ActiveTheme base dir in your app, in the corresponding environment file, or in your application.rb file. Do it like this:
|
|
233
|
+
|
|
234
|
+
<pre>
|
|
235
|
+
KillerApp::Application.configure do
|
|
236
|
+
#
|
|
237
|
+
|
|
238
|
+
config.active_theme.base_dir = File.join(Rails.root, "tmp")
|
|
239
|
+
|
|
240
|
+
#...
|
|
241
|
+
end
|
|
242
|
+
</pre>
|
|
243
|
+
|
|
244
|
+
Thanks to matheusca, now you can change the name of the theme's dir.
|
|
245
|
+
|
|
246
|
+
<pre>
|
|
247
|
+
KillerApp::Application.configure do
|
|
248
|
+
#
|
|
249
|
+
|
|
250
|
+
config.active_theme.themes_dir = "another_themes"
|
|
251
|
+
|
|
252
|
+
#...
|
|
253
|
+
end
|
|
254
|
+
</pre>
|
|
255
|
+
|
|
256
|
+
h2. Sass support
|
|
257
|
+
|
|
258
|
+
ActiveTheme will automatically add the themes paths to Sass, if sass is available.
|
|
259
|
+
|
|
260
|
+
For instance, everything you put inside themes/my_theme/stylesheets/sass will get compiled into themes/my_theme/stylesheets (duh, right?)
|
|
261
|
+
|
|
262
|
+
To bypass sass configuration, do this:
|
|
263
|
+
<pre>
|
|
264
|
+
KillerApp::Application.configure do
|
|
265
|
+
#
|
|
266
|
+
|
|
267
|
+
config.active_theme.use_sass = false
|
|
268
|
+
|
|
269
|
+
#...
|
|
270
|
+
end
|
|
271
|
+
</pre>
|
|
272
|
+
|
|
273
|
+
h2. Another way to change things
|
|
274
|
+
|
|
275
|
+
If you don't like this approach and prefer something more like an initializer file, you could create one an put something like this.
|
|
276
|
+
|
|
277
|
+
<pre>
|
|
278
|
+
# Rails.root/config/initializers/active_theme.rb (for instance)
|
|
279
|
+
ActiveTheme.config do |config|
|
|
280
|
+
#
|
|
281
|
+
config.themes_dir = 'another_themes'
|
|
282
|
+
# ...
|
|
283
|
+
end
|
|
284
|
+
</pre>
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
h2. Notes and Warnings.
|
|
289
|
+
|
|
290
|
+
If you are running an app in production mode, and you get the static files with no content, is because you don't have X-senfile enabled at your web server.
|
|
291
|
+
|
|
292
|
+
You can do two things:
|
|
293
|
+
|
|
294
|
+
comment out this line in your production.rb file:
|
|
295
|
+
|
|
296
|
+
config.action_dispatch.x_sendfile_header = "X-Sendfile"
|
|
297
|
+
|
|
298
|
+
or
|
|
299
|
+
|
|
300
|
+
configure your web server to use it. :)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
h2. Ideas
|
|
304
|
+
|
|
305
|
+
* Add ActiveTheme::Railtie for configuration, so we selectively set the plugin on or off. Also to be able to change several settings.
|
|
306
|
+
* -Add routes to allow access to the theme's static resources (js and cs), unless cached on public folder by capistrano / rake.-
|
|
307
|
+
* -Extend Action View path in order to make the views accessible. Same for the layouts.-
|
|
308
|
+
* More tests ford edge cases. Now I am only testing the happy paths.
|
|
309
|
+
|
|
310
|
+
h2. Things to remember.
|
|
311
|
+
|
|
312
|
+
* -Final version should be a gem. Initialization hooks doesn't work when using this as a plugin (vendor/plugins).-
|
|
313
|
+
* -Research about testing this kind of gem. I really don't have a clue.- Testing in place!
|
|
314
|
+
* I should probably load the theme list at start time, to be able to consult it as needed. I am gonna need that when dealing with runtime theme selection. Many themes are going to be used simultaneously, so I have to be able to switch view paths as fast as I can.
|
|
315
|
+
|
|
316
|
+
h2. Running tests
|
|
317
|
+
|
|
318
|
+
<pre>
|
|
319
|
+
gem install bundler
|
|
320
|
+
bundle install
|
|
321
|
+
rake
|
|
322
|
+
</pre>
|
|
323
|
+
|
|
324
|
+
h2. Authors and contributors
|
|
325
|
+
|
|
326
|
+
* lucasefe
|
|
327
|
+
* jbarreneche
|
|
328
|
+
* kule
|
|
329
|
+
* matheusmoreira
|
|
330
|
+
* rafaelss
|
|
331
|
+
* maxjgon
|
|
332
|
+
|