nanoc-sprockets3 1.0.0.1 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/lib/nanoc/sprockets/helper.rb +10 -4
- data/lib/nanoc/sprockets/version.rb +1 -1
- 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: 79dd5c797aa087ef26a0d1e21bc59730d0b71aac
|
4
|
+
data.tar.gz: dd679452f9198964c6705fcabcda002f67cd6bba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78624dc8241fad6ba87478c00902e1cbd11f9982dc1ff8ce35a554032dba021de35411c2ea2e01a4c47c14c64a8dc9d013f4d2ee96e0349acccc0f9f6a9d27a7
|
7
|
+
data.tar.gz: e23d089b78c89803c2bc0bbb8827732dc01d69d899d4a498a8494d5d2f0aaaef081946608e4d48b2a523963d694f54661276ee7f43d4399bb31988ca59067578
|
data/README.md
CHANGED
@@ -29,9 +29,12 @@ Or install it yourself as:
|
|
29
29
|
## Configuration
|
30
30
|
|
31
31
|
[nanoc-sprockets3][nanoc-sprockets3] does not require any mandatory configuration, however you may want to configure it
|
32
|
-
for your needs.
|
33
|
-
|
34
|
-
|
32
|
+
for your needs.
|
33
|
+
|
34
|
+
Currently you can configure [nanoc-sprockets3][nanoc-sprockets3] with the following parameters:
|
35
|
+
- **prefix** *[default: '/asset']* which is the prefix to give to all assets
|
36
|
+
- **digest** *[default: false]* which when true will return digest paths instead of logical path
|
37
|
+
- **environment** which is the Sprockets environment to use
|
35
38
|
|
36
39
|
The default environment is configured with the following paths
|
37
40
|
- content/assets/
|
@@ -66,6 +69,7 @@ Nanoc::Sprockets::Helper.configure do |config|
|
|
66
69
|
env.append_path 'vendor/assets/jquery'
|
67
70
|
end
|
68
71
|
config.prefix = '/assets'
|
72
|
+
config.digest = true
|
69
73
|
end
|
70
74
|
```
|
71
75
|
|
@@ -139,4 +143,4 @@ for dependency tracking which makes it annoying to use with livereload and parti
|
|
139
143
|
[nanoc-sprockets-filter]: https://github.com/yannlugrin/nanoc-sprockets-filter "A nanoc filter to use Sprocket 2.x"
|
140
144
|
[nanoc-sprockets]: https://github.com/stormz/nanoc-sprockets "Use sprockets 2.x as a datasource for nanoc"
|
141
145
|
[nanoc-gzip-filter]: https://github.com/yannlugrin/nanoc-gzip-filter "A Nanoc filter to gzip content"
|
142
|
-
[uglifier]: https://github.com/lautis/uglifier "Ruby wrapper for UglifyJS JavaScript compressor"
|
146
|
+
[uglifier]: https://github.com/lautis/uglifier "Ruby wrapper for UglifyJS JavaScript compressor"
|
@@ -21,7 +21,7 @@ module Nanoc::Sprockets
|
|
21
21
|
# This defaults to the context's #environment method.
|
22
22
|
def environment
|
23
23
|
@environment ||= ::Sprockets::Environment.new(File.expand_path('.')) do |env|
|
24
|
-
paths =
|
24
|
+
paths = DEFAULT_ASSETS_PATHS + DEFAULT_ASSETS_PATHS.map{|p| DEFAULT_ASSETS_DIRS.map{|f| "#{p}#{f}"}}.flatten
|
25
25
|
paths.each{ |path| env.append_path path }
|
26
26
|
end
|
27
27
|
end
|
@@ -34,6 +34,8 @@ module Nanoc::Sprockets
|
|
34
34
|
end
|
35
35
|
attr_writer :prefix
|
36
36
|
|
37
|
+
# When true, the asset paths will return digest paths
|
38
|
+
attr_accessor :digest
|
37
39
|
end
|
38
40
|
|
39
41
|
# Convience method for configuring Nanoc::Sprockets::Helpers.
|
@@ -41,7 +43,7 @@ module Nanoc::Sprockets
|
|
41
43
|
yield self
|
42
44
|
end
|
43
45
|
|
44
|
-
# Returns the path to an item or a filename
|
46
|
+
# Returns the path to an item or a filename in the Sprockets environment.
|
45
47
|
def asset_path(item_or_filename, options = {})
|
46
48
|
if item_or_filename.is_a?(::Nanoc::Item)
|
47
49
|
filename = item_or_filename[:filename]
|
@@ -50,8 +52,12 @@ module Nanoc::Sprockets
|
|
50
52
|
end
|
51
53
|
filename = File.basename(filename).gsub(/^(\w+\.\w+).*/, '\1')
|
52
54
|
|
53
|
-
if asset = Helper.environment
|
54
|
-
|
55
|
+
if asset = Helper.environment.find_asset(filename)
|
56
|
+
if Helper.digest
|
57
|
+
File.join(Helper.prefix, asset.digest_path)
|
58
|
+
else
|
59
|
+
File.join(Helper.prefix, asset.logical_path)
|
60
|
+
end
|
55
61
|
else
|
56
62
|
raise "error locating #{filename}."
|
57
63
|
end
|