class Octopress::Ink::Assets::Template
Attributes
pages[R]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
Octopress::Ink::Assets::Asset::new
# File lib/octopress-ink/assets/template.rb, line 7 def initialize(*args) super(*args) @pages = [] @existing_pages = {} end
Public Instance Methods
add()
click to toggle source
# File lib/octopress-ink/assets/template.rb, line 13 def add; end
info()
click to toggle source
# File lib/octopress-ink/assets/template.rb, line 15 def info message = " - #{asset_info}\n" unless disabled? self.pages.each do |page| if existing_page = @existing_pages[page.url] message << " #{page.url.ljust(33)} Disabled: /#{existing_page.path} already exists\n" else message << " #{page.url}\n" end end end message end
new_page(data={})
click to toggle source
# File lib/octopress-ink/assets/template.rb, line 31 def new_page(data={}) return if disabled? page = Ink::Page.new(Octopress.site, File.dirname(self.path), '.', File.basename(self.path)) page.data.merge!(data) page.plugin = plugin page.asset = self self.pages << page if existing_page = page_exists?(page) if existing_page.respond_to?(:plugin) @replacement = existing_page.plugin.name else @existing_pages[existing_page.url] = existing_page end false else page end end
page_exists?(page)
click to toggle source
# File lib/octopress-ink/assets/template.rb, line 51 def page_exists?(page) Octopress.site.pages.find {|p| p.url == page.url} end