Module: Tarpaulin

Defined in:
lib/tarpaulin.rb,
lib/tarpaulin/camping.rb

Overview

included into top-level TheApp module

overrides r404, defines r403 tells Tarpaulin which Controller in TheApp handles static files

don’t need to require anything as these are modules that are included elsewhere and those elsewhere require stuff :)

  1. use #included and then call TheApp for stuff we need (like #link_controller)

  2. what is the difference between #R, #R, #D, #URL ???

  3. use decent error pages, 403, 404, and Ruby Inspect (html version) in dev mode

  4. do link_ methods need to use #R or some variant?

Defined Under Namespace

Modules: Helpers

Constant Summary collapse

VERSION =
IO.read(version_file).strip

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



16
17
18
19
20
# File 'lib/tarpaulin/camping.rb', line 16

def self.included(mod)
  $DEBUG and $stderr.puts "mod is #{@mod}"
  @mod = mod
  $DEBUG and $stderr.puts "now it is #{@mod}"
end

Instance Method Details

#r403(f = nil, &block) ⇒ Object

check for Context, only show a.inspect in dev mode



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tarpaulin/camping.rb', line 23

def r403(f=nil, &block)
  #$stderr.puts "in 403"
  h = {'Content-Type' => 'text/html; charset=utf-8'}
  a = eval("Context::determine{}", block)
  if f.nil?
    f = block.call
  end
  extra = (ENV['MODE'] == 'development') ? "<br><hr>#{a.inspect}" : ''
  html_msg = "<!DOCTYPE html><html lang='en'><head>"+
             "<title>&#171; Uh oh &#187;</title><body><span class='error'>"+
             "Site error (BEEP!) 403: Invalid Path: #{f}#{extra}</span></body>"
  r(403, html_msg, h)
end

#r404(f = nil, &block) ⇒ Object

compat with Camping



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/tarpaulin/camping.rb', line 37

def r404(f=nil, &block) # compat with Camping
  #$stderr.puts "in 404"
  h = {'Content-Type' => 'text/html; charset=utf-8'}
  a = eval("Context::determine{}", block)
  if f.nil?
    f = block.call
  end
  extra = (ENV['MODE'] == 'development') ? "<br><hr>#{a.inspect}" : ''
  html_msg = "<!DOCTYPE html><html lang='en'><head>"+
             "<title>&#171; Uh oh &#187;</title><body><span class='error'>"+
             "Site error (BEEP!) 404: File not found: #{f}#{extra}</span></body>"
  r(404, html_msg, h)
end