class AllSeeingEye::Server
Public Instance Methods
class_if_current(path = '')
click to toggle source
# File lib/all_seeing_eye/server.rb, line 37 def class_if_current(path = '') 'class="current"' if current_page.split('/').any?{|p| p == path} end
current_page()
click to toggle source
# File lib/all_seeing_eye/server.rb, line 22 def current_page url_path request.path_info.sub('/','') end
current_section()
click to toggle source
# File lib/all_seeing_eye/server.rb, line 18 def current_section url_path request.path_info.sub('/','').split('/')[0].downcase end
humanize(string)
click to toggle source
# File lib/all_seeing_eye/server.rb, line 51 def humanize(string) string.split('_').collect(&:capitalize).join(' ') end
partial(template, local_vars = {})
click to toggle source
# File lib/all_seeing_eye/server.rb, line 59 def partial(template, local_vars = {}) @partial = true erb(template.to_sym, {:layout => false}, local_vars) ensure @partial = false end
partial?()
click to toggle source
# File lib/all_seeing_eye/server.rb, line 55 def partial? @partial end
path_prefix()
click to toggle source
# File lib/all_seeing_eye/server.rb, line 33 def path_prefix ENV['PATH_PREFIX'] || '' end
round(float, n = 2)
click to toggle source
# File lib/all_seeing_eye/server.rb, line 47 def round(float, n = 2) (float * (10.0 ** n)).round * (10.0 ** (-n)) end
show(page, layout = true)
click to toggle source
# File lib/all_seeing_eye/server.rb, line 68 def show(page, layout = true) response["Cache-Control"] = "max-age=0, private, must-revalidate" erb page.to_sym, {:layout => layout} end
tab(name, prefix = nil)
click to toggle source
# File lib/all_seeing_eye/server.rb, line 41 def tab(name, prefix = nil) dname = name.to_s.downcase path = url_path("#{prefix.nil? ? '' : "#{prefix}/"}" + dname) "<li #{class_if_current(dname)}><a href='#{path}'>#{humanize name}</a></li>" end
url_path(*path_parts)
click to toggle source
# File lib/all_seeing_eye/server.rb, line 26 def url_path(*path_parts) path_parts = path_parts.collect{|p| p.to_s.gsub(path_prefix, '')} path = [ path_prefix, path_parts ].compact.join("/") ('/' + path).squeeze('/') end