7 |
|
|
8 |
use Continuity::Widget::DomNode; |
use Continuity::Widget::DomNode; |
9 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
10 |
use Carp qw/confess/; |
use Carp qw/confess cluck/; |
11 |
use File::Slurp; |
use File::Slurp; |
12 |
|
|
13 |
use Frey::Bookmarklet; |
use Frey::Bookmarklet; |
20 |
default => sub { [ 'static/frey.css' ] }, |
default => sub { [ 'static/frey.css' ] }, |
21 |
); |
); |
22 |
|
|
|
has 'status' => ( |
|
|
is => 'rw', |
|
|
isa => 'ArrayRef[HashRef[Str]]', |
|
|
lazy => 1, |
|
|
default => sub { [ |
|
|
{ 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }, |
|
|
{ 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }, |
|
|
] }, |
|
|
); |
|
|
|
|
23 |
has 'request_url' => ( |
has 'request_url' => ( |
24 |
is => 'rw', |
is => 'rw', |
25 |
isa => 'Uri', coerce => 1, |
isa => 'Uri', coerce => 1, |
139 |
|
|
140 |
=cut |
=cut |
141 |
|
|
142 |
|
our @status; |
143 |
|
sub status { @status }; |
144 |
|
|
145 |
sub page { |
sub page { |
146 |
my $self = shift; |
my $self = shift; |
147 |
my $a = {@_}; |
my $a = {@_}; |
148 |
|
|
149 |
|
warn "## page ",dump($a); |
150 |
|
|
151 |
$reload_counter++; |
$reload_counter++; |
152 |
|
|
153 |
my $status_line = ''; |
my $status_line = ''; |
154 |
foreach my $part ( @{ $self->status } ) { |
|
155 |
if ( ref($part) ne 'HASH' ) { |
unshift @status, { 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup }; |
156 |
warn "part not hash ",dump( $part ) ; |
unshift @status, { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup }; |
157 |
#$self->status( $part ); |
|
158 |
next; |
foreach my $part ( @status ) { |
|
} |
|
159 |
foreach my $name ( keys %$part ) { |
foreach my $name ( keys %$part ) { |
160 |
my $content = $part->{$name}; |
my $content = $part->{$name}; |
161 |
if ( ref($content) ) { |
if ( ref($content) ) { |
211 |
my $right = |
my $right = |
212 |
qq| |
qq| |
213 |
<span class="right"> |
<span class="right"> |
214 |
<a title="reload" href="/reload$url"><code>$url</code></a> |
<a title="reload $url" href="/reload$url">reload</a> |
215 |
<a title="$description" href="/exit$url">$exit</a> |
<a title="$description" href="/exit$url">$exit</a> |
216 |
</span> |
</span> |
217 |
|; |
|; |
218 |
|
|
219 |
|
my $info = Frey::SVK->info; |
220 |
my $revision = Frey::SVK->info->{Revision} || ''; |
my $revision = Frey::SVK->info->{Revision} || ''; |
221 |
|
$revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)}; |
222 |
|
|
223 |
|
$self->add_icon; |
224 |
|
|
225 |
my $html = join("\n", |
my $html = join("\n", |
226 |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
256 |
sub editor { |
sub editor { |
257 |
my ( $self, $class, $line, $title ) = @_; |
my ( $self, $class, $line, $title ) = @_; |
258 |
confess "need class" unless $class; |
confess "need class" unless $class; |
259 |
$line ||= 1; |
if ( ! defined $title ) { |
260 |
|
$title = "edit $class"; |
261 |
|
$title .= " line $line" if $line; |
262 |
|
} |
263 |
|
$line ||= 1; |
264 |
qq|<a target="editor" href="/editor+$class+$line"| . |
qq|<a target="editor" href="/editor+$class+$line"| . |
265 |
( $title ? qq| title="$title"| : '' ) . |
( $title ? qq| title="$title"| : '' ) . |
266 |
qq|>$class</a>|; |
qq|>$class</a>|; |
303 |
|
|
304 |
sub add_status { |
sub add_status { |
305 |
my ( $self, $data ) = @_; |
my ( $self, $data ) = @_; |
306 |
push @{ $self->status }, $data; |
push @status, $data; |
307 |
warn "## current status ", $#{ $self->status }, " elements"; |
} |
308 |
|
|
309 |
|
sub clean_status { |
310 |
|
@status = (); |
311 |
|
} |
312 |
|
|
313 |
|
sub status_parts { |
314 |
|
warn "## status parts ", dump( map { keys %$_ } @status ); |
315 |
|
} |
316 |
|
|
317 |
|
sub DEMOLISH { |
318 |
|
my ( $self ) = @_; |
319 |
|
cluck "## DEMOLISH status ", $#status + 1, " elements ", dump( map { keys %$_ } @status ) if @status; |
320 |
|
} |
321 |
|
|
322 |
|
sub add_icon { |
323 |
|
my $self = shift; |
324 |
|
my $icon = ref($self); |
325 |
|
$icon = $self->class if $self->can('class'); |
326 |
|
$icon =~ s{::}{/}g; |
327 |
|
|
328 |
|
my $icon_path = "static/icons/$icon.png"; |
329 |
|
|
330 |
|
if ( -e $icon_path ) { |
331 |
|
$self->add_head( qq|<link rel="icon" type="image/png" href="/$icon_path" />| ); |
332 |
|
warn "# using icon $icon_path"; |
333 |
|
|
334 |
|
# FIXME http://en.wikipedia.org/wiki/Favicon suggest just rel="icon" but that doesn't seem to work! |
335 |
|
my $ico_path = $icon_path; |
336 |
|
$ico_path =~ s{png$}{ico}; |
337 |
|
if ( ! -e $ico_path ) { |
338 |
|
system "convert $icon_path $ico_path"; |
339 |
|
warn "# convert $icon_path $ico_path : $@"; |
340 |
|
} |
341 |
|
$self->add_head( qq|<link rel="shortcut icon" type="image/x-icon" href="/$ico_path" />| ) if -e $ico_path; |
342 |
|
|
343 |
|
} else { |
344 |
|
warn "can't find $icon_path"; |
345 |
|
} |
346 |
} |
} |
347 |
|
|
348 |
1; |
1; |