lib/octopress-ink/plugins.rb in octopress-ink-1.0.0.alpha.14 vs lib/octopress-ink/plugins.rb in octopress-ink-1.0.0.alpha.15
- old
+ new
@@ -19,12 +19,12 @@
def self.plugins
[@theme].concat(@plugins).concat(@local_plugins).compact
end
- def self.embed(name, file, site)
- plugin(name).embed(file, site)
+ def self.include(name, file, site)
+ plugin(name).include(file, site)
end
def self.register_plugin(plugin, name, type='plugin')
new_plugin = plugin.new(name, type)
@@ -51,16 +51,16 @@
paths = [paths] unless paths.is_a? Array
Digest::MD5.hexdigest(paths.clone.map! { |path| "#{File.mtime(path).to_i}" }.join)
end
def self.combined_stylesheet_path(media)
- File.join('stylesheets', "site-#{media}-#{@combined_stylesheets[media][:fingerprint]}.css")
+ File.join('stylesheets', "#{media}-#{@combined_stylesheets[media][:fingerprint]}.css")
end
def self.combined_javascript_path
print = @javascript_fingerprint || ''
- File.join('javascripts', "site-#{print}.js")
+ File.join('javascripts', "#{print}.js")
end
def self.write_files(site, source, dest)
site.static_files << StaticFileContent.new(source, dest)
end
@@ -163,25 +163,41 @@
unless combine_javascripts(site) == ''
"<script src='/#{combined_javascript_path}'></script>"
end
end
- def self.stylesheet_tags
- css = []
- plugins.each do |plugin|
- css.concat plugin.stylesheet_tags
- css.concat plugin.sass_tags
+ def self.stylesheet_tags(site)
+ if concat_css(site)
+ combined_stylesheet_tag(site)
+ else
+ css = []
+ plugins.each do |plugin|
+ css.concat plugin.stylesheet_tags
+ css.concat plugin.sass_tags
+ end
+ css
end
- css
end
- def self.javascript_tags
- js = []
- plugins.each do |plugin|
- js.concat plugin.javascript_tags
+ def self.concat_css(site)
+ site.config['octopress'] && site.config['octopress']['concat_css'] != false
+ end
+
+ def self.concat_js(site)
+ site.config['octopress'] && site.config['octopress']['concat_js'] != false
+ end
+
+ def self.javascript_tags(site)
+ if concat_js(site)
+ combined_javascript_tag(site)
+ else
+ js = []
+ plugins.each do |plugin|
+ js.concat plugin.javascript_tags
+ end
+ js
end
- js
end
def self.copy_javascripts(site)
plugins.each do |plugin|
copy(plugin.javascripts, site)
@@ -193,29 +209,37 @@
stylesheets = plugin.stylesheets.clone.concat plugin.sass
copy(stylesheets, site)
end
end
+ def self.local_sass_files(site)
+ if site.config['octopress'] && site.config['octopress']['sass'] && site.config['octopress']['sass']['files']
+ sass_files = site.config['octopress']['sass']['files'] || []
+ else
+ files = Dir.glob(File.join(site.source, 'stylesheets', '**/*.s[ca]ss')).reject { |f| File.basename(f) =~ /^_/ }
+ sass_files = files.map { |f| f.split('stylesheets/').last}
+ end
+ sass_files
+ end
+
def self.add_static_files(site)
- if site.config['sass'] and site.config['sass']['files']
- plugin('sass').add_files site.config['sass']['files']
- end
+ plugin('sass').add_files(local_sass_files(site))
# Copy/Generate Stylesheets
#
- if site.config['octopress'] && site.config['octopress']['combine_stylesheets'] != false
- copy_stylesheets(site)
- else
+ if concat_css(site)
write_combined_stylesheet(site)
+ else
+ copy_stylesheets(site)
end
# Copy/Generate Javascripts
#
- if site.config['octopress'] && site.config['octopress']['combine_javascripts'] != false
- copy_javascripts(site)
- else
+ if concat_js(site)
write_combined_javascript(site)
+ else
+ copy_javascripts(site)
end
# Copy other assets
#
copy_static_files(site)