11 |
use List::Util; |
use List::Util; |
12 |
|
|
13 |
use Continuity::Widget::DomNode; |
use Continuity::Widget::DomNode; |
14 |
|
use lib 'lib'; |
15 |
|
|
16 |
extends 'Frey'; |
extends 'Frey'; |
17 |
|
|
116 |
$out .= "\t\t},\n\t\tmeta: Frey.HTML, |
$out .= "\t\t},\n\t\tmeta: Frey.HTML, |
117 |
classMethods: { |
classMethods: { |
118 |
renderHTML: function () { |
renderHTML: function () { |
119 |
return new Joose.SimpleRequest().getText(\"inspect?module=$m;class=$c\") |
return new Joose.SimpleRequest().getText(\"/~/${m}::${c}\") |
120 |
},\n"; |
},\n"; |
121 |
|
|
122 |
$out .= "\t\t},\n"; |
$out .= "\t\t},\n"; |
178 |
|
|
179 |
while (1) { |
while (1) { |
180 |
|
|
181 |
my $js = [ map { |
my $js = Continuity::Widget::DomNode->create( |
182 |
( script => { type => 'text/javascript', src => $_ } ) |
map { |
183 |
} @javascript ]; |
( script => { type => 'text/javascript', src => $_ } ) |
184 |
warn "# js = ",dump( $js ); |
} @javascript |
185 |
|
)->to_string; |
186 |
|
|
187 |
|
$js .= << '__END_OF_JS__'; |
188 |
|
<script type="text/javascript"> |
189 |
|
joose.loadComponents("../lib") |
190 |
|
|
191 |
my $o; |
function $(id) { |
192 |
|
return document.getElementById(id) |
193 |
|
} |
194 |
|
|
195 |
|
</script> |
196 |
|
__END_OF_JS__ |
197 |
|
|
198 |
|
warn "# >>> js\n$js\n"; |
199 |
|
|
200 |
|
my $methods; |
201 |
|
|
202 |
|
my ( $class, $meta, $is_role ); |
203 |
|
eval { ( $class, $meta, $is_role ) = $self->load_package(); }; |
204 |
|
if ( $@ ) { |
205 |
|
warn "ERROR: $@"; |
206 |
|
$request->conn->send_status_line( 500, $@ ); |
207 |
|
$request->print( $@ ); |
208 |
|
$request->next; |
209 |
|
return; |
210 |
|
} |
211 |
|
|
|
my ( $class, $meta, $is_role ) = $self->load_package(); |
|
212 |
if ( $class->can('meta') ) { |
if ( $class->can('meta') ) { |
213 |
$o = Continuity::Widget::DomNode->create( |
$methods = Continuity::Widget::DomNode->create( |
214 |
ul => [ |
ul => [ |
215 |
map { ( |
map { ( |
216 |
li => [ a => { href => $_ } => [ $_ ] ] |
li => [ a => { href => '/~/' . $self->package . '/' . $_ } => [ $_ ] ] |
217 |
) } $self->methods |
) } $self->methods |
218 |
] |
] |
219 |
)->to_string; |
)->to_string; |
220 |
} else { |
} else { |
221 |
$o = '<b>not introspectable</b>'; |
$methods = '<b>not introspectable</b>'; |
222 |
} |
} |
223 |
|
|
224 |
warn "# o = ",dump( $o ); |
my $attributes = Continuity::Widget::DomNode->create( |
225 |
|
ul => [ |
226 |
|
map { |
227 |
|
my $attr = $class->get_attribute($_); |
228 |
|
warn "## $_ ", $attr->is_required ? 'required' : 'optional'; |
229 |
|
( li => [ a => { href => '/~/' . $self->package . '/' . $_ } => [ $_ ], ( $attr->is_required ? ' <b>required</b>' : '' ) ] ) |
230 |
|
} $class->get_attribute_list |
231 |
|
], |
232 |
|
)->to_string; |
233 |
|
|
234 |
my $doc = Continuity::Widget::DomNode->create( |
my $doc = Continuity::Widget::DomNode->create( |
235 |
html => [ |
html => [ |
236 |
head => [ |
head => [ |
237 |
link => { rel=>"stylesheet", href=>"/static/app.css", type=>"text/css", media=>"screen" }, |
link => { rel=>"stylesheet", href=>"/static/app.css", type=>"text/css", media=>"screen" }, |
238 |
# $js, |
$js, |
239 |
|
title => [ 'Introspect ', $self->package ], |
240 |
], |
], |
241 |
body => [ |
body => [ |
242 |
h1 => [ 'Introspect ', $self->package ], |
h1 => [ $self->package ], |
243 |
$o, |
h2 => [ 'Methods' ], |
244 |
|
$methods, |
245 |
|
h2 => [ 'Atrributes' ], |
246 |
|
$attributes, |
247 |
], |
], |
248 |
] |
] |
249 |
); |
); |
250 |
|
|
251 |
$request->print($doc->to_string); |
$request->print($doc->to_string); |
252 |
warn "# html = ", $doc->to_string; |
warn "# >>> html\n", $doc->to_string, "\n"; |
253 |
$request->next; |
$request->next; |
254 |
} |
} |
255 |
warn "# exit html"; |
warn "# exit html"; |