142 |
our @status; |
our @status; |
143 |
sub status { @status }; |
sub status { @status }; |
144 |
|
|
145 |
|
our $icon_html; |
146 |
|
|
147 |
sub page { |
sub page { |
148 |
my $self = shift; |
my $self = shift; |
149 |
my $a = {@_}; |
my $a = {@_}; |
222 |
my $revision = Frey::SVK->info->{Revision} || ''; |
my $revision = Frey::SVK->info->{Revision} || ''; |
223 |
$revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)}; |
$revision = $1 if $info->{'Mirrored From'} =~ m{Rev\.\s+(\d+)}; |
224 |
|
|
225 |
$self->add_icon; |
$self->add_icon unless $icon_html; |
226 |
|
|
227 |
my $html = join("\n", |
my $html = join("\n", |
228 |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|, |
229 |
$self->_head_html, |
$self->_head_html, |
230 |
'<title>' . ( $self->title || $a->{title} || ref($self) ) . '</title>', |
'<title>' . ( $self->title || $a->{title} || ref($self) ) . '</title>', |
231 |
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">', |
'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">', |
232 |
|
( $icon_html || '<!-- no icon -->' ), |
233 |
( $a->{head} || '' ), |
( $a->{head} || '' ), |
234 |
qq| |
qq| |
235 |
</head><body> |
</head><body> |
311 |
|
|
312 |
sub clean_status { |
sub clean_status { |
313 |
@status = (); |
@status = (); |
314 |
|
$icon_html = ''; |
315 |
} |
} |
316 |
|
|
317 |
sub status_parts { |
sub status_parts { |
323 |
cluck "## DEMOLISH status ", $#status + 1, " elements ", dump( map { keys %$_ } @status ) if @status; |
cluck "## DEMOLISH status ", $#status + 1, " elements ", dump( map { keys %$_ } @status ) if @status; |
324 |
} |
} |
325 |
|
|
326 |
|
=head2 add_icon |
327 |
|
|
328 |
|
Frey::Foo->add_icon; # /static/icons/Frey/Foo.png |
329 |
|
Frey::Foo->add_icon('warning'); # /static/icons/Frey/Foo/warning.png |
330 |
|
|
331 |
|
=cut |
332 |
|
|
333 |
sub add_icon { |
sub add_icon { |
334 |
my $self = shift; |
my ($self,$name) = @_; |
335 |
my $icon = ref($self); |
my $icon = ref($self); |
336 |
$icon = $self->class if $self->can('class'); |
$icon = $self->class if $self->can('class'); |
337 |
$icon =~ s{::}{/}g; |
$icon =~ s{::}{/}g; |
338 |
|
$icon .= "/$name" if $name; |
339 |
|
|
340 |
my $icon_path = "static/icons/$icon.png"; |
my $icon_path = "static/icons/$icon.png"; |
341 |
|
|
342 |
if ( -e $icon_path ) { |
if ( -e $icon_path ) { |
343 |
$self->add_head( qq|<link rel="icon" type="image/png" href="/$icon_path" />| ); |
$icon_html .= qq|<link rel="icon" type="image/png" href="/$icon_path">|; |
344 |
warn "# using icon $icon_path"; |
warn "# using icon $icon_path"; |
345 |
|
|
346 |
|
=for later |
347 |
|
|
348 |
# FIXME http://en.wikipedia.org/wiki/Favicon suggest just rel="icon" but that doesn't seem to work! |
# FIXME http://en.wikipedia.org/wiki/Favicon suggest just rel="icon" but that doesn't seem to work! |
349 |
my $ico_path = $icon_path; |
my $ico_path = $icon_path; |
350 |
$ico_path =~ s{png$}{ico}; |
$ico_path =~ s{png$}{ico}; |
352 |
system "convert $icon_path $ico_path"; |
system "convert $icon_path $ico_path"; |
353 |
warn "# convert $icon_path $ico_path : $@"; |
warn "# convert $icon_path $ico_path : $@"; |
354 |
} |
} |
355 |
$self->add_head( qq|<link rel="shortcut icon" type="image/x-icon" href="/$ico_path" />| ) if -e $ico_path; |
$icon_html .= qq|<link rel="shortcut icon" type="image/x-icon" href="/$ico_path">| if -e $ico_path; |
356 |
|
|
357 |
|
=cut |
358 |
|
|
359 |
} else { |
} else { |
360 |
warn "can't find $icon_path"; |
warn "TODO add $icon_path icon"; |
361 |
} |
} |
362 |
} |
} |
363 |
|
|