Sha256: fe164bbd452d6c4a9eab6bee21239088df0253945c411610a56d8a1c8b41e527

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

class ::StaticCms::Site
  require 'yaml'
  require 'ruby_patch'
  extend ::RubyPatch::AutoLoad

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

  attr_accessor :page_alist
  attr_accessor *(CONFIG_DEFAULT.keys)

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
static_cms-1.2.1 lib/static_cms/site.rb
static_cms-1.2.0 lib/static_cms/site.rb