1 |
package Frey::ClassBrowser; |
2 |
use Moose; |
3 |
|
4 |
extends 'Frey'; |
5 |
with 'Frey::Web'; |
6 |
|
7 |
use Frey::ClassLoader; |
8 |
|
9 |
our $markup; |
10 |
|
11 |
sub markup { |
12 |
return $markup if $markup; |
13 |
my $f = Frey::ClassLoader->new; |
14 |
my $html; |
15 |
foreach my $package ( $f->classes ) { |
16 |
$html .= qq|<tr><td><a href="/~/$package" title="| . $f->package_path( $package ) . qq|">$package</a></td><td>|; |
17 |
if ( $package->can('meta') ) { |
18 |
if ( $package->meta->isa('Moose::Meta::Role') ) { |
19 |
$html .= qq|role|; |
20 |
} else { |
21 |
$html .= qq|<a href="/od/$package">design</a>| if $package->can('collection'); |
22 |
} |
23 |
} |
24 |
$html .= qq|</td><td>|; |
25 |
$html .= qq|<a href="/ob/$package">collection</a>| if $package->can('collection_table'); |
26 |
$html .= qq|</td></tr>|; |
27 |
} |
28 |
$html = "<table>$html</table>" if $html; |
29 |
$markup = $html; |
30 |
} |
31 |
|
32 |
sub html { |
33 |
my ( $self, $req ) = @_; |
34 |
my $html = $self->page( body => qq|<h1>Classes</h1>| . $self->markup ); |
35 |
$req->print( $html ); |
36 |
} |
37 |
|
38 |
1; |