octopress-asset-pipeline 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +25 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +104 -0
- data/Rakefile +8 -0
- data/assets/docs/changelog.markdown +10 -0
- data/assets/docs/index.markdown +106 -0
- data/demo/Gemfile +8 -0
- data/demo/_config.yml +5 -0
- data/demo/_octopress.yml +2 -0
- data/demo/_sass/_partial.sass +1 -0
- data/demo/blah.js +1 -0
- data/demo/foo.coffee +3 -0
- data/demo/index.html +4 -0
- data/demo/sass-test.scss +5 -0
- data/demo/test.css +2 -0
- data/lib/octopress-asset-pipeline/assets/coffeescript.rb +23 -0
- data/lib/octopress-asset-pipeline/assets/css.rb +19 -0
- data/lib/octopress-asset-pipeline/assets/javascript.rb +12 -0
- data/lib/octopress-asset-pipeline/assets/local.rb +52 -0
- data/lib/octopress-asset-pipeline/assets/sass.rb +31 -0
- data/lib/octopress-asset-pipeline/version.rb +7 -0
- data/lib/octopress-asset-pipeline.rb +144 -0
- data/octopress-asset-pipeline.gemspec +26 -0
- data/test/Gemfile +8 -0
- data/test/_concat_false.yml +4 -0
- data/test/_config.yml +5 -0
- data/test/concat_false/blah.js +1 -0
- data/test/concat_false/foo.js +6 -0
- data/test/concat_false/index.html +2 -0
- data/test/concat_false/sass-test.css +2 -0
- data/test/concat_false/test.css +2 -0
- data/test/expected/index.html +2 -0
- data/test/expected/javascripts/all-.js +1 -0
- data/test/expected/stylesheets/all-.css +1 -0
- data/test/site/index.html +2 -0
- data/test/site/javascripts/all-.js +1 -0
- data/test/site/stylesheets/all-.css +1 -0
- data/test/source/_sass/_partial.sass +1 -0
- data/test/source/blah.js +1 -0
- data/test/source/foo.coffee +3 -0
- data/test/source/index.html +4 -0
- data/test/source/sass-test.scss +5 -0
- data/test/source/test.css +2 -0
- data/test/test.rb +14 -0
- data/test/test_suite.rb +160 -0
- metadata +172 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6109318c08d99e5cf10c768d12a28ed723ad0119
|
4
|
+
data.tar.gz: bde4e372ce2d8f5624cbf5bff3952a1bd859b79d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9be3958ab36d4761f49b00926a844d0cbed88e3bebf29cb288150c7d638e5455204ba51b52deb1208eb07e6e8b5d5804c9a305106f984d5562bb5afdfec038dc
|
7
|
+
data.tar.gz: 405f5be6958fdb36ec7806e2082065d2ef46abf5751e55dd5e41b2b32ba79bfba431ba05ae8faf8f353b6c1fc2897516ae46d239bf3c2304ecdcbd7379edee98
|
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
_site
|
24
|
+
.sass-cache
|
25
|
+
.DS_Store
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Brandon Mathis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
# Octopress Asset Pipeline
|
2
|
+
|
3
|
+
Combine and compress and fingerprint Stylesheets (CSS and Sass) and Javascripts (JS and Coffeescript) to a single fingerprinted .css or .js file.
|
4
|
+
|
5
|
+
**How it works:** This plugin will automatically search Jekyll's site index for .js, .coffee, .css, .scss and .sass
|
6
|
+
files and combine, compress and fingerprint them so they're ready for deployment. Then add the liquid tags to your site layout to write
|
7
|
+
the necessary script or link tags.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your site's Gemfile:
|
12
|
+
|
13
|
+
gem 'octopress-asset-pipeline'
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it manually:
|
20
|
+
|
21
|
+
$ gem install octopress-asset-pipeline
|
22
|
+
|
23
|
+
|
24
|
+
### Add gem to Jekyll
|
25
|
+
|
26
|
+
Add the gem to Jekyll's configuration file:
|
27
|
+
|
28
|
+
```yaml
|
29
|
+
gems:
|
30
|
+
- octopress-asset-pipeline
|
31
|
+
```
|
32
|
+
|
33
|
+
## Liquid tags
|
34
|
+
|
35
|
+
Include these tags in your site's layout.
|
36
|
+
|
37
|
+
```
|
38
|
+
{% css_asset_tag %}
|
39
|
+
{% js_asset_tag %}
|
40
|
+
```
|
41
|
+
|
42
|
+
When Jekyll is compiled these will be replaced with something like this.
|
43
|
+
|
44
|
+
```
|
45
|
+
<link href='/stylesheets/all-b5c56f2652600cde201589531c453ba1.css' media='all' rel='stylesheet' type='text/css'>
|
46
|
+
<script src='/javascripts/all-75489c7b2da6efce7ee1bc45795d400b.js'></script>
|
47
|
+
```
|
48
|
+
|
49
|
+
## Configuration
|
50
|
+
|
51
|
+
This plugin integrates with the core asset pipeline system in Octopress Ink, therefore
|
52
|
+
the configurations are set in the `_octopress.yml` configuration file.
|
53
|
+
|
54
|
+
| Option | Description | Default |
|
55
|
+
|:---------------------|:------------------------------------------|:------------|
|
56
|
+
| `combine_css` | Combine all .css, .scss and .sass files | true |
|
57
|
+
| `combine_js` | Combine all .js and .coffee files | true |
|
58
|
+
| `compress_css` | Compress stylesheets for production | true |
|
59
|
+
| `compress_js` | Compress Javascripts for production | true |
|
60
|
+
| `order_js` | Order for .js and .coffee files | [] |
|
61
|
+
| `order_css` | Order for .css, .scss, and .sass | [] |
|
62
|
+
| `uglifier` | Settings for Javascript Uglifier. [Documentaion](https://github.com/lautis/uglifier). | {} |
|
63
|
+
|
64
|
+
### Ordering assets
|
65
|
+
|
66
|
+
By default when scripts and stylesheets are combined, they added based on
|
67
|
+
their order in the file system. You can manually specify order like this:
|
68
|
+
|
69
|
+
```
|
70
|
+
order_js
|
71
|
+
- jquery.js
|
72
|
+
- kittens.coffee
|
73
|
+
|
74
|
+
order_css
|
75
|
+
- normalize.css
|
76
|
+
- site.sass
|
77
|
+
```
|
78
|
+
Assets will ordered as specified. Any additional assets will be appended based on their order in the file system.
|
79
|
+
|
80
|
+
Note: It is not necessary to write full paths in these configurations. An asset at `javascripts/lib/jquery.js` will match `jquery.js` and be ordered accordingly.
|
81
|
+
|
82
|
+
## Media files
|
83
|
+
|
84
|
+
Usually it's better to define print styles inside of the main CSS file beneath a print media query, like this.
|
85
|
+
|
86
|
+
```
|
87
|
+
@media print {
|
88
|
+
* { background: none }
|
89
|
+
* { color: #000 }
|
90
|
+
...
|
91
|
+
}
|
92
|
+
```
|
93
|
+
|
94
|
+
If you want to specify a separate print stylesheet, include `@print` in your filename, before the extension.
|
95
|
+
|
96
|
+
When your site is compiled, this file will be written separately and its `<link>` tag will include a `media='print'` attribute.
|
97
|
+
|
98
|
+
## Contributing
|
99
|
+
|
100
|
+
1. Fork it ( https://github.com/[my-github-username]/octopress-asset-pipeline/fork )
|
101
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
102
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
103
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
104
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "octopress-ink"
|
3
|
+
|
4
|
+
desc "Copy Readme and Changelog into docs"
|
5
|
+
task :update_docs do
|
6
|
+
Octopress::Ink.copy_doc 'README.md', 'assets/docs/index.markdown'
|
7
|
+
Octopress::Ink.copy_doc 'CHANGELOG.md', 'assets/docs/changelog.markdown', '/changelog/'
|
8
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
---
|
2
|
+
title: "Octopress Asset Pipeline"
|
3
|
+
---
|
4
|
+
|
5
|
+
Combine and compress and fingerprint Stylesheets (CSS and Sass) and Javascripts (JS and Coffeescript) to a single fingerprinted .css or .js file.
|
6
|
+
|
7
|
+
**How it works:** This plugin will automatically search Jekyll's site index for .js, .coffee, .css, .scss and .sass
|
8
|
+
files and combine, compress and fingerprint them so they're ready for deployment. Then add the liquid tags to your site layout to write
|
9
|
+
the necessary script or link tags.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your site's Gemfile:
|
14
|
+
|
15
|
+
gem 'octopress-asset-pipeline'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it manually:
|
22
|
+
|
23
|
+
$ gem install octopress-asset-pipeline
|
24
|
+
|
25
|
+
|
26
|
+
### Add gem to Jekyll
|
27
|
+
|
28
|
+
Add the gem to Jekyll's configuration file:
|
29
|
+
|
30
|
+
```yaml
|
31
|
+
gems:
|
32
|
+
- octopress-asset-pipeline
|
33
|
+
```
|
34
|
+
|
35
|
+
## Liquid tags
|
36
|
+
|
37
|
+
Include these tags in your site's layout.
|
38
|
+
|
39
|
+
```
|
40
|
+
{% css_asset_tag %}
|
41
|
+
{% js_asset_tag %}
|
42
|
+
```
|
43
|
+
|
44
|
+
When Jekyll is compiled these will be replaced with something like this.
|
45
|
+
|
46
|
+
```
|
47
|
+
<link href='/stylesheets/all-b5c56f2652600cde201589531c453ba1.css' media='all' rel='stylesheet' type='text/css'>
|
48
|
+
<script src='/javascripts/all-75489c7b2da6efce7ee1bc45795d400b.js'></script>
|
49
|
+
```
|
50
|
+
|
51
|
+
## Configuration
|
52
|
+
|
53
|
+
This plugin integrates with the core asset pipeline system in Octopress Ink, therefore
|
54
|
+
the configurations are set in the `_octopress.yml` configuration file.
|
55
|
+
|
56
|
+
| Option | Description | Default |
|
57
|
+
|:---------------------|:------------------------------------------|:------------|
|
58
|
+
| `combine_css` | Combine all .css, .scss and .sass files | true |
|
59
|
+
| `combine_js` | Combine all .js and .coffee files | true |
|
60
|
+
| `compress_css` | Compress stylesheets for production | true |
|
61
|
+
| `compress_js` | Compress Javascripts for production | true |
|
62
|
+
| `order_js` | Order for .js and .coffee files | [] |
|
63
|
+
| `order_css` | Order for .css, .scss, and .sass | [] |
|
64
|
+
| `uglifier` | Settings for Javascript Uglifier. [Documentaion](https://github.com/lautis/uglifier). | {} |
|
65
|
+
|
66
|
+
### Ordering assets
|
67
|
+
|
68
|
+
By default when scripts and stylesheets are combined, they added based on
|
69
|
+
their order in the file system. You can manually specify order like this:
|
70
|
+
|
71
|
+
```
|
72
|
+
order_js
|
73
|
+
- jquery.js
|
74
|
+
- kittens.coffee
|
75
|
+
|
76
|
+
order_css
|
77
|
+
- normalize.css
|
78
|
+
- site.sass
|
79
|
+
```
|
80
|
+
Assets will ordered as specified. Any additional assets will be appended based on their order in the file system.
|
81
|
+
|
82
|
+
Note: It is not necessary to write full paths in these configurations. An asset at `javascripts/lib/jquery.js` will match `jquery.js` and be ordered accordingly.
|
83
|
+
|
84
|
+
## Media files
|
85
|
+
|
86
|
+
Usually it's better to define print styles inside of the main CSS file beneath a print media query, like this.
|
87
|
+
|
88
|
+
```
|
89
|
+
@media print {
|
90
|
+
* { background: none }
|
91
|
+
* { color: #000 }
|
92
|
+
...
|
93
|
+
}
|
94
|
+
```
|
95
|
+
|
96
|
+
If you want to specify a separate print stylesheet, include `@print` in your filename, before the extension.
|
97
|
+
|
98
|
+
When your site is compiled, this file will be written separately and its `<link>` tag will include a `media='print'` attribute.
|
99
|
+
|
100
|
+
## Contributing
|
101
|
+
|
102
|
+
1. Fork it ( https://github.com/[my-github-username]/octopress-asset-pipeline/fork )
|
103
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
104
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
105
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
106
|
+
5. Create a new Pull Request
|
data/demo/Gemfile
ADDED
data/demo/_config.yml
ADDED
data/demo/_octopress.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$bg: black
|
data/demo/blah.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
console.log("Yo I'm a javascript")
|
data/demo/foo.coffee
ADDED
data/demo/index.html
ADDED
data/demo/sass-test.scss
ADDED
data/demo/test.css
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Ink
|
3
|
+
module Assets
|
4
|
+
class LocalCoffeeScriptAsset < LocalJavaScriptAsset
|
5
|
+
def read
|
6
|
+
compile
|
7
|
+
end
|
8
|
+
|
9
|
+
def path
|
10
|
+
File.join(file.site.source, file.path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def compile
|
14
|
+
::CoffeeScript.compile(render_page)
|
15
|
+
end
|
16
|
+
|
17
|
+
def destination
|
18
|
+
File.join(base, filename.sub(/\.coffee/,'.js'))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Ink
|
3
|
+
module Assets
|
4
|
+
class LocalCssAsset < LocalAsset
|
5
|
+
def media
|
6
|
+
path.scan(/@(.+?)\./).flatten[0] || 'all'
|
7
|
+
end
|
8
|
+
|
9
|
+
def destination
|
10
|
+
File.join(base, filename.sub(/@(.+?)\./,'.'))
|
11
|
+
end
|
12
|
+
|
13
|
+
def tag
|
14
|
+
"<link href='#{Filters.expand_url(File.join(destination))}' media='#{media}' rel='stylesheet' type='text/css'>"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Ink
|
3
|
+
module Assets
|
4
|
+
class LocalAsset < Asset
|
5
|
+
def initialize(plugin, file)
|
6
|
+
@plugin = plugin
|
7
|
+
@file = file
|
8
|
+
end
|
9
|
+
|
10
|
+
def info
|
11
|
+
message = filename.ljust(35)
|
12
|
+
message += "from: #{base}"
|
13
|
+
" - #{message}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def filename
|
17
|
+
File.basename(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def base
|
21
|
+
file.relative_path.sub(filename,'').sub(/^\/(.+)\/$/,'\1')
|
22
|
+
end
|
23
|
+
|
24
|
+
def destination
|
25
|
+
File.join(base, filename)
|
26
|
+
end
|
27
|
+
|
28
|
+
def path
|
29
|
+
file.path
|
30
|
+
end
|
31
|
+
|
32
|
+
def read
|
33
|
+
File.open(path).read
|
34
|
+
end
|
35
|
+
|
36
|
+
# Copy is unncessary with local assets
|
37
|
+
#
|
38
|
+
def copy(target_dir); end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def render_page
|
43
|
+
payload = Ink.site.site_payload
|
44
|
+
payload['page'] = file.data
|
45
|
+
|
46
|
+
render_liquid(file.content, payload)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Octopress
|
2
|
+
module Ink
|
3
|
+
module Assets
|
4
|
+
class LocalSassAsset < LocalCssAsset
|
5
|
+
def read
|
6
|
+
compile
|
7
|
+
end
|
8
|
+
|
9
|
+
def content
|
10
|
+
render_page
|
11
|
+
end
|
12
|
+
|
13
|
+
def ext
|
14
|
+
file.ext
|
15
|
+
end
|
16
|
+
|
17
|
+
def path
|
18
|
+
File.join(file.site.source, file.path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def destination
|
22
|
+
File.join(base, filename.sub(/@(.+?)\./,'.').sub(/s.ss/, 'css'))
|
23
|
+
end
|
24
|
+
|
25
|
+
def compile
|
26
|
+
PluginAssetPipeline.compile_sass(self)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require 'octopress-ink'
|
2
|
+
require 'octopress-asset-pipeline/version'
|
3
|
+
|
4
|
+
require 'octopress-asset-pipeline/assets/local'
|
5
|
+
require 'octopress-asset-pipeline/assets/css'
|
6
|
+
require 'octopress-asset-pipeline/assets/sass'
|
7
|
+
require 'octopress-asset-pipeline/assets/javascript'
|
8
|
+
require 'octopress-asset-pipeline/assets/coffeescript'
|
9
|
+
|
10
|
+
module Octopress
|
11
|
+
module Ink
|
12
|
+
module AssetPipeline
|
13
|
+
class Plugin < Ink::Plugin
|
14
|
+
def configuration
|
15
|
+
{
|
16
|
+
name: "Octopress Asset Pipeline",
|
17
|
+
slug: "octopress-asset-pipeline",
|
18
|
+
assets_path: File.expand_path(File.join(File.dirname(__FILE__), "../../../assets")),
|
19
|
+
type: "plugin",
|
20
|
+
version: Octopress::Ink::LocalAssetPipeline::VERSION,
|
21
|
+
description: "Combine and compress CSS and Sass, Javascript and Coffeescript to a single fingerprinted file.",
|
22
|
+
website: "https://github.com/octopress/asset-pipeline",
|
23
|
+
local: true
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
def register
|
28
|
+
@config ||= Ink.config
|
29
|
+
# Tell Jekyll to read static files and pages
|
30
|
+
# This is necessary when Jekyll isn't being asked to build a site,
|
31
|
+
# like when a user runs the list command to list assets
|
32
|
+
#
|
33
|
+
if Ink.site.pages.empty? && Ink.site.posts.empty?
|
34
|
+
Ink.site.read_directories
|
35
|
+
end
|
36
|
+
|
37
|
+
add_stylesheets
|
38
|
+
add_javascripts
|
39
|
+
end
|
40
|
+
|
41
|
+
# Return stylesheets to be combined in the asset pipeline
|
42
|
+
def stylesheets
|
43
|
+
sort(@css.clone.concat(@sass), @config['order_css'] || [])
|
44
|
+
end
|
45
|
+
|
46
|
+
def javascripts
|
47
|
+
sort(@js.clone.concat(@coffee), @config['order_js'] || [])
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def combine_js
|
53
|
+
@config['combine_js']
|
54
|
+
end
|
55
|
+
|
56
|
+
def combine_css
|
57
|
+
@config['combine_css']
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_stylesheets
|
61
|
+
add_css
|
62
|
+
add_sass
|
63
|
+
|
64
|
+
if !combine_css
|
65
|
+
# Add tags for {% js_asset_tag %}
|
66
|
+
stylesheets.each { |f| Plugins.add_css_tag(f.tag) }
|
67
|
+
@css.clear
|
68
|
+
@sass.clear
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
def add_javascripts
|
74
|
+
add_js
|
75
|
+
add_coffee
|
76
|
+
|
77
|
+
if !combine_js
|
78
|
+
# Add tags for {% js_asset_tag %}
|
79
|
+
javascripts.each { |f| Plugins.add_js_tag(f.tag) }
|
80
|
+
@js.clear
|
81
|
+
@coffee.clear
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def sort(files, config)
|
86
|
+
sorted = []
|
87
|
+
config.each do |item|
|
88
|
+
files.each do |file|
|
89
|
+
sorted << files.delete(file) if file.path.include? item
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
sorted.concat files
|
94
|
+
end
|
95
|
+
|
96
|
+
# Finds all Sass files registered by Jekyll
|
97
|
+
#
|
98
|
+
def add_sass
|
99
|
+
Ink.site.pages.each do |f|
|
100
|
+
if f.ext =~ /\.s[ca]ss/
|
101
|
+
@sass << Assets::LocalSassAsset.new(self, f)
|
102
|
+
Ink.site.pages.delete(f) if combine_css
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Finds all CSS files registered by Jekyll
|
108
|
+
#
|
109
|
+
def add_css
|
110
|
+
Ink.site.static_files.each do |f|
|
111
|
+
if f.path =~ /\.css$/
|
112
|
+
@css << Assets::LocalCssAsset.new(self, f)
|
113
|
+
Ink.site.static_files.delete(f) if combine_css
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# Finds all Coffeescript files registered by Jekyll
|
119
|
+
#
|
120
|
+
def add_coffee
|
121
|
+
Ink.site.pages.each do |f|
|
122
|
+
if f.ext =~ /\.coffee$/
|
123
|
+
@coffee << Assets::LocalCoffeeScriptAsset.new(self, f)
|
124
|
+
Ink.site.pages.delete(f) if combine_js
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Finds all Javascript files registered by Jekyll
|
130
|
+
#
|
131
|
+
def add_js
|
132
|
+
Ink.site.static_files.each do |f|
|
133
|
+
if f.path =~ /\.js$/
|
134
|
+
@js << Assets::LocalJavaScriptAsset.new(self, f)
|
135
|
+
Ink.site.static_files.delete(f) if combine_js
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
Octopress::Ink.register_plugin(Octopress::Ink::AssetPipeline::Plugin)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'octopress-asset-pipeline/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "octopress-asset-pipeline"
|
8
|
+
spec.version = Octopress::Ink::LocalAssetPipeline::VERSION
|
9
|
+
spec.authors = ["Brandon Mathis"]
|
10
|
+
spec.email = ["brandon@imathis.com"]
|
11
|
+
spec.summary = %q{Combine and compress CSS and Sass, Javascript and Coffeescript to a single fingerprinted file.}
|
12
|
+
spec.description = %q{Combine and compress CSS and Sass, Javascript and Coffeescript to a single fingerprinted file.}
|
13
|
+
spec.homepage = "https://github.com/octopress/asset-pipeline"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "octopress"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "octopress-ink", "~> 1.0.0.rc.1"
|
26
|
+
end
|
data/test/Gemfile
ADDED
data/test/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
console.log("Yo I'm a javascript")
|
@@ -0,0 +1 @@
|
|
1
|
+
console.log("Yo I'm a javascript")(function(){console.log("hi")}).call(this);
|
@@ -0,0 +1 @@
|
|
1
|
+
body{color:#444}body{background:black}
|
@@ -0,0 +1 @@
|
|
1
|
+
console.log("Yo I'm a javascript")(function(){console.log("hi")}).call(this);
|
@@ -0,0 +1 @@
|
|
1
|
+
body{color:#444}body{background:black}
|
@@ -0,0 +1 @@
|
|
1
|
+
$bg: black
|
data/test/source/blah.js
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
console.log("Yo I'm a javascript")
|
data/test/test.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require './test_suite'
|
2
|
+
ENV['JEKYLL_ENV'] = 'test'
|
3
|
+
|
4
|
+
@failures = []
|
5
|
+
|
6
|
+
build
|
7
|
+
|
8
|
+
test_dirs('Site build', 'site', 'expected')
|
9
|
+
|
10
|
+
#build({:octopress_config => '_concat_false.yml'})
|
11
|
+
|
12
|
+
#test_dirs('Site build', 'site', 'concat_false')
|
13
|
+
|
14
|
+
print_results
|
data/test/test_suite.rb
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'colorator'
|
2
|
+
require 'find'
|
3
|
+
|
4
|
+
# This is a makeshift integration test-suite.
|
5
|
+
# It is unapologetically pragmatic.
|
6
|
+
|
7
|
+
|
8
|
+
# Build Jekyll
|
9
|
+
#
|
10
|
+
def build(options={})
|
11
|
+
if options[:octopress_config]
|
12
|
+
FileUtils.cp options[:octopress_config], '_octopress.yml'
|
13
|
+
end
|
14
|
+
|
15
|
+
config = ['_config.yml'] << options[:config]
|
16
|
+
cmd = "rm -rf site && bundle exec jekyll build --config #{config.join(',')}"
|
17
|
+
|
18
|
+
`#{cmd}`
|
19
|
+
`rm _octopress.yml` if options[:octopress_config]
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
# Find all files in a given directory
|
24
|
+
#
|
25
|
+
def dir_files(dir)
|
26
|
+
Find.find(dir).to_a.reject!{|f| File.directory?(f) }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Recursively diff two directories
|
30
|
+
#
|
31
|
+
# This will walk through dir1 and diff matching paths in dir2
|
32
|
+
#
|
33
|
+
def test_dirs(desc, dir1, dir2)
|
34
|
+
|
35
|
+
test_missing_files(desc, dir1, dir2)
|
36
|
+
|
37
|
+
dir_files(dir1).each do |file|
|
38
|
+
file2 = file.sub(dir1, dir2)
|
39
|
+
if File.exist?(file2)
|
40
|
+
if diff = diff_file(file, file2)
|
41
|
+
@failures << {
|
42
|
+
desc: "#{desc}\nDiff of file: #{file.sub(dir1+'/', '')}\n",
|
43
|
+
result: format_diff(diff)
|
44
|
+
}
|
45
|
+
pout 'F'.red
|
46
|
+
else
|
47
|
+
pout '.'.green
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def format_diff(diff)
|
54
|
+
"#{diff.gsub(/\A.+?\n/,'').gsub(/^[^><].+/,'---').gsub(/^>.+/){|m|
|
55
|
+
m.green
|
56
|
+
}.gsub(/^(<.+?)$/){ |m|
|
57
|
+
m.red
|
58
|
+
}}"
|
59
|
+
end
|
60
|
+
|
61
|
+
# List differences between files in two directories
|
62
|
+
#
|
63
|
+
def test_missing_files(desc, dir1, dir2)
|
64
|
+
files1 = dir_files(dir1).map {|f| f.sub(dir1,'') }
|
65
|
+
files2 = dir_files(dir2).map {|f| f.sub(dir2,'') }
|
66
|
+
|
67
|
+
missing = []
|
68
|
+
|
69
|
+
(files2 - files1).each do |file|
|
70
|
+
missing << File.join(dir1, file)
|
71
|
+
end
|
72
|
+
|
73
|
+
(files1 - files2).each do |file|
|
74
|
+
missing << File.join(dir2, file)
|
75
|
+
end
|
76
|
+
|
77
|
+
if !missing.empty?
|
78
|
+
@failures << {
|
79
|
+
desc: "#{desc}\nMissing files:\n",
|
80
|
+
result: " - " + missing.join("\n - ")
|
81
|
+
}
|
82
|
+
|
83
|
+
pout 'F'.red
|
84
|
+
else
|
85
|
+
pout '.'.green
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# Diff two files
|
90
|
+
#
|
91
|
+
def diff_file(file1, file2)
|
92
|
+
diff = `diff #{file1} #{file2}`
|
93
|
+
if diff.size > 0
|
94
|
+
diff
|
95
|
+
else
|
96
|
+
false
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Test command output
|
101
|
+
#
|
102
|
+
# Input: options hash, format:
|
103
|
+
# {
|
104
|
+
# desc: description of task
|
105
|
+
# cmd: system command to be run, (String or Array)
|
106
|
+
# expect: expected output from command
|
107
|
+
# }
|
108
|
+
#
|
109
|
+
def test_cmd(options)
|
110
|
+
if cmd = options[:cmd]
|
111
|
+
cmd = [cmd] unless cmd.is_a? Array
|
112
|
+
|
113
|
+
# In debug mode command output is printed
|
114
|
+
#
|
115
|
+
if options[:debug]
|
116
|
+
system cmd.join('; ')
|
117
|
+
else
|
118
|
+
output = `#{cmd.join('; ')}`.gsub(/#{Dir.pwd}\/*/,'').strip
|
119
|
+
|
120
|
+
# Remove character color codes
|
121
|
+
output = output.gsub("\e",'').gsub(/\[\d+m/,'').gsub("\[0m",'')
|
122
|
+
end
|
123
|
+
if options[:expect] && options[:expect].strip == output
|
124
|
+
pout '.'.green
|
125
|
+
else
|
126
|
+
pout 'F'.red
|
127
|
+
@failures << {
|
128
|
+
desc: options[:desc]+"\n",
|
129
|
+
result: <<-HERE
|
130
|
+
expected: #{(options[:expect] || '').strip.green}
|
131
|
+
result: #{(output || '').strip.red}
|
132
|
+
HERE
|
133
|
+
}
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
# Print a single character without a newline
|
140
|
+
#
|
141
|
+
def pout(str)
|
142
|
+
print str
|
143
|
+
$stdout.flush
|
144
|
+
end
|
145
|
+
|
146
|
+
# Ouptut nicely formatted failure messages
|
147
|
+
#
|
148
|
+
def print_results
|
149
|
+
if !@failures.empty?
|
150
|
+
@failures.each do |test|
|
151
|
+
pout "\nFailed: #{test[:desc]}"
|
152
|
+
puts test[:result]
|
153
|
+
# print a newline for easier reading
|
154
|
+
puts ""
|
155
|
+
end
|
156
|
+
abort
|
157
|
+
else
|
158
|
+
puts "All passed!".green
|
159
|
+
end
|
160
|
+
end
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: octopress-asset-pipeline
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brandon Mathis
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: octopress
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octopress-ink
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0.rc.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.0.rc.1
|
69
|
+
description: Combine and compress CSS and Sass, Javascript and Coffeescript to a single
|
70
|
+
fingerprinted file.
|
71
|
+
email:
|
72
|
+
- brandon@imathis.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- LICENSE.txt
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- assets/docs/changelog.markdown
|
85
|
+
- assets/docs/index.markdown
|
86
|
+
- demo/Gemfile
|
87
|
+
- demo/_config.yml
|
88
|
+
- demo/_octopress.yml
|
89
|
+
- demo/_sass/_partial.sass
|
90
|
+
- demo/blah.js
|
91
|
+
- demo/foo.coffee
|
92
|
+
- demo/index.html
|
93
|
+
- demo/sass-test.scss
|
94
|
+
- demo/test.css
|
95
|
+
- lib/octopress-asset-pipeline.rb
|
96
|
+
- lib/octopress-asset-pipeline/assets/coffeescript.rb
|
97
|
+
- lib/octopress-asset-pipeline/assets/css.rb
|
98
|
+
- lib/octopress-asset-pipeline/assets/javascript.rb
|
99
|
+
- lib/octopress-asset-pipeline/assets/local.rb
|
100
|
+
- lib/octopress-asset-pipeline/assets/sass.rb
|
101
|
+
- lib/octopress-asset-pipeline/version.rb
|
102
|
+
- octopress-asset-pipeline.gemspec
|
103
|
+
- test/Gemfile
|
104
|
+
- test/_concat_false.yml
|
105
|
+
- test/_config.yml
|
106
|
+
- test/concat_false/blah.js
|
107
|
+
- test/concat_false/foo.js
|
108
|
+
- test/concat_false/index.html
|
109
|
+
- test/concat_false/sass-test.css
|
110
|
+
- test/concat_false/test.css
|
111
|
+
- test/expected/index.html
|
112
|
+
- test/expected/javascripts/all-.js
|
113
|
+
- test/expected/stylesheets/all-.css
|
114
|
+
- test/site/index.html
|
115
|
+
- test/site/javascripts/all-.js
|
116
|
+
- test/site/stylesheets/all-.css
|
117
|
+
- test/source/_sass/_partial.sass
|
118
|
+
- test/source/blah.js
|
119
|
+
- test/source/foo.coffee
|
120
|
+
- test/source/index.html
|
121
|
+
- test/source/sass-test.scss
|
122
|
+
- test/source/test.css
|
123
|
+
- test/test.rb
|
124
|
+
- test/test_suite.rb
|
125
|
+
homepage: https://github.com/octopress/asset-pipeline
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.2.2
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Combine and compress CSS and Sass, Javascript and Coffeescript to a single
|
149
|
+
fingerprinted file.
|
150
|
+
test_files:
|
151
|
+
- test/Gemfile
|
152
|
+
- test/_concat_false.yml
|
153
|
+
- test/_config.yml
|
154
|
+
- test/concat_false/blah.js
|
155
|
+
- test/concat_false/foo.js
|
156
|
+
- test/concat_false/index.html
|
157
|
+
- test/concat_false/sass-test.css
|
158
|
+
- test/concat_false/test.css
|
159
|
+
- test/expected/index.html
|
160
|
+
- test/expected/javascripts/all-.js
|
161
|
+
- test/expected/stylesheets/all-.css
|
162
|
+
- test/site/index.html
|
163
|
+
- test/site/javascripts/all-.js
|
164
|
+
- test/site/stylesheets/all-.css
|
165
|
+
- test/source/_sass/_partial.sass
|
166
|
+
- test/source/blah.js
|
167
|
+
- test/source/foo.coffee
|
168
|
+
- test/source/index.html
|
169
|
+
- test/source/sass-test.scss
|
170
|
+
- test/source/test.css
|
171
|
+
- test/test.rb
|
172
|
+
- test/test_suite.rb
|