nanoc-sprockets 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b64436c4d2e8ee089640dd6725cce5947add84b
4
- data.tar.gz: c6b67620a1ff4e626949f573b10ba10f2096cf47
3
+ metadata.gz: d5fddcc2e8cd9e9914b917fcbdf22ae16a26acd6
4
+ data.tar.gz: 8fcdcd1039cc8531b35dd7a660f9edc192daa257
5
5
  SHA512:
6
- metadata.gz: 5db505ce5a9f404fa801dde354696d976523715b87d83ca0547a8f1032135adba52312db4efe3c7f720e8210d79921c5b2d107848c3c68c2487bdc292695718b
7
- data.tar.gz: d84c6262f801aa52c0e9f5e436da668708db4ae45bc69e48aedd3161c8fdf5fa55ef3acc6ae5e040d04ae0743735a71b4fcb14762b06f57dddc8f46e54f16872
6
+ metadata.gz: 213ed748b50091aa45914092bda54071d768133831b8af64191d6ca10d7cc55323345bee20b46d12e8e4b259f573c60cd00a336b17cf64e734449d27b6a3f425
7
+ data.tar.gz: 511c13e519aa1365e62ef6f292d66cb0ab388bf438956aac61f26ea3715d9f5fa58ee369c47c23dcb594f39d07a57b332ae84dfef3cb90612f65c363c51fb80c
data/README.md CHANGED
@@ -15,7 +15,11 @@ Add *nanoc-sprockets* to you Gemfile.
15
15
 
16
16
  gem 'nanoc-sprockets'
17
17
 
18
- ### Usage
18
+ ## Config
19
+
20
+ In default.rb, require nanoc-sprockets:
21
+
22
+ require 'nanoc-sprockets'
19
23
 
20
24
  Add a new entry in your *nanoc.yaml*.
21
25
 
@@ -32,11 +36,46 @@ data_sources:
32
36
  js_compressor: uglifier
33
37
  ```
34
38
 
35
- ### License
39
+ * items_root: the default prefix for you assets identifier
40
+ * compile: an array of js and css files to load as nanoc's items. Any other files are loaded automatically
41
+ * path: the path to the assets
42
+ * css_compressor: See [sprockets minifying assets][sprockets-minify-assets]
43
+ * js_compressor: See [sprockets minifying assets][sprockets-minify-assets]
44
+ * assets_additionnal_paths: an array of paths to be added to sprockets. Can be vendor/assets/javascript for example
45
+ * digest: The assets path will have a digest. You should toggle it to false during development.
46
+ * assets_host: Link to assets from a dedicated server.
47
+
48
+ Add specific rules for assets in *Rules*:
49
+
50
+ ```ruby
51
+ compile '/assets/*/' do
52
+ end
53
+ route '/assets/*/' do
54
+ Sprockets::Helpers.asset_path(item[:filename])
55
+ end
56
+ ```
57
+
58
+ If you plan to use sass, you should probably install the *[sprockets-sass][]* gem. Also install the *[uglifier][]* gem to minify javascript.
59
+
60
+ ## Usage
61
+
62
+ To link to any assets, use the helpers providers by [sprockets-helpers][].
63
+
64
+ * image_path
65
+ * font_path
66
+ * stylesheet_path
67
+ * javascript_path
68
+ * asset_path
69
+
70
+ ## License
36
71
 
37
72
  (c) 2014 Stormz
38
73
 
39
74
  MIT
40
75
 
41
- [sprockets]: https://github.com/sstephenson/sprockets
76
+ [sprockets]: https://github.com/sstephenson/sprockets-minify-assets
42
77
  [nanoc]: http://nanoc.ws/
78
+ [sprockets-minify-assets]: https://github.com/sstephenson/sprockets#minifying-assets
79
+ [sprockets-sass]: https://github.com/petebrowne/sprockets-sass/
80
+ [sprockets-helpers]: https://github.com/petebrowne/sprockets-helpers
81
+ [uglifier]: https://github.com/lautis/uglifier
@@ -10,6 +10,14 @@ module Nanoc::DataSources
10
10
  path =~ /assets/ && !%w(.js .css).include?(File.extname(filename))
11
11
  end
12
12
 
13
+ def up
14
+ @config = {
15
+ path: 'assets',
16
+ compile: [],
17
+ assets_additionnal_paths: []
18
+ }.merge(@config)
19
+ end
20
+
13
21
  def items
14
22
  assets = environment.each_logical_path(*compiled_assets).to_a
15
23
 
@@ -17,12 +25,9 @@ module Nanoc::DataSources
17
25
  asset = environment.find_asset(bundle)
18
26
  is_binary = !!(asset.pathname && !@site.config[:text_extensions].include?(File.extname(asset.pathname)[1..-1]))
19
27
 
28
+ content_of_filename = is_binary ? asset.pathname : asset.to_s
20
29
  attributes = {filename: bundle, binary: is_binary, mtime: asset.mtime}
21
- if is_binary
22
- Nanoc::Item.new(asset.pathname, attributes, bundle, attributes)
23
- else
24
- Nanoc::Item.new(asset.to_s, attributes, bundle, attributes)
25
- end
30
+ Nanoc::Item.new(content_of_filename, attributes, bundle, attributes)
26
31
  end
27
32
  end
28
33
 
@@ -34,11 +39,11 @@ module Nanoc::DataSources
34
39
  def create_environment
35
40
  env = ::Sprockets::Environment.new
36
41
 
37
- env.append_path File.join(config[:path], 'javascripts')
38
- env.append_path File.join(config[:path], 'images')
39
- env.append_path File.join(config[:path], 'stylesheets')
40
- config[:assets_path].each do |path|
41
- env.append_path File.join(config[:path], path)
42
+ %w(javascripts images stylesheets fonts).each do |asset|
43
+ env.append_path File.join(config[:path], asset)
44
+ end
45
+ config[:assets_additionnal_paths].each do |path|
46
+ env.append_path path
42
47
  end
43
48
  env.js_compressor = config[:js_compressor].to_sym
44
49
  env.css_compressor = config[:css_compressor].to_sym
@@ -47,7 +52,8 @@ module Nanoc::DataSources
47
52
  Sprockets::Helpers.configure do |c|
48
53
  c.environment = env
49
54
  c.prefix = config[:items_root]
50
- c.digest = production?
55
+ c.asset_host = config[:asset_host] if config[:asset_host]
56
+ c.digest = config[:digest] if config[:digest]
51
57
  end
52
58
  env
53
59
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'nanoc-sprockets'
5
- s.version = '0.0.1'
6
- s.summary = "Use sprockets as a datasource for nanoc"
7
- s.description = "A simple hello world gem"
5
+ s.version = '0.0.2'
6
+ s.summary = 'Use sprockets as a datasource for nanoc.'
7
+ s.description = 'Use sprockets as a datasource for nanoc.'
8
8
  s.homepage = 'https://github.com/stormz/nanoc-sprockets'
9
9
  s.license = 'MIT'
10
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - François de Metz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-25 00:00:00.000000000 Z
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sprockets
@@ -38,7 +38,7 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.1.0
41
- description: A simple hello world gem
41
+ description: Use sprockets as a datasource for nanoc.
42
42
  email: francois@2metz.fr
43
43
  executables: []
44
44
  extensions: []
@@ -70,6 +70,6 @@ rubyforge_project:
70
70
  rubygems_version: 2.1.5
71
71
  signing_key:
72
72
  specification_version: 4
73
- summary: Use sprockets as a datasource for nanoc
73
+ summary: Use sprockets as a datasource for nanoc.
74
74
  test_files: []
75
75
  has_rdoc: