class Egalite::Controller
Constants
- MIME_TYPES
From WEBrick.
Attributes
env[RW]
log_values[RW]
params[RW]
req[RW]
template_file[RW]
Public Instance Methods
after_filter(response)
click to toggle source
# File lib/egalite.rb, line 163 def after_filter(response) # after filter for final http output response end
after_filter_html(response)
click to toggle source
# File lib/egalite.rb, line 160 def after_filter_html(response) # html after template filter response end
after_filter_return_value(response)
click to toggle source
# File lib/egalite.rb, line 157 def after_filter_return_value(response) # right after controller response end
before_filter()
click to toggle source
filters
# File lib/egalite.rb, line 154 def before_filter true end
db()
click to toggle source
accessors
# File lib/egalite.rb, line 171 def db @env.db end
delegate(params)
click to toggle source
# File lib/egalite.rb, line 199 def delegate(params) EgaliteResponse.new(:delegate, params) end
errorlog(severity, text)
click to toggle source
# File lib/egalite.rb, line 252 def errorlog(severity, text) logid = Egalite::ErrorLogger.write(:severity => severity, :ipaddress => @req.ipaddr, :text => text, :url => @req.url) logid end
escape_html(s)
click to toggle source
# File lib/egalite.rb, line 237 def escape_html(s) tags.escape_html(s) end
file_form(data={},param_name = nil, opts = {})
click to toggle source
# File lib/egalite.rb, line 249 def file_form(data={},param_name = nil, opts = {}) FormHelper.new(data,param_name,opts.merge(:enctype => 'multipart/form-data')) end
filter_on_html_load(html, htmlfile)
click to toggle source
# File lib/egalite.rb, line 166 def filter_on_html_load(html, htmlfile) html end
form(data={},param_name = nil, opts = {})
click to toggle source
# File lib/egalite.rb, line 246 def form(data={},param_name = nil, opts = {}) FormHelper.new(data,param_name,opts) end
id()
click to toggle source
# File lib/egalite.rb, line 180 def id @params[:id] end
include(params)
click to toggle source
# File lib/egalite.rb, line 202 def include(params) raw(req.handler.inner_dispatch(req, params)[2].join) end
link_to(title,prms)
click to toggle source
# File lib/egalite.rb, line 230 def link_to(title,prms) return tags.a(prms,title) if prms.is_a?(String) raw(@req.route.link_to(title,prms, req.host, req.port, req.scheme)) end
notfound()
click to toggle source
results
# File lib/egalite.rb, line 185 def notfound EgaliteResponse.new(:notfound) end
raw(text)
click to toggle source
# File lib/egalite.rb, line 234 def raw(text) NonEscapeString.new(text) end
redirect(url)
click to toggle source
# File lib/egalite.rb, line 188 def redirect(url) url = url_for(url) if url.is_a?(Hash) EgaliteResponse.new(:redirect, url) end
Also aliased as: redirect_to
redirect_permanent(url)
click to toggle source
# File lib/egalite.rb, line 194 def redirect_permanent(url) url = url_for(url) if url.is_a?(Hash) [301,{'Location' => url}, [url]] end
send_data(data, content_type)
click to toggle source
# File lib/egalite.rb, line 222 def send_data(data, content_type) [200,{"Content-Type" => content_type},[data]] end
send_file(path, content_type = nil)
click to toggle source
# File lib/egalite.rb, line 205 def send_file(path, content_type = nil) ext = File.extname(path)[1..-1] if File.file?(path) && File.readable?(path) s = nil open(path, "rb") { |file| s = file.read } return [200, { "Last-Modified" => File.mtime(path).rfc822, "Content-Type" => content_type || MIME_TYPES[ext] || "text/plain", "Content-Length" => File.size(path).to_s }, [s]] else return [404, {"Content-Type" => "text/plain"}, ["File not found\n"]] end end
session()
click to toggle source
# File lib/egalite.rb, line 177 def session @req.session end
table_by_array(header,content,opts={})
click to toggle source
# File lib/egalite.rb, line 243 def table_by_array(header,content,opts={}) TableHelper.table_by_array(header,content,opts) end
url_for(prms)
click to toggle source
helpers
# File lib/egalite.rb, line 227 def url_for(prms) @req.route.url_for(prms, req.host, req.port, req.scheme) end