class Octopress::Ink::Assets::PageAsset

Attributes

data[RW]
filename[R]

Public Class Methods

new(plugin, base, file) click to toggle source
# File lib/octopress-ink/assets/page.rb, line 11
def initialize(plugin, base, file)
  @root = plugin.assets_path
  @plugin = plugin
  @base = base
  @filename = file
  @dir  = File.dirname(file)
  @file = File.basename(file)
  @exists = {}
  @permalink_name = file.sub(File.extname(file), '')
  @data = {}
  file_check
end

Public Instance Methods

add() click to toggle source

Add page to Jekyll pages if no other page has a conflicting destination

# File lib/octopress-ink/assets/page.rb, line 26
def add
  if page.url && !find_page(page)
    Octopress.site.pages << page
    plugin.config['permalinks'] ||= {}
    permalink_config ||= page.url
  end
end
deep_merge(data={}) click to toggle source
# File lib/octopress-ink/assets/page.rb, line 38
def deep_merge(data={})
  Jekyll::Utils.deep_merge_hashes(page.data, data)
end
find_page(page) click to toggle source
# File lib/octopress-ink/assets/page.rb, line 50
def find_page(page)
  site_dir = Octopress.site.dest
  dest = page.destination(site_dir)

  Octopress.site.pages.clone.each do |p|
    return p if p.destination(site_dir) == dest
  end
  return false
end
lang() click to toggle source
# File lib/octopress-ink/assets/page.rb, line 84
def lang
  data['lang']
end
merge_data(data={}) click to toggle source
# File lib/octopress-ink/assets/page.rb, line 34
def merge_data(data={})
  page.data.merge!(data)
end
new_page(data={}) click to toggle source
# File lib/octopress-ink/assets/page.rb, line 42
def new_page(data={})
  page = Ink::Page.new(Octopress.site, File.dirname(self.path), '.', File.basename(self.path))
  page.data.merge!(data)
  page.plugin = plugin
  page.asset = self
  page
end
page() click to toggle source
# File lib/octopress-ink/assets/page.rb, line 60
def page
  @page ||= begin
    page = Page.new(Octopress.site, source_dir, page_dir, file)

    if permalink_config
      page.data['permalink'] = permalink_config
    else
      permalink = page.data['permalink']
    end

    page.data.merge!(@data)
    page.plugin = plugin
    page.asset = self

    page
  end
end
url() click to toggle source
# File lib/octopress-ink/assets/page.rb, line 82
def url; permalink; end

Private Instance Methods

page_dir() click to toggle source
# File lib/octopress-ink/assets/page.rb, line 109
def page_dir
  dir == '.' ? '' : dir
end
plugin_path() click to toggle source
# File lib/octopress-ink/assets/page.rb, line 113
def plugin_path
  File.join(plugin_dir, dir, file)
end
user_dir() click to toggle source
# File lib/octopress-ink/assets/page.rb, line 117
def user_dir
  File.join Plugins.custom_dir, plugin.slug, base
end