class Adocsite::Context
Attributes
type[R]
Public Class Methods
new(engine, request)
click to toggle source
# File lib/adocsite/context.rb, line 4 def initialize(engine, request) @engine = engine @request = request @type = request.type @context_vars = Hash.new build_vars end
Public Instance Methods
get_article()
click to toggle source
# File lib/adocsite/context.rb, line 102 def get_article() @engine.content_loader.articles[@request.name] end
get_articles(category = nil)
click to toggle source
# File lib/adocsite/context.rb, line 68 def get_articles(category = nil) if category @engine.categories[category] else @engine.content_loader.articles.values end end
get_categories()
click to toggle source
# File lib/adocsite/context.rb, line 64 def get_categories() @engine.categories.values end
get_category()
click to toggle source
# File lib/adocsite/context.rb, line 106 def get_category() @engine.categories[@request.name] end
get_content_for_layout()
click to toggle source
# File lib/adocsite/context.rb, line 85 def get_content_for_layout() get_partial(@type) # if @type == "home" # get_partial('home') # elsif @type == "page" # get_partial('page') # elsif @type == "article" # get_partial('article') # elsif @type == "category" # get_partial('category') # end end
get_include(include_name)
click to toggle source
# File lib/adocsite/context.rb, line 38 def get_include(include_name) tpl = @engine.templates.get_include(include_name) tpl.render(self, @context_vars) end
get_layout(layout_name = "default")
click to toggle source
# File lib/adocsite/context.rb, line 47 def get_layout(layout_name = "default") tpl = @engine.templates.get_layout(layout_name) tpl.render(self, @context_vars) end
get_literal(literal_name)
click to toggle source
# File lib/adocsite/context.rb, line 43 def get_literal(literal_name) @engine.templates.get_literal(literal_name) end
get_page()
click to toggle source
# File lib/adocsite/context.rb, line 110 def get_page() @engine.content_loader.pages[@request.name] end
get_pages()
click to toggle source
# File lib/adocsite/context.rb, line 60 def get_pages() @engine.content_loader.pages.values end
get_partial(partial_name)
click to toggle source
# File lib/adocsite/context.rb, line 33 def get_partial(partial_name) tpl = @engine.templates.get_partial(partial_name) tpl.render(self, @context_vars) end
is_context?(context_name)
click to toggle source
# File lib/adocsite/context.rb, line 56 def is_context?(context_name) @type == context_name end
Private Instance Methods
build_vars()
click to toggle source
# File lib/adocsite/context.rb, line 13 def build_vars() # variables common to all contexts @context_vars = { :page_title => Adocsite::config[:SITE_TITLE], } if @type == "home" # @context_vars[] = 'nil' elsif @type == "page" @context_vars[:page] = get_page elsif @type == "article" @context_vars[:article] = get_article elsif @type == "category" @context_vars[:category] = get_category end end