class Marsdawn::Site

Public Class Methods

new(opts, config=nil) { |config| ... } click to toggle source
# File lib/marsdawn/site.rb, line 11
def initialize opts, config=nil
  @key = opts[:key]
  if block_given?
    config = {}
    yield config
  elsif config.nil?
    config = Marsdawn::Config.new.to_hash(@key)
  end
  @config = config
  @storage = Marsdawn::Storage.get(@config[:storage], opts)
  @doc_info = @storage.get_document_info
  @opts = opts
  @base_path = (opts.key?(:base_path) ? opts[:base_path] : '')
end

Public Instance Methods

full_path(uri) click to toggle source
# File lib/marsdawn/site.rb, line 34
def full_path uri
  File.join @base_path, uri
end
index() click to toggle source
# File lib/marsdawn/site.rb, line 38
def index
  @index ||= Marsdawn::Site::Indexer.new(self, @doc_info[:site_index])
end
page(uri) click to toggle source
# File lib/marsdawn/site.rb, line 30
def page uri
  Marsdawn::Site::Page.new @doc_info, @storage.get(uri), self
end
page_title(uri) click to toggle source
# File lib/marsdawn/site.rb, line 42
def page_title uri
  @doc_info[:site_index][uri] if @doc_info[:site_index].key?(uri)
end
search_path() click to toggle source
# File lib/marsdawn/site.rb, line 58
def search_path
  uri = @opts[:search_uri] || '/'
  full_path uri
end
searchable?() click to toggle source
# File lib/marsdawn/site.rb, line 54
def searchable?
  @config.key?(:search)
end
title() click to toggle source
# File lib/marsdawn/site.rb, line 46
def title
  @doc_info[:title]
end
top() click to toggle source
# File lib/marsdawn/site.rb, line 26
def top
  @top ||= page('/')
end