octopress-asset-pipeline 1.1.7 → 2.0.0

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: 64ced752758764404dd6615c838cce1b38652f2b
4
- data.tar.gz: a158ae6dc1ec401c138c27122144f5be0cac02c4
3
+ metadata.gz: 9262a0c33a0c7c88bbe9306d6e7563c832cb172b
4
+ data.tar.gz: 160c46f0cfa00af04a5afcc573ef3aed152b9a58
5
5
  SHA512:
6
- metadata.gz: 61fa65441c3a9756af0b1265d69a419a0d72bbcf749e11e5eade3a47135bc3636ffa1d786a014a568eccc68d0e448641c2fc15b1954979baac834b6d6259cef6
7
- data.tar.gz: d4cc5d32193f506c8f5e7791528081af39b74ca2c30d79249980c068ca36c97566ee5233ffb40f973ca991b89dc1691c2f9ea10fd60c9e336667ef1063d2b248
6
+ metadata.gz: 6d6f0b53e2eb6fd4cc187cb304e8e47a06a95ac7c9508ff2e680b36ab44e7560ebe6231202746d8c5f26a8218e66a8b2fb909642d13138a95bc8e0d9f9007164
7
+ data.tar.gz: 5b7ae968ad75c3ef5e7cfa1671e947c71c86e4e9a7cc8790c210532c90ca1c08649b5c40baa5eb27e15a7f8c03a602852c2cff008289883de53bbe98605b57ca
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ### 2.0.0 - 2015-01-15
4
+
5
+ - Change: Reads stylesheets from: `css/` and `stylesheets/`.
6
+ - Change: Reads javascripts from: `js/` and `javascripts/`.
7
+ - New: set asset directories with configurations: `stylesheets_dir` and `javascripts_dir`.
8
+
3
9
  ### 1.1.7 - 2015-01-14
4
10
 
5
11
  - Minified js support - file.min.js isn't compressed again, and is added first to build.
data/README.md CHANGED
@@ -5,8 +5,7 @@ Combine and compress and fingerprint Stylesheets (CSS and Sass) and Javascripts
5
5
  [![Build Status](https://travis-ci.org/octopress/asset-pipeline.png?branch=master)](https://travis-ci.org/octopress/asset-pipeline)
6
6
  [![Gem Version](https://badge.fury.io/rb/octopress-asset-pipeline.png)](http://badge.fury.io/rb/octopress-asset-pipeline)
7
7
 
8
- **How it works:** This plugin will automatically search Jekyll's site index for .js, .coffee, .css, .scss and .sass
9
- files and combine, compress and fingerprint them so they're ready for deployment. Then add the liquid tags to your site layout to write
8
+ **How it works:** This plugin will automatically read .js, .coffee, .css, .scss and .sass files from your site, combine, compress and fingerprint them so they're ready for deployment. Then add the liquid tags to your site layout to write
10
9
  the necessary script or link tags.
11
10
 
12
11
  ## Installation
@@ -32,6 +31,18 @@ Then add the gem to your Jekyll configuration.
32
31
  gems:
33
32
  -octopress-asset-pipeline
34
33
 
34
+ ## Basic usage
35
+
36
+ This should be very simple to use.
37
+
38
+ 1. Ass Sass or CSS to `stylesheets/` or `css/` directory in your site's source.
39
+ 1. Ass Coffeescript or JS to `stylesheets/` or `css/` directory in your site's source.
40
+ 2. Put Coffeescript and JS in `[source]/javascripts/`.
41
+ 3. Add a liquid tags to your sites layout.
42
+ 4. Build.
43
+
44
+ If you want, you can configure which directories this plugin reads from. See the configuration section below.
45
+
35
46
  ## Liquid tags
36
47
 
37
48
  Include these tags in your site's layout.
@@ -41,7 +52,7 @@ Include these tags in your site's layout.
41
52
  {% js_asset_tag %}
42
53
  ```
43
54
 
44
- When Jekyll is compiled these will be replaced with something like this.
55
+ When Jekyll builds your site, these will be replaced with something like this.
45
56
 
46
57
  ```
47
58
  <link href='/stylesheets/all-b5c56f2652600cde201589531c453ba1.css' media='all' rel='stylesheet' type='text/css'>
@@ -55,6 +66,8 @@ the configurations are set in the `_config.yml` configuration file under the `as
55
66
 
56
67
  | Option | Description | Default |
57
68
  |:---------------------|:------------------------------------------|:------------|
69
+ | `stylesheets_dir` | Directory to read stylesheets from | ['css', 'stylesheets'] |
70
+ | `javascripts_dir` | Directory to read javascripts from | ['js', 'javascripts'] |
58
71
  | `combine_css` | Combine all .css, .scss and .sass files | true |
59
72
  | `combine_js` | Combine all .js and .coffee files | true |
60
73
  | `compress_css` | Compress stylesheets for production | true |
@@ -42,13 +42,19 @@ module Octopress
42
42
  Octopress.site.read_directories
43
43
  end
44
44
 
45
+ add_static_files
46
+ add_page_files
45
47
  add_stylesheets
46
48
  add_javascripts
47
49
  end
48
50
 
49
51
  def config
50
52
  @config ||= begin
51
- Ink.configuration['asset_pipeline'].merge({'disable' => {}})
53
+ c = Ink.configuration['asset_pipeline']
54
+ {
55
+ 'stylesheets_dir' => ['stylesheets', 'css'],
56
+ 'javascripts_dir' => ['javascripts', 'js']
57
+ }.merge(c).merge({ 'disable' => {} })
52
58
  end
53
59
  end
54
60
 
@@ -63,30 +69,31 @@ module Octopress
63
69
 
64
70
  private
65
71
 
66
- def combine_js
67
- config['combine_js']
72
+ def asset_dirs
73
+ [config['stylesheets_dir'], config['javascripts_dir']].flatten
74
+ end
75
+
76
+ def css_dirs
77
+ config['stylesheets_dir']
68
78
  end
69
79
 
70
80
  def combine_css
71
81
  config['combine_css']
72
82
  end
73
83
 
74
- def add_stylesheets
75
- add_css
76
- add_sass
84
+ def combine_js
85
+ config['combine_js']
86
+ end
77
87
 
88
+ def add_stylesheets
78
89
  if !combine_css
79
90
  # Add tags for {% css_asset_tag %}
80
91
  stylesheets.each { |f| Ink::Plugins.add_css_tag(f.tag) }
81
92
  @css.clear
82
93
  end
83
-
84
94
  end
85
95
 
86
96
  def add_javascripts
87
- add_js
88
- add_coffee
89
-
90
97
  if !combine_js
91
98
  # Add tags for {% js_asset_tag %}
92
99
  javascripts.each { |f| Ink::Plugins.add_js_tag(f.tag) }
@@ -106,53 +113,63 @@ module Octopress
106
113
  sorted.concat files
107
114
  end
108
115
 
109
- # Finds all Sass files registered by Jekyll
116
+ # Finds css and js files files registered by Jekyll
110
117
  #
111
- def add_sass
112
- Octopress.site.pages.dup.sort_by(&:path).each do |f|
113
- if f.ext =~ /\.s[ca]ss/
114
- @sass << Sass.new(self, f)
115
- Octopress.site.pages.delete(f)
116
- end
117
- end
118
- end
118
+ def add_static_files
119
+ find_static_assets(asset_dirs, '.js', '.css').each do |f|
120
+ if f.path =~ /\.js$/
121
+ if f.path =~ /\.min\.js$/i
122
+ @no_compress_js << Javascript.new(self, f)
123
+ else f.path =~ /\.js$/
124
+ @js << Javascript.new(self, f)
125
+ end
126
+ Octopress.site.static_files.delete(f) if combine_js
119
127
 
120
- # Finds all CSS files registered by Jekyll
121
- #
122
- def add_css
123
- Octopress.site.static_files.dup.sort_by(&:path).each do |f|
124
- if f.path =~ /\.css$/
128
+ elsif f.path =~ /\.css$/
125
129
  @css << Css.new(self, f)
126
130
  Octopress.site.static_files.delete(f) if combine_css
127
131
  end
128
132
  end
129
133
  end
130
134
 
131
- # Finds all Coffeescript files registered by Jekyll
135
+ # Finds Sass and Coffeescript files files registered by Jekyll
132
136
  #
133
- def add_coffee
134
- Octopress.site.pages.dup.sort_by(&:path).each do |f|
137
+ def add_page_files
138
+ find_page_assets(asset_dirs, '.scss', '.sass', '.coffee').each do |f|
135
139
  if f.ext =~ /\.coffee$/
136
140
  @coffee << Coffeescript.new(self, f)
137
141
  Octopress.site.pages.delete(f) if combine_js
142
+ elsif f.ext =~ /\.s[ca]ss/
143
+ @sass << Sass.new(self, f)
144
+ Octopress.site.pages.delete(f) if combine_css
138
145
  end
139
146
  end
140
147
  end
141
148
 
142
- # Finds all Javascript files registered by Jekyll
143
- #
144
- def add_js
145
- Octopress.site.static_files.dup.sort_by(&:path).each do |f|
146
- if f.path =~ /\.js$/
147
- if f.path =~ /\.min\.js$/i
148
- @no_compress_js << Javascript.new(self, f)
149
- else
150
- @js << Javascript.new(self, f)
151
- end
152
- Octopress.site.static_files.delete(f) if combine_js
149
+ def find_static_assets(dirs, *extensions)
150
+ assets = Octopress.site.static_files.dup.sort_by(&:path)
151
+ find_assets(assets, dirs, extensions)
152
+ end
153
+
154
+ def find_page_assets(dirs, *extensions)
155
+ assets = Octopress.site.pages.dup.sort_by(&:path)
156
+ find_assets(assets, dirs, extensions)
157
+ end
158
+
159
+ def find_assets(assets, dirs, extensions)
160
+ assets.select do |f|
161
+ if extensions.include?(File.extname(f.path))
162
+ path = f.path.sub(File.join(Octopress.site.source, ''), '')
163
+ in_dir?(path, dirs)
153
164
  end
154
165
  end
155
166
  end
167
+
168
+ def in_dir?(file, *dirs)
169
+ dirs.flatten.select do |d|
170
+ file.match(/^#{d}\//)
171
+ end.size > 0
172
+ end
156
173
  end
157
174
  end
158
175
  end
@@ -1,5 +1,5 @@
1
1
  module Octopress
2
2
  module AssetPipeline
3
- VERSION = "1.1.7"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopress-asset-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.7
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Mathis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octopress-ink