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(keyword, opts={})
click to toggle source
# File lib/marsdawn/site.rb, line 63 def search keyword, opts={} raise "No search settings for this document." unless searchable? se = Marsdawn::Search.get(@storage, @config[:search]) results = se.search(keyword, opts) Marsdawn::Site::SearchPage.new @doc_info, self, keyword, results 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
title_link()
click to toggle source
# File lib/marsdawn/site.rb, line 50 def title_link @title_link ||= Marsdawn::Site::Link.new(self, "#{@base_path}/", title) end
top()
click to toggle source
# File lib/marsdawn/site.rb, line 26 def top @top ||= page('/') end