Changeset 235

Show
Ignore:
Timestamp:
06/12/07 22:20:16 (3 years ago)
Author:
eevee
Message:

Add current revision number to the footer. (#67)

Location:
veekun/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • veekun/trunk/lib/Vee.pm

    r186 r235  
    5454__PACKAGE__->setup; 
    5555 
     56# grab the current revision number, if applicable 
     57__PACKAGE__->cache->{svn_revision} =  
     58    Vee::Utils::timed_exec( 5 => sub { 
     59        open my $fh, '-|', 'svnversion' or return; 
     60        my $revision = <$fh>; 
     61        close $fh; 
     62        $revision =~ s/ \D+ $//gx; 
     63        return $revision; 
     64    } ); 
     65 
    5666{ 
    5767    no strict 'refs'; 
     
    8595=cut 
    8696 
    87 my $cache = {}; 
     97my $cache; 
    8898sub cache { 
     99    $cache ||= {};  # so we can call this function above 
    89100    return $cache; 
    90101} 
  • veekun/trunk/lib/Vee/Utils.pm

    r137 r235  
    8484} 
    8585 
     86# execute code but give up after x seconds 
     87# this is taken from perldoc -f alarm 
     88sub timed_exec { 
     89    my ($secs, $subref) = @_; 
     90    my $res = eval { 
     91        local $SIG{ALRM} = sub { die "alarm\n" }; 
     92        alarm $secs; 
     93        my $res = $subref->(); 
     94        alarm 0; 
     95        return $res; 
     96    }; 
     97 
     98    if ($@) { 
     99        die unless $@ eq "alarm\n";  # propagate unexpected errors 
     100        return; 
     101    } else { 
     102        return $res; 
     103    } 
     104} 
     105 
    86106sub pad { sprintf "%0$_[1]d", $_[0] } 
    87107sub round { $_[1] ||= 0; return int($_[0] * 10 ** $_[1] + .5) / 10 ** $_[1]; } 
  • veekun/trunk/templates/style/global.tt

    r231 r235  
    9696#debug { margin-bottom: 1em; } 
    9797#footer { -moz-border-radius-bottomright: 64px; } 
     98  #footer #svn-revision { float: right; font-size: 85%; } 
    9899 
    99100#breadcrumbs { margin: -0.5em; margin-bottom: 0.5em; padding: 0.5em; background: [% glass_background(tablerow_fill2) %]; } 
  • veekun/trunk/templates/wrapper.tt

    r234 r235  
    173173 
    174174<div id="footer"> 
     175[% IF c.cache.svn_revision %] 
     176    <div id="svn-revision">Revision [% 
     177        c.cache.svn_revision 
     178        .replace(':', ' through ') 
     179        .replace('(\d+)', '<a href="http://trac.veekun.com/changeset/$1">$1</a>') 
     180    %]</div> 
     181[% END %] 
    175182    All content copyright its original owners.  Pok&eacute;mon is copyright to Nintendo and Game Freak.  Current site layout by Eevee/Alex Munroe and is &copy;2005. <br/> 
    176183[% IF from_cache %]