Module: Spider::HTML
- Includes:
- ControllerMixin
- Defined in:
- lib/spiderfw/controller/formats/html.rb
Instance Method Summary
collapse
extend_recipient, included
Instance Method Details
#before(action = '', *arguments) ⇒ Object
before do
Spider.logger.debug('HTML before')
begin
run_chain(:before)
rescue => exc
top
print_backtrace(exc)
bottom
raise exc
end
end
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/spiderfw/controller/formats/html.rb', line 24
def before(action='', *arguments)
Spider.logger.debug("HTML BEFORE")
@response.register(:js, [])
begin
super
rescue => exc
top
print_backtrace(exc)
bottom
raise exc
end
end
|
57
58
59
|
# File 'lib/spiderfw/controller/formats/html.rb', line 57
def bottom
puts "</body></html>"
end
|
#print_backtrace(exc) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/spiderfw/controller/formats/html.rb', line 67
def print_backtrace(exc)
html = "<h3>Error: "+exc.to_s+"</h3>"
html += "<ul>"
client_editor = (Spider.config.get('client.text_editor') || '').downcase
prefix = ''
prefix = 'txmt://open?url=' if (client_editor == 'textmate')
exc.backtrace.each do |trace_line|
parts = trace_line.split(':')
file_path = parts[0]
line = parts[1]
method = parts[2]
suffix = ''
suffix = '&line='+line if (client_editor == 'textmate')
html += "<li>"
html += "<a href='#{prefix}file://#{file_path}#{suffix}'>#{file_path}</a>:#{line}:#{method}"
html += "</li>"
end
html += "</ul>"
puts html
end
|
47
48
49
50
51
52
53
54
55
|
# File 'lib/spiderfw/controller/formats/html.rb', line 47
def top
puts "<html>"
puts "<head>"
@response.js.each do |js|
puts "<script type=\"text/javascript\" src=\"#{js}\"></script>"
end
puts "</head>"
puts "<body>"
end
|
#try_rescue(exc) ⇒ Object
61
62
63
64
|
# File 'lib/spiderfw/controller/formats/html.rb', line 61
def try_rescue(exc)
print_backtrace(exc) if Spider.config.get('webserver.show_traces')
raise exc
end
|