class Stormy::Page

Public Class Methods

fetch(app,key,params) click to toggle source
# File lib/stormy/page.rb, line 11
def self.fetch(app,key,params)
  details = app.cache.page(key) do 
    app.store.page(key)
  end

  self.new(app,details,params)
end
new(app, details, params) click to toggle source
Calls superclass method Stormy::Chunk::new
# File lib/stormy/page.rb, line 3
def initialize(app, details, params)

  super(app,details,params)

  @layout = app.layout(@details["layout"],@details) if @details["layout"]
  @template.content = resolve_content if details[:content] && @template
end

Public Instance Methods

mime_type() click to toggle source
# File lib/stormy/page.rb, line 28
def mime_type
  @mime_type ||= Rack::Mime.mime_type(File.extname(details["key"]),"text/html")
end
render(status = nil) click to toggle source
# File lib/stormy/page.rb, line 19
def render(status = nil)
  output =  @layout && mime_type == "text/html" ? @layout.render(@template) : @template.render
  if details[:redirect]
    [status || 301, {'Content-Type' => 'text','Location' => details[:redirect]}, ['301 found'] ]
  else
    [status || 200, {'Content-Type' => mime_type }, [ output ] ]
  end
end