lib/octopress-ink.rb in octopress-ink-1.0.0.rc.11 vs lib/octopress-ink.rb in octopress-ink-1.0.0.rc.13

- old
+ new

@@ -1,24 +1,42 @@ require 'jekyll' require 'sass' require 'uglifier' -require 'autoprefixer-rails' require 'digest/md5' -require 'jekyll-page-hooks' +require 'octopress' +require 'octopress-hooks' +require 'octopress-filters' require 'octopress-ink/version' -require 'octopress-ink/utils' -require 'octopress-ink/generators/plugin_assets' +require 'octopress-ink/configuration' require 'octopress-ink/jekyll/hooks' module Octopress + def self.site(options={}) + @site ||= init_site(options) + end + + def self.site=(site) + # Octopress historically used site.title + # This allows theme developers to expect site.name + # in consistancy with Jekyll's scaffold config + + site.config['name'] ||= site.config['title'] + + @site = site + end + + def self.init_site(options) + Jekyll.logger.log_level = :error + site = Jekyll::Site.new(Jekyll.configuration(options)) + Jekyll.logger.log_level = :info + site + end + module Ink - autoload :Configuration, 'octopress-ink/configuration' - autoload :Helpers, 'octopress-ink/helpers' - autoload :Filters, 'octopress-ink/filters' autoload :Assets, 'octopress-ink/assets' autoload :Page, 'octopress-ink/jekyll/page' autoload :StaticFile, 'octopress-ink/jekyll/static_file' autoload :StaticFileContent, 'octopress-ink/jekyll/static_file_content' autoload :Plugins, 'octopress-ink/plugins' @@ -57,73 +75,10 @@ def self.config @config ||= Configuration.config end - def self.site(options={}) - unless @site - @site ||= init_site(options) - end - - @site - end - - def self.site=(site) - # Octopress historically used site.title - # This allows theme developers to expect site.name - # in consistancy with Jekyll's scaffold config - site.config['name'] ||= site.config['title'] - - @site = site - end - - def self.payload(jekyll_payload={}) - Jekyll::Utils.deep_merge_hashes(jekyll_payload, custom_payload) - end - - def self.custom_payload - unless @custom_payload - config = Plugins.config - - payload = { - 'plugins' => config['plugins'], - 'theme' => config['theme'], - 'octopress' => { - 'version' => Octopress::Ink.version - }, - 'site' => { - 'linkposts' => self.linkposts, - 'articles' => self.articles, - } - } - - if Octopress::Ink.config['docs_mode'] - payload['doc_pages'] = Octopress::Ink::Plugins.doc_pages - end - - @custom_payload = payload - end - - @custom_payload - end - - def self.linkposts - @linkposts ||= site.posts.select {|p| p.data['linkpost']} - end - - def self.articles - @articles ||= site.posts.reject {|p| p.data['linkpost']} - end - - def self.init_site(options) - log_level = Jekyll.logger.log_level - Jekyll.logger.log_level = :error - site = Jekyll::Site.new(Jekyll.configuration(options)) - Jekyll.logger.log_level = log_level - site - end - def self.plugins Plugins.plugins end def self.plugin(name) @@ -142,11 +97,11 @@ # list of plugin names, slugs, versions, and descriptions, # but no assets, i.e. 'minimal' info. # # def self.list(options={}) - site(options) + Octopress.site(options) Plugins.register options = {'minimal'=>true} if options.empty? message = "Octopress Ink - v#{VERSION}\n" if plugins.size > 0 @@ -158,23 +113,28 @@ end puts message end def self.plugin_list(name, options) - site(options) + config = options.delete('config') # Jekyll conflicts with this option + Octopress.site(options) Plugins.register - options.delete('config') + options['config'] = config if config + if p = plugin(name) puts p.list(options) else not_found(name) end end def self.copy_plugin_assets(name, options) - site(options) + config = options.delete('config') # Jekyll conflicts with this option + Octopress.site(options) Plugins.register + options['config'] = config if config + path = copy_path(name, options) if p = plugin(name) copied = p.copy_asset_files(path, options) @@ -188,27 +148,27 @@ end end def self.copy_path(name, options) if path = options.delete('path') - full_path = File.join(Ink.site.source, path) + full_path = File.join(Dir.pwd, path) if !Dir["#{full_path}/*"].empty? && options['force'].nil? abort "Error: directory #{path} is not empty. Use --force to overwrite files." end else - full_path = File.join(Ink.site.source, Plugins.custom_dir, name) + full_path = File.join(Dir.pwd, Plugins.custom_dir, name) end full_path end def self.list_plugins(options={}) - site(options) + Octopress.site(options) Plugins.register puts "\nCurrently installed plugins:" if plugins.size > 0 - plugins.each { |plugin| puts plugin.name } + plugins.each { |plugin| puts plugin.name + " (#{plugin.slug})" } else puts "You have no plugins installed." end end @@ -248,24 +208,11 @@ yaml += "---" end end end -Liquid::Template.register_filter Octopress::Ink::Filters - -Liquid::Template.register_tag('include', Octopress::Ink::Tags::IncludeTag) -Liquid::Template.register_tag('assign', Octopress::Ink::Tags::AssignTag) -Liquid::Template.register_tag('capture', Octopress::Ink::Tags::CaptureTag) -Liquid::Template.register_tag('return', Octopress::Ink::Tags::ReturnTag) -Liquid::Template.register_tag('filter', Octopress::Ink::Tags::FilterTag) -Liquid::Template.register_tag('render', Octopress::Ink::Tags::RenderTag) -Liquid::Template.register_tag('css_asset_tag', Octopress::Ink::Tags::JavascriptTag) -Liquid::Template.register_tag('js_asset_tag', Octopress::Ink::Tags::StylesheetTag) -Liquid::Template.register_tag('content_for', Octopress::Ink::Tags::ContentForTag) -Liquid::Template.register_tag('yield', Octopress::Ink::Tags::YieldTag) -Liquid::Template.register_tag('wrap', Octopress::Ink::Tags::WrapTag) -Liquid::Template.register_tag('abort', Octopress::Ink::Tags::AbortTag) -Liquid::Template.register_tag('_', Octopress::Ink::Tags::LineCommentTag) +Liquid::Template.register_tag('css_asset_tag', Octopress::Ink::Tags::StylesheetTag) +Liquid::Template.register_tag('js_asset_tag', Octopress::Ink::Tags::JavascriptTag) Liquid::Template.register_tag('doc_url', Octopress::Ink::Tags::DocUrlTag) require 'octopress-ink/plugins/ink' Octopress::Ink.register_plugin(Octopress::Ink::InkPlugin)