lib/octopress-ink/plugin.rb in octopress-ink-1.0.0.alpha.35 vs lib/octopress-ink/plugin.rb in octopress-ink-1.0.0.alpha.36

- old
+ new

@@ -1,16 +1,16 @@ require 'find' module Octopress module Ink class Plugin - attr_accessor :name, :type, :assets_path, + attr_reader :name, :type, :assets_path, :layouts_dir, :css_dir, :javascripts_dir, :files_dir, :includes_dir, :images_dir, :layouts, :includes, :images, :fonts, :files, :pages, :docs, :website, :description, :version, :config - def initialize(name, type) + def initialize(slug, type) @layouts_dir = 'layouts' @files_dir = 'files' @pages_dir = 'pages' @docs_dir = 'docs' @fonts_dir = 'fonts' @@ -18,22 +18,23 @@ @includes_dir = 'includes' @javascripts_dir = 'javascripts' @css_dir = 'stylesheets' @sass_dir = 'stylesheets' @config_file = 'config.yml' - @name = name - @type = type @layouts = [] @includes = [] @css = [] @javascripts = [] @images = [] @sass = [] @docs = [] @fonts = [] @files = [] @pages = [] + @type = type + @slug = slug + @name ||= slug @version ||= false @description ||= false @website ||= false end @@ -82,18 +83,38 @@ def disabled?(dir, file) @config['disable'].include?(dir) || @config['disable'].include?(File.join(dir, file)) end def slug - @type == 'theme' ? @type : @name + @type == 'theme' ? @type : @slug end def docs_base_path type = @type == 'plugin' ? 'plugins' : @type - File.join('docs', type, @name) + File.join('docs', type, slug) end + # Docs pages for easy listing in an index + # + # returns: Array of hashes including doc page title and url + # + def doc_pages + if !@docs.empty? + @docs.clone.map do |d| + page_data = d.page.data + title = page_data['link_title'] || page_data['title'] + title ||= File.basename(d.file, '.*') + path = File.join(docs_base_path, d.file) + + { + 'title' => title, + 'path' => path + } + end + end + end + def can_disable [ 'pages', 'sass', 'css', @@ -136,9 +157,10 @@ name = "Plugin: #{@name}" name += " (theme)" if @type == 'theme' name += " - v#{@version}" if @version name = name message = name + message += "\nSlug: #{slug}" if @description message += "\n#{@description}" end