File Coverage

lib/Egg/Util/DebugScreen.pm
Criterion Covered Total %
statement 12 37 32.4
branch 0 4 0.0
condition 0 9 0.0
subroutine 4 7 57.1
pod n/a
total 16 57 28.0


line stmt bran cond sub pod time code
1             package Egg::Util::DebugScreen;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: DebugScreen.pm 342 2008-05-29 16:05:06Z lushe $
6             #
7 1     1   487 use strict;
  1         2  
  1         44  
8 1     1   6 use warnings;
  1         2  
  1         79  
9 1     1   6 use Egg::Release;
  1         1  
  1         14  
10 1     1   23 use HTML::Entities;
  1         2  
  1         673  
11              
12             our $VERSION = '3.04';
13              
14             sub _debug_screen {
15 0     0     my($e)= @_;
16 0           $e->setup_error_header;
17 0           $e->finished(0);
18 0           $e->response->body( _content($e) );
19 0           $e->_output;
20             }
21             sub _content {
22 0     0     my($e)= @_;
23 0   0       my $err= $e->errstr || 'Internal Error.';
24 0           my($res, $querys, $escape)= ($e->response, '', q{'"&<>@});
25 0           $err= encode_entities($err, $escape);
26 0           $err=~s{\n} [<br />\n]sg;
27 0           my $param;
28 0 0 0       if ($param= $e->request->params and %$param) {
29 0           $querys = q{ <div class="querys"><b>Request Querys:</b><table>};
30 0           while (my($key, $value)= each %$param) {
31 0           $querys.= q{<tr><th>}. encode_entities($key, $escape). qq{</th>};
32 0 0         $value = encode_entities($value, $escape) unless ref($value);
33 0           $querys.= qq{<td>${value}</td></tr>\n};
34             }
35 0           $querys.= q{</table></div>};
36             }
37 0           <<END_OF_DISP;
38             <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
39             "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
40 0           <html xmlns="http://www.w3.org/1999/xhtml" lang="@{[
41 0   0       $res->content_language($e->config->{content_language} || 'en')
42             ]}">
43             <head>
44 0   0       <meta http-equiv="Content-Language" content="@{[ $res->content_language ]}" />
45 0           <meta http-equiv="Content-Type" content="@{[
46             $res->content_type($e->config->{content_type} || 'text/html')
47             ]}" />
48             <meta http-equiv="Content-Style-Type" content="text/css" />
49             <meta name="robots" content="noindex,nofollow,noarchive" />
50             <title>EGG - Error.</title>
51 0           <style type="text/css">@{[ _style() ]}</style>
52             </head>
53             <body>
54             <div id="egg_error_container">
55             <h1>$e->{namespace} v@{[ $e->VERSION ]}</h1>
56             <div id="egg_error_content"> $err$querys </div>
57             <div id="egg_error_footer">
58             <a href="$Egg::Release::DISTURL" target="_blank">
59             Powered by Egg <strong>$Egg::Release::VERSION</strong></a>
60             </div>
61             </div>
62             </body></html>
63             END_OF_DISP
64             }
65             sub _style {
66 0     0     <<END_STYLE;
67             body {
68             background:#FFF376;
69             margin:0px;
70             text-align:center;
71             }
72             h1 {
73             margin:0px; padding:1px 3px 1px 10px;
74             font:bold 16pt Times,sans-serif;
75             background:#FFBF00;
76             border:#B7974E solid 2px; border-bottom:0px;
77             }
78             #egg_error_container {
79             margin:10px auto 0px auto; padding:0px;
80             width:720px;
81             text-align:left;
82             }
83             #egg_error_content {
84             background:#FFF;
85             margin:0px; padding:10px;
86             border-right:#B7974E solid 2px; border-left:#B7974E solid 2px;
87             text-align:left;
88             }
89             #egg_error_content .querys {
90             margin:10px; padding:2px;
91             background:#F9D787; color:#555;
92             border:#333 solid 1px;
93             font-size:10px;
94             }
95             #egg_error_content .querys table {
96             width:99.5%;
97             border-collapse:collapse;
98             font-size:12px; color:#000;
99             }
100             #egg_error_content .querys table th, #egg_error_content .querys table td {
101             padding:2px 3px 1px 5px;
102             border-bottom:#C5AB6A solid 1px;
103             }
104             #egg_error_content .querys table th { background:#FFF1B9 }
105             #egg_error_content .querys table td { background:#FFFFED }
106             #egg_error_footer {
107             background:#FFBF00;
108             border:#B7974E solid 2px; border-top:0px;
109             font:italic 10pt Times,sans-serif;
110             text-align:right;
111             }
112             #egg_error_footer a { color:#000 }
113             END_STYLE
114             }
115              
116             1;
117              
118             __END__
119              
120             =head1 NAME
121              
122             Egg::Util::DebugScreen - Debugging screen for Egg.
123              
124             =head1 DESCRIPTION
125              
126             The message is displayed on the screen where the appearance was in order when
127             the project generates the exception.
128              
129             This module is set up by L<Egg::Util::Debug> when debug mode is effective.
130             To use other classes, it sets it to environment variable EGG_DEBUG_SCREEN_CLASS.
131              
132             This module initializes the response status when the exception is generated and
133             displays the screen. In a word, please note that Egg continues processing assuming
134             that '200 OK' was specified when the response status is undefined.
135              
136             =head1 SEE ALSO
137              
138             L<Egg::Release>,
139             L<HTML::Entities>,
140              
141             =head1 AUTHOR
142              
143             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
144              
145             =head1 COPYRIGHT AND LICENSE
146              
147             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>.
148              
149             This library is free software; you can redistribute it and/or modify
150             it under the same terms as Perl itself, either Perl version 5.8.6 or,
151             at your option, any later version of Perl 5 you may have available.
152              
153             =cut
154