lib/octopress-docs/doc.rb in octopress-docs-0.0.11 vs lib/octopress-docs/doc.rb in octopress-docs-0.0.12

- old
+ new

@@ -1,13 +1,13 @@ module Octopress module Docs class Doc - attr_reader :filename, :plugin_name, :base_url, :plugin_type, :description, :source_url + attr_reader :filename, :plugin_name, :plugin_slug, :base_url, :plugin_type, :description, :source_url def initialize(options={}) @file = options[:file] - @dir = options[:dir] ||= '.' + @path = options[:path] ||= '.' @file_dir = File.dirname(@file) @plugin_name = options[:name] @plugin_slug = options[:slug] @plugin_type = options[:type] @base_url = options[:base_url] @@ -34,18 +34,21 @@ " - #{permalink.ljust(35)}" end def page return @page if @page - @page = Octopress::Docs::Page.new(Octopress.site, @dir, page_dir, file, {'path'=>@base_url}) + @page = Octopress::Docs::Page.new(Octopress.site, @path, page_dir, file, {'path'=>@base_url}) @page.data['layout'] = 'docs' + @page.data['escape_code'] = true + @page.data['plugin'] = { - 'name' => @plugin_name, - 'slug' => plugin_slug, - 'docs_base_url' => @base_url, - 'source_url' => @source_url, - 'description' => @description + 'name' => @plugin_name, + 'slug' => @plugin_slug, + 'type' => @plugin_type, + 'source_url' => @source_url, + 'description' => @description, + 'url' => @base_url } @page.data['dir'] = doc_dir @page.data = @data.merge(@page.data) @page.data.merge!(comment_yaml(@page.content)) @@ -57,11 +60,11 @@ def permalink File.basename(file, ".*") end def read - File.open(File.join(@dir, @file)).read + File.open(File.join(@path, @file)).read end def plugin_slug Jekyll::Utils.slugify(@plugin_type == 'theme' ? 'theme' : @plugin_slug) end @@ -69,10 +72,10 @@ def page_dir @file_dir == '.' ? '' : @file_dir end def doc_dir - File.join(@dir, page_dir, File.dirname(@file)) + File.join(@path, page_dir, File.dirname(@file)) end def comment_yaml(content) if content =~ /<!-{3}\s+(.+)?-{3}>/m SafeYAML.load($1)