320 |
|
|
321 |
sub DEMOLISH { |
sub DEMOLISH { |
322 |
my ( $self ) = @_; |
my ( $self ) = @_; |
323 |
cluck "## DEMOLISH status ", $#status + 1, " elements ", dump( map { keys %$_ } @status ) if @status; |
warn "## $self DEMOLISH status ", $#status + 1, " elements ", dump( map { keys %$_ } @status ) if @status; |
324 |
} |
} |
325 |
|
|
326 |
=head2 add_icon |
=head2 add_icon |
330 |
|
|
331 |
=cut |
=cut |
332 |
|
|
333 |
sub add_icon { |
sub icon_path { |
334 |
my ($self,$name) = @_; |
my ($self,$class,$variant) = @_; |
335 |
my $icon = ref($self); |
my $icon = $class; |
|
$icon = $self->class if $self->can('class'); |
|
336 |
$icon =~ s{::}{/}g; |
$icon =~ s{::}{/}g; |
337 |
$icon .= "/$name" if $name; |
$icon .= "/$variant" if $variant; |
338 |
|
my $path = 'static/icons/' . $icon . '.png'; |
339 |
|
if ( -e $path ) { |
340 |
|
warn "# $class from $self icon_path $path"; |
341 |
|
return $path; |
342 |
|
} else { |
343 |
|
warn "TODO: add $path icon for $class"; |
344 |
|
return undef; |
345 |
|
} |
346 |
|
} |
347 |
|
|
348 |
my $icon_path = "static/icons/$icon.png"; |
sub add_icon { |
349 |
|
my ($self,$variant) = @_; |
350 |
|
|
351 |
if ( -e $icon_path ) { |
my $class = ref($self); |
352 |
$icon_html .= qq|<link rel="icon" type="image/png" href="/$icon_path">|; |
$class = $self->class if $self->can('class'); |
353 |
warn "# using icon $icon_path"; |
my $icon_path = $self->icon_path( $class, $variant ) || return; |
354 |
|
|
355 |
|
$icon_html .= qq|<link rel="icon" type="image/png" href="/$icon_path">|; |
356 |
|
warn "# using icon $icon_path"; |
357 |
|
|
358 |
=for later |
=for later |
359 |
|
|
360 |
# 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! |
361 |
my $ico_path = $icon_path; |
my $ico_path = $icon_path; |
362 |
$ico_path =~ s{png$}{ico}; |
$ico_path =~ s{png$}{ico}; |
363 |
if ( ! -e $ico_path ) { |
if ( ! -e $ico_path ) { |
364 |
system "convert $icon_path $ico_path"; |
system "convert $icon_path $ico_path"; |
365 |
warn "# convert $icon_path $ico_path : $@"; |
warn "# convert $icon_path $ico_path : $@"; |
366 |
} |
} |
367 |
$icon_html .= 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; |
368 |
|
|
369 |
=cut |
=cut |
370 |
|
|
|
} else { |
|
|
warn "TODO add $icon_path icon"; |
|
|
} |
|
371 |
} |
} |
372 |
|
|
373 |
1; |
1; |