/[Frey]/trunk/lib/Frey/Web.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Web.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 519 by dpavlin, Tue Nov 25 17:15:18 2008 UTC revision 529 by dpavlin, Wed Nov 26 04:26:43 2008 UTC
# Line 142  our $reload_counter = 0; Line 142  our $reload_counter = 0;
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 = {@_};
# Line 220  sub page { Line 222  sub page {
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 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>
# Line 306  sub add_status { Line 311  sub add_status {
311    
312  sub clean_status {  sub clean_status {
313          @status = ();          @status = ();
314            $icon_html = '';
315  }  }
316    
317  sub status_parts {  sub status_parts {
# Line 314  sub status_parts { Line 320  sub status_parts {
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
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 icon_path {
334            my ($self,$class,$variant) = @_;
335            my $icon = $class;
336            $icon =~ s{::}{/}g;
337            $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    sub add_icon {
349            my ($self,$variant) = @_;
350    
351            my $class = ref($self);
352            $class = $self->class if $self->can('class');
353            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
359    
360            # FIXME http://en.wikipedia.org/wiki/Favicon suggest just rel="icon" but that doesn't seem to work!
361            my $ico_path = $icon_path;
362            $ico_path =~ s{png$}{ico};
363            if ( ! -e $ico_path ) {
364                    system "convert $icon_path $ico_path";
365                    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;
368    
369    =cut
370    
371  }  }
372    
373  1;  1;

Legend:
Removed from v.519  
changed lines
  Added in v.529

  ViewVC Help
Powered by ViewVC 1.1.26