octopress-ink 1.0.0.alpha.31 → 1.0.0.alpha.32

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