class Staticpress::Theme

Attributes

name[R]
root[R]
trail[R]

Public Class Methods

new(name) click to toggle source
# File lib/staticpress/theme.rb, line 10
def initialize(name)
  @name = name.to_sym
  custom = Staticpress.blog_path + 'themes' + @name.to_s
  @root = custom.directory? ? custom : Staticpress.root + 'themes' + @name.to_s

  @trail = Hike::Trail.new
  @trail.append_paths custom, Staticpress.root + 'themes' + @name.to_s
  @trail.append_extensions *Tilt.mappings.keys
end
theme() click to toggle source
# File lib/staticpress/theme.rb, line 68
def self.theme
  new config.theme
end

Public Instance Methods

==(other) click to toggle source
Calls superclass method
# File lib/staticpress/theme.rb, line 20
def ==(other)
  other.respond_to?(:name) ? (name == other.name) : super
end
assets() click to toggle source
# File lib/staticpress/theme.rb, line 24
def assets
  reply = spider_map (root + 'assets').children do |file|
    file
  end.flatten
  parent ? (parent.assets + reply) : reply
end
copy_to(name) click to toggle source
# File lib/staticpress/theme.rb, line 31
def copy_to(name)
  destination = Staticpress.blog_path + 'themes' + name.to_s

  if destination.directory?
    raise Staticpress::Error, "Cannot copy theme. Destination (#{destination}) already exists."
  else
    FileUtils.mkdir_p destination
    FileUtils.cp_r root.children, destination
  end
end
parent() click to toggle source
# File lib/staticpress/theme.rb, line 42
def parent
  @parent ||= lambda do
    if config.theme_parent
      reply = self.class.new(config.theme_parent)
      @parent = reply unless self == reply
    end
  end.call
end