octopress-ink 1.0.0.alpha.31 → 1.0.0.alpha.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/octopress-ink.rb +92 -37
- data/lib/octopress-ink/assets.rb +12 -10
- data/lib/octopress-ink/assets/asset.rb +91 -80
- data/lib/octopress-ink/assets/config.rb +29 -27
- data/lib/octopress-ink/assets/include.rb +11 -9
- data/lib/octopress-ink/assets/javascript.rb +7 -4
- data/lib/octopress-ink/assets/layout.rb +16 -11
- data/lib/octopress-ink/assets/page.rb +32 -30
- data/lib/octopress-ink/assets/root.rb +17 -15
- data/lib/octopress-ink/assets/sass.rb +48 -46
- data/lib/octopress-ink/assets/stylesheet.rb +25 -23
- data/lib/octopress-ink/commands.rb +23 -0
- data/lib/octopress-ink/commands/helpers.rb +19 -0
- data/lib/octopress-ink/commands/info.rb +24 -0
- data/lib/octopress-ink/filters.rb +112 -109
- data/lib/octopress-ink/generators/plugin_assets.rb +8 -6
- data/lib/octopress-ink/helpers.rb +7 -5
- data/lib/octopress-ink/helpers/conditional.rb +16 -14
- data/lib/octopress-ink/helpers/content_for.rb +23 -20
- data/lib/octopress-ink/helpers/path.rb +51 -48
- data/lib/octopress-ink/helpers/var.rb +82 -80
- data/lib/octopress-ink/jekyll/hooks.rb +2 -2
- data/lib/octopress-ink/jekyll/page.rb +38 -35
- data/lib/octopress-ink/jekyll/static_file.rb +18 -16
- data/lib/octopress-ink/jekyll/static_file_content.rb +8 -6
- data/lib/octopress-ink/plugin.rb +189 -144
- data/lib/octopress-ink/plugins.rb +249 -230
- data/lib/octopress-ink/plugins/stylesheets.rb +37 -35
- data/lib/octopress-ink/tags.rb +16 -14
- data/lib/octopress-ink/tags/abort.rb +15 -12
- data/lib/octopress-ink/tags/assign.rb +21 -19
- data/lib/octopress-ink/tags/capture.rb +26 -24
- data/lib/octopress-ink/tags/content_for.rb +15 -12
- data/lib/octopress-ink/tags/filter.rb +16 -13
- data/lib/octopress-ink/tags/include.rb +40 -38
- data/lib/octopress-ink/tags/javascript.rb +6 -4
- data/lib/octopress-ink/tags/line_comment.rb +6 -3
- data/lib/octopress-ink/tags/render.rb +53 -51
- data/lib/octopress-ink/tags/return.rb +12 -9
- data/lib/octopress-ink/tags/stylesheet.rb +6 -4
- data/lib/octopress-ink/tags/wrap.rb +62 -60
- data/lib/octopress-ink/tags/yield.rb +23 -20
- data/lib/octopress-ink/version.rb +1 -1
- data/octopress-ink.gemspec +1 -1
- data/test/Gemfile +3 -2
- data/test/_config.yml +2 -0
- data/test/plugins/awesome-sauce/plugin.rb +3 -2
- data/test/plugins/test-theme/plugin.rb +3 -2
- metadata +7 -4
@@ -1,25 +1,27 @@
|
|
1
1
|
module Octopress
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
module Ink
|
3
|
+
class StaticFile
|
4
|
+
def initialize(source, dest)
|
5
|
+
@source = source
|
6
|
+
@dest = dest
|
7
|
+
end
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
def destination(dest)
|
10
|
+
File.join(dest, @dest)
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
def path
|
14
|
+
@source
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
def write(dest)
|
18
|
+
dest_path = destination(dest)
|
18
19
|
|
19
|
-
|
20
|
-
|
20
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
21
|
+
FileUtils.cp(@source, dest_path)
|
21
22
|
|
22
|
-
|
23
|
+
true
|
24
|
+
end
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
module Octopress
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
module Ink
|
3
|
+
class StaticFileContent < StaticFile
|
4
|
+
def write(dest)
|
5
|
+
dest_path = destination(dest)
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
FileUtils.mkdir_p(File.dirname(dest_path))
|
8
|
+
File.open(dest_path, 'w') { |f| f.write(@source) }
|
8
9
|
|
9
|
-
|
10
|
+
true
|
11
|
+
end
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
data/lib/octopress-ink/plugin.rb
CHANGED
@@ -1,190 +1,235 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
1
3
|
module Octopress
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
4
|
+
module Ink
|
5
|
+
class Plugin
|
6
|
+
attr_accessor :name, :type, :asset_override, :assets_path,
|
7
|
+
:layouts_dir, :stylesheets_dir, :javascripts_dir, :files_dir, :includes_dir, :images_dir,
|
8
|
+
:layouts, :includes, :stylesheets, :javascripts, :images, :sass, :fonts, :files, :pages,
|
9
|
+
:website, :description, :version
|
10
|
+
|
11
|
+
def initialize(name, type)
|
12
|
+
@layouts_dir = 'layouts'
|
13
|
+
@files_dir = 'files'
|
14
|
+
@pages_dir = 'pages'
|
15
|
+
@fonts_dir = 'fonts'
|
16
|
+
@images_dir = 'images'
|
17
|
+
@includes_dir = 'includes'
|
18
|
+
@javascripts_dir = 'javascripts'
|
19
|
+
@stylesheets_dir = 'stylesheets'
|
20
|
+
@plugins_dir = 'plugins'
|
21
|
+
@config_file = 'config.yml'
|
22
|
+
@name = name
|
23
|
+
@type = type
|
24
|
+
@layouts = []
|
25
|
+
@includes = {}
|
26
|
+
@stylesheets = []
|
27
|
+
@javascripts = []
|
28
|
+
@images = []
|
29
|
+
@sass = []
|
30
|
+
@fonts = []
|
31
|
+
@files = []
|
32
|
+
@pages = []
|
33
|
+
@version ||= false
|
34
|
+
@description ||= false
|
35
|
+
@website ||= false
|
36
|
+
add_assets
|
37
|
+
add_layouts
|
38
|
+
add_pages
|
39
|
+
add_includes
|
40
|
+
add_config
|
41
|
+
require_plugins
|
42
|
+
end
|
36
43
|
|
37
|
-
|
44
|
+
def add_assets; end
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
def add_config
|
47
|
+
@config_file = Assets::Config.new(self, @config_file)
|
48
|
+
end
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
50
|
+
def slug
|
51
|
+
if @type == 'local_plugin'
|
52
|
+
''
|
53
|
+
else
|
54
|
+
@type == 'theme' ? @type : @name
|
55
|
+
end
|
48
56
|
end
|
49
|
-
end
|
50
57
|
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
def assets
|
59
|
+
{
|
60
|
+
'layouts' => @layouts,
|
61
|
+
'includes' => @includes.values,
|
62
|
+
'pages' => @pages,
|
63
|
+
'sass' => @sass,
|
64
|
+
'stylesheets' => @stylesheets,
|
65
|
+
'javascripts' => @javascripts,
|
66
|
+
'images' => @images,
|
67
|
+
'fonts' => @fonts,
|
68
|
+
'files' => @files
|
69
|
+
}
|
70
|
+
end
|
54
71
|
|
55
|
-
|
56
|
-
|
57
|
-
|
72
|
+
def info(options={})
|
73
|
+
message = @name
|
74
|
+
message += " (theme)" if @type == 'theme'
|
75
|
+
message += " - v#{@version}" if @version
|
76
|
+
message += " - #{@description}" if @description
|
77
|
+
message += "\n"
|
78
|
+
if options == {}
|
79
|
+
asset_types = assets
|
80
|
+
else
|
81
|
+
asset_types = assets.select{|k,v| options.keys.include?(k)}
|
82
|
+
end
|
83
|
+
asset_types.each do |name, assets|
|
84
|
+
if assets.size > 0
|
85
|
+
message += "#{name.capitalize}:\n"
|
86
|
+
assets.each do |t|
|
87
|
+
message += " - #{t.info}\n"
|
88
|
+
end
|
89
|
+
elsif options != {}
|
90
|
+
message += "#{name.capitalize}: none\n"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
message
|
94
|
+
end
|
58
95
|
|
59
|
-
|
60
|
-
|
61
|
-
|
96
|
+
def add_stylesheet(file, media=nil)
|
97
|
+
@stylesheets << Assets::Stylesheet.new(self, @stylesheets_dir, file, media)
|
98
|
+
end
|
99
|
+
|
100
|
+
def add_sass(file, media=nil)
|
101
|
+
@sass << Assets::Sass.new(self, @stylesheets_dir, file, media)
|
102
|
+
end
|
62
103
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@
|
104
|
+
def add_javascript(file)
|
105
|
+
@javascripts << Assets::Javascript.new(self, @javascripts_dir, file)
|
106
|
+
end
|
107
|
+
|
108
|
+
def add_pages
|
109
|
+
if @assets_path
|
110
|
+
find_assets(File.join(@assets_path, @pages_dir)).each do |file|
|
111
|
+
@pages << Assets::PageAsset.new(self, @pages_dir, file)
|
71
112
|
end
|
72
113
|
end
|
73
114
|
end
|
74
|
-
end
|
75
115
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
entries = []
|
80
|
-
if Dir.exists?(base)
|
81
|
-
Dir.chdir(base) { entries = Dir['**/*.rb'] }
|
82
|
-
entries.each do |file|
|
116
|
+
def require_plugins
|
117
|
+
if @assets_path
|
118
|
+
find_assets(File.join(@assets_path, @plugins_dir)).each do |file|
|
83
119
|
require File.join base, file
|
84
120
|
end
|
85
121
|
end
|
86
122
|
end
|
87
|
-
end
|
88
123
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
Dir.chdir(base) { entries = Dir['**/*.*'] }
|
95
|
-
entries.each do |file|
|
96
|
-
@layouts << Assets::Layout.new(self, @layouts_dir, file)
|
124
|
+
def find_assets(dir)
|
125
|
+
found = []
|
126
|
+
if Dir.exist? dir
|
127
|
+
Find.find(dir) do |file|
|
128
|
+
found << file.sub(dir+'/', '') unless File.directory? file
|
97
129
|
end
|
98
130
|
end
|
131
|
+
found
|
99
132
|
end
|
100
|
-
end
|
101
133
|
|
102
|
-
|
103
|
-
|
104
|
-
|
134
|
+
def add_layouts
|
135
|
+
if @assets_path
|
136
|
+
find_assets(File.join(@assets_path, @layouts_dir)).each do |layout|
|
137
|
+
@layouts << Assets::Layout.new(self, @layouts_dir, layout)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
105
141
|
|
106
|
-
|
107
|
-
|
108
|
-
|
142
|
+
def remove_jekyll_assets(files)
|
143
|
+
files.each {|f| f.remove_jekyll_asset }
|
144
|
+
end
|
109
145
|
|
110
|
-
|
111
|
-
|
112
|
-
|
146
|
+
def add_includes
|
147
|
+
if @assets_path
|
148
|
+
find_assets(File.join(@assets_path, @includes_dir)).each do |include_file|
|
149
|
+
@includes[include_file] = Assets::Asset.new(self, @includes_dir, include_file)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
113
153
|
|
114
|
-
|
115
|
-
|
116
|
-
|
154
|
+
def add_image(file)
|
155
|
+
@images << Assets::Asset.new(self, @images_dir, file)
|
156
|
+
end
|
117
157
|
|
118
|
-
|
119
|
-
|
120
|
-
|
158
|
+
def add_root_files(files)
|
159
|
+
files.each { |f| add_root_file(f) }
|
160
|
+
end
|
121
161
|
|
122
|
-
|
123
|
-
|
124
|
-
|
162
|
+
def add_root_file(file)
|
163
|
+
@files << Assets::RootAsset.new(self, @files_dir, file)
|
164
|
+
end
|
125
165
|
|
126
|
-
|
127
|
-
|
128
|
-
|
166
|
+
def add_font(file)
|
167
|
+
@fonts << Assets::Asset.new(self, @fonts_dir, file)
|
168
|
+
end
|
129
169
|
|
130
|
-
|
131
|
-
|
132
|
-
|
170
|
+
def add_file(file)
|
171
|
+
@files << Assets::Asset.new(self, @files_dir, file)
|
172
|
+
end
|
133
173
|
|
134
|
-
|
135
|
-
|
136
|
-
|
174
|
+
def add_stylesheets(files, media=nil)
|
175
|
+
files.each { |f| add_stylesheet(f, media) }
|
176
|
+
end
|
137
177
|
|
138
|
-
|
139
|
-
|
140
|
-
|
178
|
+
def add_sass_files(files, media=nil)
|
179
|
+
files.each { |f| add_sass(f, media) }
|
180
|
+
end
|
141
181
|
|
142
|
-
|
143
|
-
|
144
|
-
|
182
|
+
def add_javascripts(files)
|
183
|
+
files.each { |f| add_javascript(f) }
|
184
|
+
end
|
145
185
|
|
146
|
-
|
147
|
-
|
148
|
-
|
186
|
+
def add_images(files)
|
187
|
+
files.each { |f| add_image(f) }
|
188
|
+
end
|
149
189
|
|
150
|
-
|
151
|
-
|
152
|
-
|
190
|
+
def add_fonts(files)
|
191
|
+
files.each { |f| add_font(f) }
|
192
|
+
end
|
153
193
|
|
154
|
-
|
155
|
-
|
156
|
-
|
194
|
+
def add_files(files)
|
195
|
+
files.each { |f| add_file(f) }
|
196
|
+
end
|
157
197
|
|
158
|
-
|
159
|
-
|
160
|
-
|
198
|
+
def stylesheet_paths
|
199
|
+
get_paths @stylesheets
|
200
|
+
end
|
161
201
|
|
162
|
-
|
163
|
-
|
164
|
-
|
202
|
+
def javascript_paths
|
203
|
+
get_paths @javascripts
|
204
|
+
end
|
165
205
|
|
166
|
-
|
167
|
-
|
168
|
-
|
206
|
+
def stylesheet_tags
|
207
|
+
get_tags @stylesheets
|
208
|
+
end
|
169
209
|
|
170
|
-
|
171
|
-
|
172
|
-
|
210
|
+
def sass_tags
|
211
|
+
get_tags @sass
|
212
|
+
end
|
173
213
|
|
174
|
-
|
175
|
-
|
176
|
-
|
214
|
+
def javascript_tags
|
215
|
+
get_tags @javascripts
|
216
|
+
end
|
177
217
|
|
178
|
-
|
179
|
-
|
180
|
-
|
218
|
+
def get_paths(files)
|
219
|
+
files.dup.map { |f| f.path }
|
220
|
+
end
|
181
221
|
|
182
|
-
|
183
|
-
|
184
|
-
|
222
|
+
def get_tags(files)
|
223
|
+
files.dup.map { |f| f.tag }
|
224
|
+
end
|
225
|
+
|
226
|
+
def include(file)
|
227
|
+
@includes[file].path
|
228
|
+
end
|
185
229
|
|
186
|
-
|
187
|
-
|
230
|
+
def config
|
231
|
+
@config ||= @config_file.read
|
232
|
+
end
|
188
233
|
end
|
189
234
|
end
|
190
235
|
end
|
@@ -1,299 +1,318 @@
|
|
1
1
|
module Octopress
|
2
|
-
module
|
2
|
+
module Ink
|
3
|
+
module Plugins
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
5
|
+
@plugins = []
|
6
|
+
@local_plugins = []
|
7
|
+
@site = nil
|
7
8
|
|
8
|
-
|
9
|
-
@theme
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.plugin(name)
|
13
|
-
if name == 'theme'
|
9
|
+
def self.theme
|
14
10
|
@theme
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.each(&block)
|
14
|
+
plugins.each(&block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.size
|
18
|
+
plugins.size
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.plugin(name)
|
22
|
+
if name == 'theme'
|
23
|
+
@theme
|
24
|
+
else
|
25
|
+
found = plugins.reject { |p| p.name != name }
|
26
|
+
if found.empty?
|
27
|
+
raise IOError.new "No Theme or Plugin with the name '#{name}' was found."
|
28
|
+
end
|
29
|
+
found.first
|
19
30
|
end
|
20
|
-
found.first
|
21
31
|
end
|
22
|
-
end
|
23
32
|
|
24
|
-
|
25
|
-
|
26
|
-
|
33
|
+
def self.plugins
|
34
|
+
[@theme].concat(@plugins).concat(@local_plugins).compact
|
35
|
+
end
|
27
36
|
|
28
|
-
|
29
|
-
|
30
|
-
|
37
|
+
def self.site=(site)
|
38
|
+
@site = site
|
39
|
+
end
|
31
40
|
|
32
|
-
|
33
|
-
|
34
|
-
|
41
|
+
def self.site
|
42
|
+
@site
|
43
|
+
end
|
35
44
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
def self.config
|
46
|
+
if @config
|
47
|
+
@config
|
48
|
+
else
|
49
|
+
@config = {}
|
50
|
+
@config['plugins'] = {}
|
51
|
+
@config['theme'] = @theme.nil? ? {} : @theme.config
|
43
52
|
|
44
53
|
|
45
|
-
|
46
|
-
|
47
|
-
|
54
|
+
plugins.each do |p|
|
55
|
+
unless p == @theme
|
56
|
+
@config['plugins'][p.name] = p.config
|
57
|
+
end
|
48
58
|
end
|
59
|
+
|
60
|
+
@config
|
49
61
|
end
|
62
|
+
end
|
50
63
|
|
51
|
-
|
64
|
+
def self.include(name, file)
|
65
|
+
p = plugin(name)
|
66
|
+
p.include(file)
|
52
67
|
end
|
53
|
-
end
|
54
68
|
|
55
|
-
|
56
|
-
|
57
|
-
p.include(file)
|
58
|
-
end
|
69
|
+
def self.register_plugin(plugin, name, type='plugin')
|
70
|
+
new_plugin = plugin.new(name, type)
|
59
71
|
|
60
|
-
|
61
|
-
|
72
|
+
case type
|
73
|
+
when 'theme'
|
74
|
+
@theme = new_plugin
|
75
|
+
when 'local_plugin'
|
76
|
+
@local_plugins << new_plugin
|
77
|
+
else
|
78
|
+
@plugins << new_plugin
|
79
|
+
end
|
80
|
+
end
|
62
81
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@local_plugins << new_plugin
|
68
|
-
else
|
69
|
-
@plugins << new_plugin
|
82
|
+
def self.register_layouts
|
83
|
+
plugins.each do |p|
|
84
|
+
p.layouts.clone.each { |layout| layout.register }
|
85
|
+
end
|
70
86
|
end
|
71
|
-
end
|
72
87
|
|
73
|
-
|
74
|
-
|
75
|
-
|
88
|
+
def self.layouts
|
89
|
+
names = []
|
90
|
+
plugins.each do |p|
|
91
|
+
p.layouts.each { |layout| names << layout.name }
|
92
|
+
end
|
93
|
+
names
|
76
94
|
end
|
77
|
-
end
|
78
95
|
|
79
|
-
|
80
|
-
|
81
|
-
|
96
|
+
def self.custom_dir
|
97
|
+
@site.config['plugins']
|
98
|
+
end
|
82
99
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
100
|
+
def self.fingerprint(paths)
|
101
|
+
paths = [paths] unless paths.is_a? Array
|
102
|
+
Digest::MD5.hexdigest(paths.clone.map! { |path| "#{File.mtime(path).to_i}" }.join)
|
103
|
+
end
|
104
|
+
|
105
|
+
def self.combined_stylesheet_path(media)
|
106
|
+
File.join('stylesheets', "#{media}-#{@combined_stylesheets[media][:fingerprint]}.css")
|
107
|
+
end
|
91
108
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
109
|
+
def self.combined_javascript_path
|
110
|
+
print = @javascript_fingerprint || ''
|
111
|
+
File.join('javascripts', "#{print}.js")
|
112
|
+
end
|
96
113
|
|
97
|
-
|
98
|
-
|
99
|
-
|
114
|
+
def self.write_files(source, dest)
|
115
|
+
@site.static_files << StaticFileContent.new(source, dest)
|
116
|
+
end
|
100
117
|
|
101
|
-
|
102
|
-
|
103
|
-
|
118
|
+
def self.compile_sass_file(path, options)
|
119
|
+
::Sass.compile_file(path, options)
|
120
|
+
end
|
104
121
|
|
105
|
-
|
106
|
-
|
107
|
-
|
122
|
+
def self.compile_sass(contents, options)
|
123
|
+
::Sass.compile(contents, options)
|
124
|
+
end
|
108
125
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
126
|
+
def self.sass_config(item, default)
|
127
|
+
config = @site.config
|
128
|
+
if config['octopress'] && config['octopress']['sass'] && config['octopress']['sass'][item]
|
129
|
+
config['octopress']['sass'][item]
|
130
|
+
else
|
131
|
+
default
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.sass_options
|
136
|
+
options = {
|
137
|
+
style: sass_config('output_style', 'compressed').to_sym,
|
138
|
+
trace: sass_config('trace', false),
|
139
|
+
line_numbers: sass_config('line_numbers', false)
|
140
|
+
}
|
115
141
|
end
|
116
|
-
end
|
117
|
-
|
118
|
-
def self.sass_options
|
119
|
-
options = {
|
120
|
-
style: sass_config('output_style', 'compressed').to_sym,
|
121
|
-
trace: sass_config('trace', false),
|
122
|
-
line_numbers: sass_config('line_numbers', false)
|
123
|
-
}
|
124
|
-
end
|
125
142
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
143
|
+
def self.write_combined_stylesheet
|
144
|
+
css = combine_stylesheets
|
145
|
+
css.keys.each do |media|
|
146
|
+
options = sass_options
|
147
|
+
options[:line_numbers] = false
|
148
|
+
contents = compile_sass(css[media][:contents], options)
|
149
|
+
write_files(contents, combined_stylesheet_path(media))
|
150
|
+
end
|
133
151
|
end
|
134
|
-
end
|
135
152
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
153
|
+
def self.write_combined_javascript
|
154
|
+
js = combine_javascripts
|
155
|
+
write_files(js, combined_javascript_path) unless js == ''
|
156
|
+
end
|
140
157
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
else
|
149
|
-
plugin_header = "/* Plugin: #{plugin.name} */\n"
|
150
|
-
end
|
151
|
-
stylesheets = plugin.stylesheets.clone.concat plugin.sass
|
152
|
-
stylesheets.each do |file|
|
153
|
-
css[file.media] ||= {}
|
154
|
-
css[file.media][:contents] ||= ''
|
155
|
-
css[file.media][:contents] << plugin_header
|
156
|
-
css[file.media][:paths] ||= []
|
157
|
-
|
158
|
-
# Add Sass files
|
159
|
-
if file.respond_to? :compile
|
160
|
-
css[file.media][:contents].concat file.compile
|
158
|
+
def self.combine_stylesheets
|
159
|
+
unless @combined_stylesheets
|
160
|
+
css = {}
|
161
|
+
paths = {}
|
162
|
+
plugins.each do |plugin|
|
163
|
+
if plugin.type == 'theme'
|
164
|
+
plugin_header = "/* Theme: #{plugin.name} */\n"
|
161
165
|
else
|
162
|
-
|
166
|
+
plugin_header = "/* Plugin: #{plugin.name} */\n"
|
167
|
+
end
|
168
|
+
stylesheets = plugin.stylesheets.clone.concat plugin.sass
|
169
|
+
stylesheets.each do |file|
|
170
|
+
css[file.media] ||= {}
|
171
|
+
css[file.media][:contents] ||= ''
|
172
|
+
css[file.media][:contents] << plugin_header
|
173
|
+
css[file.media][:paths] ||= []
|
174
|
+
|
175
|
+
# Add Sass files
|
176
|
+
if file.respond_to? :compile
|
177
|
+
css[file.media][:contents].concat file.compile
|
178
|
+
else
|
179
|
+
css[file.media][:contents].concat file.path.read.strip
|
180
|
+
end
|
181
|
+
css[file.media][:paths] << file.path
|
182
|
+
plugin_header = ''
|
163
183
|
end
|
164
|
-
css[file.media][:paths] << file.path
|
165
|
-
plugin_header = ''
|
166
184
|
end
|
167
|
-
end
|
168
185
|
|
169
|
-
|
170
|
-
|
186
|
+
css.keys.each do |media|
|
187
|
+
css[media][:fingerprint] = fingerprint(css[media][:paths])
|
188
|
+
end
|
189
|
+
@combined_stylesheets = css
|
171
190
|
end
|
172
|
-
@combined_stylesheets
|
191
|
+
@combined_stylesheets
|
173
192
|
end
|
174
|
-
@combined_stylesheets
|
175
|
-
end
|
176
193
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
194
|
+
def self.combine_javascripts
|
195
|
+
unless @combined_javascripts
|
196
|
+
js = ''
|
197
|
+
plugins.each do |plugin|
|
198
|
+
paths = plugin.javascript_paths
|
199
|
+
@javascript_fingerprint = fingerprint(paths)
|
200
|
+
paths.each do |file|
|
201
|
+
js.concat Pathname.new(file).read
|
202
|
+
end
|
185
203
|
end
|
204
|
+
@combined_javascripts = js
|
186
205
|
end
|
187
|
-
@combined_javascripts
|
206
|
+
@combined_javascripts
|
188
207
|
end
|
189
|
-
@combined_javascripts
|
190
|
-
end
|
191
208
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
209
|
+
def self.combined_stylesheet_tag
|
210
|
+
tags = ''
|
211
|
+
combine_stylesheets.keys.each do |media|
|
212
|
+
tags.concat "<link href='#{Filters.expand_url(combined_stylesheet_path(media))}' media='#{media}' rel='stylesheet' type='text/css'>"
|
213
|
+
end
|
214
|
+
tags
|
196
215
|
end
|
197
|
-
tags
|
198
|
-
end
|
199
216
|
|
200
|
-
|
201
|
-
|
202
|
-
|
217
|
+
def self.combined_javascript_tag
|
218
|
+
unless combine_javascripts == ''
|
219
|
+
"<script src='#{Filters.expand_url(combined_javascript_path)}'></script>"
|
220
|
+
end
|
203
221
|
end
|
204
|
-
end
|
205
222
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
223
|
+
def self.stylesheet_tags
|
224
|
+
if concat_css
|
225
|
+
combined_stylesheet_tag
|
226
|
+
else
|
227
|
+
css = []
|
228
|
+
plugins.each do |plugin|
|
229
|
+
css.concat plugin.stylesheet_tags
|
230
|
+
css.concat plugin.sass_tags
|
231
|
+
end
|
232
|
+
css
|
214
233
|
end
|
215
|
-
css
|
216
234
|
end
|
217
|
-
end
|
218
235
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
236
|
+
def self.concat_css
|
237
|
+
config = @site.config
|
238
|
+
if config['octopress'] && !config['octopress']['concat_css'].nil?
|
239
|
+
config['octopress']['concat_css'] != false
|
240
|
+
else
|
241
|
+
true
|
242
|
+
end
|
225
243
|
end
|
226
|
-
end
|
227
244
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
245
|
+
def self.concat_js
|
246
|
+
config = @site.config
|
247
|
+
if config['octopress'] && !config['octopress']['concat_js'].nil?
|
248
|
+
config['octopress']['concat_js'] != false
|
249
|
+
else
|
250
|
+
true
|
251
|
+
end
|
234
252
|
end
|
235
|
-
end
|
236
253
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
254
|
+
def self.javascript_tags
|
255
|
+
if concat_js
|
256
|
+
combined_javascript_tag
|
257
|
+
else
|
258
|
+
js = []
|
259
|
+
plugins.each do |plugin|
|
260
|
+
js.concat plugin.javascript_tags
|
261
|
+
end
|
262
|
+
js
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def self.copy_javascripts
|
242
267
|
plugins.each do |plugin|
|
243
|
-
|
268
|
+
copy plugin.javascripts
|
244
269
|
end
|
245
|
-
js
|
246
270
|
end
|
247
|
-
end
|
248
271
|
|
249
|
-
|
250
|
-
|
251
|
-
|
272
|
+
def self.copy_stylesheets
|
273
|
+
stylesheets = plugins.clone.map {
|
274
|
+
|p| p.stylesheets.clone.concat(p.sass)
|
275
|
+
}.flatten
|
276
|
+
copy stylesheets
|
252
277
|
end
|
253
|
-
end
|
254
278
|
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
279
|
+
def self.add_static_files
|
280
|
+
|
281
|
+
plugin('user stylesheets').add_files
|
282
|
+
|
283
|
+
# Copy/Generate Stylesheets
|
284
|
+
#
|
285
|
+
if concat_css
|
286
|
+
write_combined_stylesheet
|
287
|
+
else
|
288
|
+
copy_stylesheets
|
289
|
+
end
|
261
290
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
write_combined_stylesheet
|
270
|
-
else
|
271
|
-
copy_stylesheets
|
272
|
-
end
|
273
|
-
|
274
|
-
# Copy/Generate Javascripts
|
275
|
-
#
|
276
|
-
if concat_js
|
277
|
-
write_combined_javascript
|
278
|
-
else
|
279
|
-
copy_javascripts
|
280
|
-
end
|
281
|
-
|
282
|
-
# Copy other assets
|
283
|
-
#
|
284
|
-
copy_static_files
|
285
|
-
end
|
291
|
+
# Copy/Generate Javascripts
|
292
|
+
#
|
293
|
+
if concat_js
|
294
|
+
write_combined_javascript
|
295
|
+
else
|
296
|
+
copy_javascripts
|
297
|
+
end
|
286
298
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
copy plugin.images
|
291
|
-
copy plugin.fonts
|
299
|
+
# Copy other assets
|
300
|
+
#
|
301
|
+
copy_static_files
|
292
302
|
end
|
293
|
-
end
|
294
303
|
|
295
|
-
|
296
|
-
|
304
|
+
def self.copy_static_files
|
305
|
+
plugins.each do |plugin|
|
306
|
+
copy plugin.files
|
307
|
+
copy plugin.pages
|
308
|
+
copy plugin.images
|
309
|
+
copy plugin.fonts
|
310
|
+
end
|
311
|
+
end
|
312
|
+
|
313
|
+
def self.copy(files)
|
314
|
+
files.each { |f| f.copy }
|
315
|
+
end
|
297
316
|
end
|
298
317
|
end
|
299
318
|
end
|