jekyll-assets 0.2.0 → 0.2.1
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/README.md +130 -15
- data/jekyll-assets.gemspec +6 -2
- data/lib/jekyll/assets_plugin/asset_file.rb +8 -2
- data/lib/jekyll/assets_plugin/site_patch.rb +6 -6
- data/lib/jekyll/assets_plugin/version.rb +1 -1
- metadata +7 -7
data/README.md
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
|
7
7
|
Jekyll plugin, that adds Rails-alike assets pipeline, that means that:
|
8
8
|
|
9
|
-
- It allows you to write
|
10
|
-
Sass, Less and ERB.
|
9
|
+
- It allows you to write javascript/css assets in other languages such as
|
10
|
+
CoffeeScript, Sass, Less and ERB.
|
11
11
|
- It allows you to specify dependencies between your assets and automatically
|
12
12
|
concatenates them.
|
13
13
|
- It allows you to minify/compress your JavaScript and CSS assets using
|
@@ -22,8 +22,8 @@ Jekyll-Assets uses fabulous [Sprockets][sprockets] under the hood, so you may
|
|
22
22
|
refer to Rails guide about [Asset Pipeline][rails-guide] for detailed
|
23
23
|
information about amazing features it gives you.
|
24
24
|
|
25
|
-
*
|
26
|
-
CoffeeScript.
|
25
|
+
*Note:* You must have an [ExecJS][extjs] supported runtime in order to use
|
26
|
+
CoffeeScript.
|
27
27
|
|
28
28
|
|
29
29
|
[rails-guide]: http://guides.rubyonrails.org/asset_pipeline.html
|
@@ -57,10 +57,10 @@ require "jekyll-assets"
|
|
57
57
|
|
58
58
|
Once plugin installed, you'll have following liquid tags available:
|
59
59
|
|
60
|
-
- `javascript app`: Generates `<script>` tag for `app.js`
|
61
|
-
- `stylesheet app`: Generates `<link>` tag for `app.css`
|
62
|
-
- `asset_path logo.png`: Returns _resulting_ URL for `logo.png`
|
63
|
-
- `asset app.css`: Returns _compiled_ body of `app.css`
|
60
|
+
- `{% javascript app %}`: Generates `<script>` tag for `app.js`
|
61
|
+
- `{% stylesheet app %}`: Generates `<link>` tag for `app.css`
|
62
|
+
- `{% asset_path logo.png %}`: Returns _resulting_ URL for `logo.png`
|
63
|
+
- `{% asset app.css %}`: Returns _compiled_ body of `app.css`
|
64
64
|
|
65
65
|
All compiled assets will be stored under `assets/` dir of generated site.
|
66
66
|
|
@@ -96,8 +96,8 @@ $(function () {
|
|
96
96
|
});
|
97
97
|
```
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
If you want to use CoffeScript, just add `.coffee` suffix to the file you want
|
100
|
+
and you're good to go. For example, here's how your `app.js.coffe` might look
|
101
101
|
like:
|
102
102
|
|
103
103
|
``` coffeescript
|
@@ -107,7 +107,13 @@ $ ->
|
|
107
107
|
alert 'I love BIG BOOKS! And small ones too!'
|
108
108
|
```
|
109
109
|
|
110
|
-
|
110
|
+
Notice, that `vendor/jquery` is not required to be coffee script. You can easily
|
111
|
+
mix CoffeeScript and vanilla JavaScript, CSS and SCSS and SASS and LESS. The
|
112
|
+
difference is only in comments styles used with _directives_.
|
113
|
+
|
114
|
+
See detailes information about these _directives_ below.
|
115
|
+
|
116
|
+
You might also want your stylesheets and javascripts to be minified. In this
|
111
117
|
case just install `uglifier` gem and add following lines into your `config.yml`:
|
112
118
|
|
113
119
|
``` yaml
|
@@ -117,16 +123,15 @@ assets:
|
|
117
123
|
css: sass
|
118
124
|
```
|
119
125
|
|
120
|
-
|
121
|
-
|
122
|
-
config file.
|
126
|
+
If you want to use YUI compressor for minification, install `yui-compressor`
|
127
|
+
gem and put `yui` in place of `uglifier` and/or `sass` in the config file.
|
123
128
|
|
124
129
|
Let's go crazy now! Assume you want your blog's `body` background color to be
|
125
130
|
white all the time, but red in December. Just add `.erb` suffix extension and
|
126
131
|
you can use ruby to "pre-process" asset, something like this:
|
127
132
|
|
128
133
|
```
|
129
|
-
|
134
|
+
// file: _assets/stylesheets/app.css.sass.erb
|
130
135
|
|
131
136
|
body
|
132
137
|
background-color: <%= (12 == Date.today.month) ? "red" : "white" %>
|
@@ -153,6 +158,25 @@ $ ->
|
|
153
158
|
info: "I love BIG BOOKS! And small ones too!"
|
154
159
|
```
|
155
160
|
|
161
|
+
Finally, you might want to store your assets on [Amazon S3][amazon-s3] or any
|
162
|
+
CDN service you like. As said previously, all compiled/processed assets got
|
163
|
+
special MD5 checksum appended to their original filenames. So, for example,
|
164
|
+
your `app.js.coffee` will become something like:
|
165
|
+
|
166
|
+
app-4f41243847da693a4f356c0486114bc6.js
|
167
|
+
|
168
|
+
By default, generated URLs will have `/assets/` prefixes, but you will want to
|
169
|
+
change this if you are going to host assets somewhere else. This can be easily
|
170
|
+
changed via configuration:
|
171
|
+
|
172
|
+
``` yaml
|
173
|
+
assets:
|
174
|
+
baseurl: //my.super-cool-cdn.com/
|
175
|
+
```
|
176
|
+
|
177
|
+
[amazon-s3]: http://aws.amazon.com/s3
|
178
|
+
|
179
|
+
|
156
180
|
That's all. Feel free to ask questions if any on [twitter][twitter],
|
157
181
|
[jabber][jabber] or [e-mail][e-mail].
|
158
182
|
|
@@ -161,6 +185,97 @@ That's all. Feel free to ask questions if any on [twitter][twitter],
|
|
161
185
|
[e-mail]: mailto://ixti@member.fsf.org
|
162
186
|
|
163
187
|
|
188
|
+
## The Directive Processor
|
189
|
+
|
190
|
+
*Note:* This section extracted from [Sprockets][sprockets] README.
|
191
|
+
|
192
|
+
Sprockets runs the *directive processor* on each CSS and JavaScript
|
193
|
+
source file. The directive processor scans for comment lines beginning
|
194
|
+
with `=` in comment blocks at the top of the file.
|
195
|
+
|
196
|
+
//= require jquery
|
197
|
+
//= require jquery-ui
|
198
|
+
//= require backbone
|
199
|
+
//= require_tree .
|
200
|
+
|
201
|
+
The first word immediately following `=` specifies the directive
|
202
|
+
name. Any words following the directive name are treated as
|
203
|
+
arguments. Arguments may be placed in single or double quotes if they
|
204
|
+
contain spaces, similar to commands in the Unix shell.
|
205
|
+
|
206
|
+
**Note**: Non-directive comment lines will be preserved in the final
|
207
|
+
asset, but directive comments are stripped after
|
208
|
+
processing. Sprockets will not look for directives in comment blocks
|
209
|
+
that occur after the first line of code.
|
210
|
+
|
211
|
+
|
212
|
+
### Supported Comment Types
|
213
|
+
|
214
|
+
The directive processor understands comment blocks in three formats:
|
215
|
+
|
216
|
+
/* Multi-line comment blocks (CSS, SCSS, JavaScript)
|
217
|
+
*= require foo
|
218
|
+
*/
|
219
|
+
|
220
|
+
// Single-line comment blocks (SCSS, JavaScript)
|
221
|
+
//= require foo
|
222
|
+
|
223
|
+
# Single-line comment blocks (CoffeeScript)
|
224
|
+
#= require foo
|
225
|
+
|
226
|
+
|
227
|
+
### Sprockets Directives
|
228
|
+
|
229
|
+
You can use the following directives to declare dependencies in asset
|
230
|
+
source files.
|
231
|
+
|
232
|
+
For directives that take a *path* argument, you may specify either a
|
233
|
+
logical path or a relative path. Relative paths begin with `./` and
|
234
|
+
reference files relative to the location of the current file.
|
235
|
+
|
236
|
+
#### The `require` Directive
|
237
|
+
|
238
|
+
`require` *path* inserts the contents of the asset source file
|
239
|
+
specified by *path*. If the file is required multiple times, it will
|
240
|
+
appear in the bundle only once.
|
241
|
+
|
242
|
+
#### The `include` Directive
|
243
|
+
|
244
|
+
`include` *path* works like `require`, but inserts the contents of the
|
245
|
+
specified source file even if it has already been included or
|
246
|
+
required.
|
247
|
+
|
248
|
+
#### The `require_directory` Directive
|
249
|
+
|
250
|
+
`require_directory` *path* requires all source files of the same
|
251
|
+
format in the directory specified by *path*. Files are required in
|
252
|
+
alphabetical order.
|
253
|
+
|
254
|
+
#### The `require_tree` Directive
|
255
|
+
|
256
|
+
`require_tree` *path* works like `require_directory`, but operates
|
257
|
+
recursively to require all files in all subdirectories of the
|
258
|
+
directory specified by *path*.
|
259
|
+
|
260
|
+
#### The `require_self` Directive
|
261
|
+
|
262
|
+
`require_self` tells Sprockets to insert the body of the current
|
263
|
+
source file before any subsequent `require` or `include` directives.
|
264
|
+
|
265
|
+
#### The `depend_on` Directive
|
266
|
+
|
267
|
+
`depend_on` *path* declares a dependency on the given *path* without
|
268
|
+
including it in the bundle. This is useful when you need to expire an
|
269
|
+
asset's cache in response to a change in another file.
|
270
|
+
|
271
|
+
#### The `stub` Directive
|
272
|
+
|
273
|
+
`stub` *path* allows dependency to be excluded from the asset bundle.
|
274
|
+
The *path* must be a valid asset and may or may not already be part
|
275
|
+
of the bundle. Once stubbed, it is blacklisted and can't be brought
|
276
|
+
back by any other `require`.
|
277
|
+
|
278
|
+
|
164
279
|
## Configuration
|
165
280
|
|
166
281
|
You can fine-tune configuration by editing your `_config.yml`:
|
data/jekyll-assets.gemspec
CHANGED
@@ -6,10 +6,14 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.name = "jekyll-assets"
|
7
7
|
gem.version = Jekyll::AssetsPlugin::VERSION
|
8
8
|
gem.homepage = "http://ixti.github.com/jekyll-assets"
|
9
|
-
gem.authors =
|
9
|
+
gem.authors = "Aleksey V Zapparov"
|
10
10
|
gem.email = %w{ixti@member.fsf.org}
|
11
11
|
gem.summary = "jekyll-assets-#{Jekyll::AssetsPlugin::VERSION}"
|
12
|
-
gem.description =
|
12
|
+
gem.description = <<-DESC
|
13
|
+
Jekyll plugin, that allows you to write javascript/css assets in
|
14
|
+
other languages such as CoffeeScript, Sass, Less and ERB, concatenate
|
15
|
+
them, respecting dependencies, minify and many more.
|
16
|
+
DESC
|
13
17
|
|
14
18
|
gem.add_dependency "jekyll"
|
15
19
|
gem.add_dependency "sprockets", "~> 2.8"
|
@@ -45,8 +45,8 @@ module Jekyll
|
|
45
45
|
|
46
46
|
def == other
|
47
47
|
case other
|
48
|
-
when AssetFile then other.asset
|
49
|
-
when Sprockets::Asset then other
|
48
|
+
when AssetFile then same_asset? other.asset
|
49
|
+
when Sprockets::Asset then same_asset? other
|
50
50
|
else false
|
51
51
|
end
|
52
52
|
end
|
@@ -54,6 +54,12 @@ module Jekyll
|
|
54
54
|
def to_s
|
55
55
|
"#<Jekyll::AssetsPlugin::AssetFile:#{asset.logical_path}>"
|
56
56
|
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def same_asset? other
|
61
|
+
other.pathname.cleanpath == asset.pathname.cleanpath
|
62
|
+
end
|
57
63
|
end
|
58
64
|
end
|
59
65
|
end
|
@@ -26,15 +26,15 @@ module Jekyll
|
|
26
26
|
@assets.css_compressor = assets_config.css_compressor
|
27
27
|
|
28
28
|
# bind jekyll and Sprockets context together
|
29
|
-
@assets.context_class.instance_variable_set :@
|
29
|
+
@assets.context_class.instance_variable_set :@site, self
|
30
30
|
|
31
31
|
@assets.context_class.class_eval do
|
32
|
-
def
|
33
|
-
self.class.instance_variable_get :@
|
32
|
+
def site
|
33
|
+
self.class.instance_variable_get :@site
|
34
34
|
end
|
35
35
|
|
36
36
|
def asset_baseurl
|
37
|
-
|
37
|
+
site.assets_config.baseurl.chomp "/"
|
38
38
|
end
|
39
39
|
|
40
40
|
def asset_path(path, options = {})
|
@@ -42,8 +42,8 @@ module Jekyll
|
|
42
42
|
raise AssetFile::NotFound, "couldn't find file '#{path}'"
|
43
43
|
end
|
44
44
|
|
45
|
-
unless
|
46
|
-
|
45
|
+
unless site.static_files.include? asset
|
46
|
+
site.static_files << AssetFile.new(site, asset)
|
47
47
|
end
|
48
48
|
|
49
49
|
"#{asset_baseurl}/#{asset.digest_path}".squeeze "/"
|
metadata
CHANGED
@@ -1,17 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Aleksey
|
9
|
-
- V
|
10
|
-
- Zapparov
|
8
|
+
- Aleksey V Zapparov
|
11
9
|
autorequire:
|
12
10
|
bindir: bin
|
13
11
|
cert_chain: []
|
14
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-31 00:00:00.000000000 Z
|
15
13
|
dependencies:
|
16
14
|
- !ruby/object:Gem::Dependency
|
17
15
|
name: jekyll
|
@@ -109,7 +107,9 @@ dependencies:
|
|
109
107
|
- - ! '>='
|
110
108
|
- !ruby/object:Gem::Version
|
111
109
|
version: '0'
|
112
|
-
description:
|
110
|
+
description: ! " Jekyll plugin, that allows you to write javascript/css assets in\n
|
111
|
+
\ other languages such as CoffeeScript, Sass, Less and ERB, concatenate\n them,
|
112
|
+
respecting dependencies, minify and many more.\n"
|
113
113
|
email:
|
114
114
|
- ixti@member.fsf.org
|
115
115
|
executables: []
|
@@ -172,7 +172,7 @@ rubyforge_project:
|
|
172
172
|
rubygems_version: 1.8.23
|
173
173
|
signing_key:
|
174
174
|
specification_version: 3
|
175
|
-
summary: jekyll-assets-0.2.
|
175
|
+
summary: jekyll-assets-0.2.1
|
176
176
|
test_files:
|
177
177
|
- spec/fixtures/.gitignore
|
178
178
|
- spec/fixtures/_assets/app.css.erb
|