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 :)
-
use #included and then call TheApp for stuff we need (like #link_controller)
-
what is the difference between #R, #R, #D, #URL ???
-
use decent error pages, 403, 404, and Ruby Inspect (html version) in dev mode
-
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
-
#r403(f = nil, &block) ⇒ Object
check for Context, only show a.inspect in dev mode.
-
#r404(f = nil, &block) ⇒ Object
compat with Camping.
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>« Uh oh »</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>« Uh oh »</title><body><span class='error'>"+ "Site error (BEEP!) 404: File not found: #{f}#{extra}</span></body>" r(404, html_msg, h) end |