octopress-asset-pipeline 1.1.0 → 1.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/octopress-asset-pipeline/assets/coffeescript.rb +10 -12
- data/lib/octopress-asset-pipeline/assets/css.rb +10 -12
- data/lib/octopress-asset-pipeline/assets/javascript.rb +4 -6
- data/lib/octopress-asset-pipeline/assets/local.rb +26 -28
- data/lib/octopress-asset-pipeline/assets/sass.rb +19 -21
- data/lib/octopress-asset-pipeline/version.rb +2 -4
- data/lib/octopress-asset-pipeline.rb +106 -101
- data/octopress-asset-pipeline.gemspec +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: 60bc0ddd9493e3bda8bddd969d03ee41fa923af1
|
4
|
+
data.tar.gz: e602239f9f1cae6b17a20a8c4474b4cb7ed6fa1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81b371370acabfbe5d5c62d681d70f16a12b3038c441a032907ddcdcd8c7233cf64a9f4fea95756a84bfbe72ca50efcc074cda5a87355f20d071805b6ae51b8c
|
7
|
+
data.tar.gz: 5e29a2f9e986c3be0200204aa0695cd3049ba43665cd5f0a1bdbd5e10011fbbe1698a8768f5a0ec0cb644bed7a75ad0f93d4db226de2a41bee286c38787579c0
|
data/CHANGELOG.md
CHANGED
@@ -1,18 +1,16 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
2
|
+
module AssetPipeline
|
3
|
+
class Coffeescript < Javascript
|
4
|
+
def compile
|
5
|
+
::CoffeeScript.compile(file.content)
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def path
|
9
|
+
Pathname.new File.join(Octopress.site.source, file.path)
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
end
|
12
|
+
def destination
|
13
|
+
File.join(base, filename.sub(/\.coffee/,'.js'))
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
@@ -1,18 +1,16 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
2
|
+
module AssetPipeline
|
3
|
+
class Css < Asset
|
4
|
+
def media
|
5
|
+
path.to_s.scan(/@(.+?)\./).flatten[0] || 'all'
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def destination
|
9
|
+
File.join(base, filename.sub(/@(.+?)\./,'.'))
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
end
|
12
|
+
def tag
|
13
|
+
"<link href='#{Filters.expand_url(destination)}' media='#{media}' rel='stylesheet' type='text/css'>"
|
16
14
|
end
|
17
15
|
end
|
18
16
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
"<script src='#{Filters.expand_url(destination)}'></script>"
|
7
|
-
end
|
2
|
+
module AssetPipeline
|
3
|
+
class Javascript < Asset
|
4
|
+
def tag
|
5
|
+
"<script src='#{Filters.expand_url(destination)}'></script>"
|
8
6
|
end
|
9
7
|
end
|
10
8
|
end
|
@@ -1,38 +1,36 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def info
|
11
|
-
message = filename.ljust(35)
|
12
|
-
message += "from: #{base}"
|
13
|
-
" - #{message}"
|
14
|
-
end
|
2
|
+
module AssetPipeline
|
3
|
+
class Asset < Ink::Assets::Asset
|
4
|
+
def initialize(plugin, file)
|
5
|
+
@plugin = plugin
|
6
|
+
@file = file
|
7
|
+
end
|
15
8
|
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
def info
|
10
|
+
message = filename.ljust(35)
|
11
|
+
message += "from: #{base}"
|
12
|
+
" - #{message}"
|
13
|
+
end
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
|
15
|
+
def filename
|
16
|
+
File.basename(path)
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
def base
|
20
|
+
file.relative_path.sub(filename,'').sub(/^\/(.+)\/$/,'\1')
|
21
|
+
end
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
def destination
|
24
|
+
File.join(base, filename)
|
25
|
+
end
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
def copy(target_dir); end
|
27
|
+
def path
|
28
|
+
Pathname.new file.path
|
35
29
|
end
|
30
|
+
|
31
|
+
# Copy is unncessary with local assets
|
32
|
+
#
|
33
|
+
def copy(target_dir); end
|
36
34
|
end
|
37
35
|
end
|
38
36
|
end
|
@@ -1,30 +1,28 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
end
|
2
|
+
module AssetPipeline
|
3
|
+
class Sass < Css
|
4
|
+
def ext
|
5
|
+
file.ext
|
6
|
+
end
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
def path
|
9
|
+
Pathname.new File.join(Octopress.site.source, file.path)
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
def destination
|
13
|
+
super.sub(/\.s[ca]ss$/, '.css')
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
def add
|
17
|
+
Ink::Plugins.static_files << Ink::StaticFileContent.new(compile, destination)
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
def data
|
21
|
+
file.data
|
22
|
+
end
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
end
|
24
|
+
def compile
|
25
|
+
Ink::PluginAssetPipeline.compile_sass(self)
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -9,136 +9,141 @@ require 'octopress-asset-pipeline/assets/javascript'
|
|
9
9
|
require 'octopress-asset-pipeline/assets/coffeescript'
|
10
10
|
|
11
11
|
module Octopress
|
12
|
-
module
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
def register
|
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 Octopress.site.pages.empty? && Octopress.site.posts.empty?
|
34
|
-
Octopress.site.read_directories
|
35
|
-
end
|
12
|
+
module AssetPipeline
|
13
|
+
class Plugin < Ink::Plugin
|
14
|
+
def configuration
|
15
|
+
{
|
16
|
+
name: "Octopress Asset Pipeline",
|
17
|
+
path: File.expand_path(File.join(File.dirname(__FILE__), "../")),
|
18
|
+
type: "plugin",
|
19
|
+
version: Octopress::AssetPipeline::VERSION,
|
20
|
+
description: "Combine and compress CSS and Sass, Javascript and Coffeescript to a single fingerprinted file.",
|
21
|
+
source_url: "https://github.com/octopress/asset-pipeline",
|
22
|
+
local: true
|
23
|
+
}
|
24
|
+
end
|
36
25
|
|
37
|
-
|
38
|
-
|
26
|
+
def register
|
27
|
+
# Tell Jekyll to read static files and pages
|
28
|
+
# This is necessary when Jekyll isn't being asked to build a site,
|
29
|
+
# like when a user runs the list command to list assets
|
30
|
+
#
|
31
|
+
if ENV['OCTOPRESS_DOCS']
|
32
|
+
add_docs
|
33
|
+
else
|
34
|
+
add_files
|
39
35
|
end
|
36
|
+
end
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
38
|
+
def add_files
|
39
|
+
if Octopress.site.pages.empty? && Octopress.site.posts.empty?
|
40
|
+
Octopress.site.read_directories
|
45
41
|
end
|
46
42
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
43
|
+
add_stylesheets
|
44
|
+
add_javascripts
|
45
|
+
end
|
51
46
|
|
52
|
-
|
53
|
-
|
47
|
+
def config
|
48
|
+
@config ||= begin
|
49
|
+
Ink.configuration['asset_pipeline'].merge({'disable' => {}})
|
54
50
|
end
|
51
|
+
end
|
55
52
|
|
56
|
-
|
53
|
+
# Return stylesheets to be combined in the asset pipeline
|
54
|
+
def stylesheets
|
55
|
+
sort(@css.clone.concat(@sass), config['order_css'] || [])
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def javascripts
|
59
|
+
sort(@js.clone.concat(@coffee), config['order_js'] || [])
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
config['combine_css']
|
64
|
-
end
|
62
|
+
private
|
65
63
|
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
def combine_js
|
65
|
+
config['combine_js']
|
66
|
+
end
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
def combine_css
|
69
|
+
config['combine_css']
|
70
|
+
end
|
71
|
+
|
72
|
+
def add_stylesheets
|
73
|
+
add_css
|
74
|
+
add_sass
|
75
75
|
|
76
|
+
if !combine_css
|
77
|
+
# Add tags for {% css_asset_tag %}
|
78
|
+
stylesheets.each { |f| Ink::Plugins.add_css_tag(f.tag) }
|
79
|
+
@css.clear
|
76
80
|
end
|
77
81
|
|
78
|
-
|
79
|
-
add_js
|
80
|
-
add_coffee
|
82
|
+
end
|
81
83
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
84
|
+
def add_javascripts
|
85
|
+
add_js
|
86
|
+
add_coffee
|
87
|
+
|
88
|
+
if !combine_js
|
89
|
+
# Add tags for {% js_asset_tag %}
|
90
|
+
javascripts.each { |f| Ink::Plugins.add_js_tag(f.tag) }
|
91
|
+
@js.clear
|
92
|
+
@coffee.clear
|
88
93
|
end
|
94
|
+
end
|
89
95
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
end
|
96
|
+
def sort(files, config)
|
97
|
+
sorted = []
|
98
|
+
config.each do |item|
|
99
|
+
files.each do |file|
|
100
|
+
sorted << files.delete(file) if file.path.to_s.include? item
|
96
101
|
end
|
97
|
-
|
98
|
-
sorted.concat files
|
99
102
|
end
|
100
103
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
104
|
+
sorted.concat files
|
105
|
+
end
|
106
|
+
|
107
|
+
# Finds all Sass files registered by Jekyll
|
108
|
+
#
|
109
|
+
def add_sass
|
110
|
+
Octopress.site.pages.each do |f|
|
111
|
+
if f.ext =~ /\.s[ca]ss/
|
112
|
+
@sass << Sass.new(self, f)
|
113
|
+
Octopress.site.pages.delete(f)
|
109
114
|
end
|
110
115
|
end
|
116
|
+
end
|
111
117
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end
|
118
|
+
# Finds all CSS files registered by Jekyll
|
119
|
+
#
|
120
|
+
def add_css
|
121
|
+
Octopress.site.static_files.each do |f|
|
122
|
+
if f.path =~ /\.css$/
|
123
|
+
@css << Css.new(self, f)
|
124
|
+
Octopress.site.static_files.delete(f) if combine_css
|
120
125
|
end
|
121
126
|
end
|
127
|
+
end
|
122
128
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end
|
129
|
+
# Finds all Coffeescript files registered by Jekyll
|
130
|
+
#
|
131
|
+
def add_coffee
|
132
|
+
Octopress.site.pages.each do |f|
|
133
|
+
if f.ext =~ /\.coffee$/
|
134
|
+
@coffee << Coffeescript.new(self, f)
|
135
|
+
Octopress.site.pages.delete(f) if combine_js
|
131
136
|
end
|
132
137
|
end
|
138
|
+
end
|
133
139
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
end
|
140
|
+
# Finds all Javascript files registered by Jekyll
|
141
|
+
#
|
142
|
+
def add_js
|
143
|
+
Octopress.site.static_files.each do |f|
|
144
|
+
if f.path =~ /\.js$/
|
145
|
+
@js << Javascript.new(self, f)
|
146
|
+
Octopress.site.static_files.delete(f) if combine_js
|
142
147
|
end
|
143
148
|
end
|
144
149
|
end
|
@@ -146,4 +151,4 @@ module Octopress
|
|
146
151
|
end
|
147
152
|
end
|
148
153
|
|
149
|
-
Octopress::Ink.register_plugin(Octopress::
|
154
|
+
Octopress::Ink.register_plugin(Octopress::AssetPipeline::Plugin)
|
@@ -5,7 +5,7 @@ require 'octopress-asset-pipeline/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "octopress-asset-pipeline"
|
8
|
-
spec.version = Octopress::
|
8
|
+
spec.version = Octopress::AssetPipeline::VERSION
|
9
9
|
spec.authors = ["Brandon Mathis"]
|
10
10
|
spec.email = ["brandon@imathis.com"]
|
11
11
|
spec.summary = %q{Combine and compress CSS and Sass, Javascript and Coffeescript to a single fingerprinted file.}
|