h2ocube_rails_assets 0.7.1 → 0.7.2
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.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/h2ocube_rails_assets.gemspec +1 -1
- data/lib/h2ocube_rails_assets.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 422b287eb84bc5648f83b72424c1996c3bc44673
|
4
|
+
data.tar.gz: 845ee5c621b4738d9e4f06862b16123e34659ab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cacfb1a178942789e7a66a368278beb9a551903cd27bc2da8edfbf790f0d71e45581813c3044bf97473cd0ec0cc161dd750d4c7627751b756363c6f8b983d08
|
7
|
+
data.tar.gz: 3120efa1cd154b9ee2eb159a89da4cfe5e8acca97ae87a808f253d99e41cbdda6c414df2428b579e63688bb71678528837c57311b89e89e5883a38d3eb712cbe
|
data/README.md
CHANGED
@@ -33,7 +33,15 @@ Or install it yourself as:
|
|
33
33
|
|
34
34
|
## Include helper
|
35
35
|
|
36
|
-
|
36
|
+
### assets_source(type)
|
37
|
+
|
38
|
+
type is `:css` or `:js`
|
39
|
+
|
40
|
+
Example:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
assets_source :css # when subdomain is 'www', controller is 'pages', action is 'home', it will try to find 'assets/stylesheets/domains/www/pages.sass' and 'assets/stylesheets/domains/www/pages/home.sass', if file exists, will use `stylesheet_link_tag` to include them.
|
44
|
+
```
|
37
45
|
|
38
46
|
## Other Useful Gems
|
39
47
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = 'h2ocube_rails_assets'
|
7
|
-
gem.version = '0.7.
|
7
|
+
gem.version = '0.7.2'
|
8
8
|
gem.authors = ['Ben']
|
9
9
|
gem.email = ['ben@h2ocube.com']
|
10
10
|
gem.description = 'Just an assets collection'
|
data/lib/h2ocube_rails_assets.rb
CHANGED
@@ -5,16 +5,17 @@ if defined?(Rails)
|
|
5
5
|
module ActionView
|
6
6
|
module Helpers
|
7
7
|
def assets_source(type)
|
8
|
+
domain = request.subdomain.split('.')[0]
|
8
9
|
case type
|
9
10
|
when :css
|
10
11
|
list = []
|
11
|
-
list.push "
|
12
|
-
list.push "
|
12
|
+
list.push "domains/#{domain}/#{params[:controller]}" if File.exist?(Rails.root.join("app/assets/stylesheets/domains/#{domain}/#{params[:controller]}.sass"))
|
13
|
+
list.push "domains/#{domain}/#{params[:controller]}/#{params[:action]}" if File.exist?(Rails.root.join("app/assets/stylesheets/domains/#{domain}/#{params[:controller]}/#{params[:action]}.sass"))
|
13
14
|
list.empty? ? nil : stylesheet_link_tag(*list)
|
14
15
|
when :js
|
15
16
|
list = []
|
16
|
-
list.push "
|
17
|
-
list.push "
|
17
|
+
list.push "domains/#{domain}/#{params[:controller]}" if File.exist?(Rails.root.join("app/assets/javascripts/domains/#{domain}/#{params[:controller]}.js"))
|
18
|
+
list.push "domains/#{domain}/#{params[:controller]}/#{params[:action]}" if File.exist?(Rails.root.join("app/assets/javascripts/domains/#{domain}/#{params[:controller]}/#{params[:action]}.js"))
|
18
19
|
list.empty? ? nil : javascript_include_tag(*list)
|
19
20
|
end
|
20
21
|
end
|
@@ -22,9 +23,10 @@ if defined?(Rails)
|
|
22
23
|
end
|
23
24
|
|
24
25
|
class Railtie < Rails::Railtie
|
25
|
-
PATH = File.dirname(__FILE__)
|
26
26
|
initializer 'h2ocube_rails_assets.require_dependency' do |app|
|
27
|
-
app.config.assets.
|
27
|
+
app.config.assets.precompile += Dir[Rails.root.join('app/assets/stylesheets/domains/*/*.sass')] + Dir[Rails.root.join('app/assets/stylesheets/domains/*/*/*.sass')]
|
28
|
+
app.config.assets.precompile += Dir[Rails.root.join('app/assets/javascripts/domains/*/*.js')] + Dir[Rails.root.join('app/assets/javascripts/domains/*/*/*.js')]
|
29
|
+
|
28
30
|
ActiveSupport.on_load :action_view do
|
29
31
|
include H2ocubeRailsAssets::ActionView::Helpers
|
30
32
|
end
|