Class: StaticCms::Site

Inherits:
Object
  • Object
show all
Extended by:
RubyPatch::AutoLoad
Defined in:
lib/static_cms/site.rb

Constant Summary collapse

CONFIG_DEFAULT =
{
  'lang' => 'en',
  'www' => nil,
  'dir' => File.join(__DIR__, 'root'),
  'author' => '',
  'robots' => 'noarchive',
  'favicon' => 'images/favicon.png',
  'charset' => 'utf-8',
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSite

Returns a new instance of Site.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/static_cms/site.rb', line 19

def initialize
  config = CONFIG_DEFAULT.merge(YAML.load_file('config.yaml'))
  @www = config.delete('www')
  @www += '/' unless @www[-1] == '/'
  config.each{|k, v| instance_variable_set("@#{k}", v)}
  @page_alist = Hash.new{|h, k| raise KeyError, k}
  YAML.load_file('pages.yaml')\
    .sort\
    .each{|name, params|
    @page_alist[name] = ::StaticCms::Page.new(self, name, params)
  }
end

Instance Attribute Details

#page_alistObject

Returns the value of attribute page_alist.



16
17
18
# File 'lib/static_cms/site.rb', line 16

def page_alist
  @page_alist
end

Instance Method Details

#upload(dir = @dir) ⇒ Object



32
33
34
# File 'lib/static_cms/site.rb', line 32

def upload(dir = @dir)
  ::StaticCms::Helpers.puts_system "rsync -avu root/ #{dir}"
end