Changeset 21

Show
Ignore:
Timestamp:
02/23/07 23:27:09 (3 years ago)
Author:
eevee
Message:

Added last repository message to the top of the index page.
In doing so, also added use of DateTime?, created a once-per-site-instance cache, fixed a doublebug with recent user printing, and fixed the nohtml filter.

Location:
veekun
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • veekun/README.pod

    r13 r21  
    2525    Catalyst::Plugin::Session::Store::DBIC 
    2626    DBIx::Class 
     27    DateTime 
    2728    Email::Valid 
    2829    Image::Size 
  • veekun/lib/Vee.pm

    r13 r21  
    6767} 
    6868 
     69=head2 cache 
     70 
     71Returns a cache hash for holding small bits of data useful between requests 
     72but not worth a database table/row/hit. 
     73 
     74=cut 
     75 
     76my $cache = {}; 
     77sub cache { 
     78    return $cache; 
     79} 
     80 
    6981=head2 uri 
    7082 
  • veekun/lib/Vee/Controller/Index.pm

    r18 r21  
    44use warnings; 
    55use base 'Catalyst::Controller'; 
     6 
     7use DateTime; 
    68 
    79__PACKAGE__->config->{namespace} = ''; 
     
    5456    } ); 
    5557 
     58    # check for latest subversion revision every 15 minutes or so 
     59    if (not $c->cache->{svn} or $c->cache->{svn}{last_checked} < time - 15 * 60) { 
     60        eval { 
     61            open my $svn_fh, '-|', 'svn', 'log', '--limit' => 1, '--incremental', $c->site_opts->{svn_url}; 
     62            my (undef, $details, undef, @log) = <$svn_fh>; 
     63            close $svn_fh; 
     64            my ($rev, $user, $time, undef) = split / \| /, $details; 
     65            $rev =~ s/^r//; 
     66            my ($yr, $mo, $day, $hr, $min, $sec, $tz) = split /[- :]/, $time, 7; 
     67 
     68            $c->cache->{svn} = { 
     69                revision     => $rev, 
     70                user         => $user, 
     71                time         => new DateTime( 
     72                    year   => $yr, 
     73                    month  => $mo, 
     74                    day    => $day, 
     75                    hour   => $hr, 
     76                    minute => $min, 
     77                    second => $sec, 
     78                    time_zone => substr $tz, 0, 5, 
     79                ), 
     80                last_checked => time, 
     81                log          => join '', @log, 
     82            } 
     83        }; 
     84    } 
     85 
     86    $s->{recent_revision} = $c->cache->{svn}; 
     87 
    5688    $s->{recent_users} = $c->model('DBIC::Users')->search( 
    5789        { lastactive => { '>', time - $c->site_opts->{user_activity_timeout} } }, 
  • veekun/lib/Vee/View/TT.pm

    r13 r21  
    4545    FILTERS => { 
    4646    #                vee_basic       => \&Vee::format_basic, 
    47         nohtml      => sub { return Vee->vee_cleanse(@_) }, 
     47        nohtml      => \&Vee::Utils::cleanse, 
    4848        bbcode      => \&Vee::BBCode::apply_bbcode, 
    4949        timespan    => \&_format_timespan, 
  • veekun/site_options.yml

    r13 r21  
    7070user_activity_timeout: 900 
    7171 
     72# URL for Subversion repository path to check for activity 
     73# Note that at the moment this *requires* anon access! 
     74svn_url: svn://veekun.com/veekun 
     75 
    7276# Number of posts => rank you get 
    7377post_ranks: 
  • veekun/templates/index.tt

    r18 r21  
    2222<p>I am wide open to suggestions, comments, criticisms, improvements, and free 
    2323money.</p> 
     24[% IF recent_revision %] 
     25<div style="border: 1px dotted navy; -moz-border-radius: 8px; padding: 4px;"> 
     26  <p> <em>Last Subversion commit:</em> <a href="/viewvc?view=rev&amp;revision=[% recent_revision.revision.replace('r','') %]">[% recent_revision.revision %]</a> </p> 
     27  <p><code>[% recent_revision.log | nohtml %]</code></p> 
     28  <p>by [% recent_revision.user %] on [% recent_revision.time %]</p> 
     29</div> 
     30[% END %] 
    2431 <div id="rightcol"> 
    2532  <div class="front-box"> 
     
    4451[% now = time %] 
    4552[% WHILE (u = recent_users.next) %] 
    46 [%# TODO: what the hell is this, it doesn't work at all does it? %] 
    47 [%     IF !loop.first && loop.last.lastactive > now - 600 && loop.prev.lastactive < now - 600 %] | [% END %] 
     53[%#     IF NOT done_user_sep AND last_user AND last_user.lastactive < now - 600; done_user_set = 1 %] | [%# END %] 
    4854<a href="/users/[% u.id %]" title="[% now - u.lastactive | timespan %]">[% u.name %]</a> 
     55[%     last_user = u %] 
    4956[% END %] 
    5057[% IF !recent_users.size %]