Changeset 407
- Timestamp:
- 02/09/08 02:53:35 (2 years ago)
- Location:
- veekun/trunk
- Files:
-
- 8 modified
-
README.pod (modified) (2 diffs)
-
lib/Vee.pm (modified) (3 diffs)
-
lib/Vee/Controller/Index.pm (modified) (1 diff)
-
lib/Vee/Controller/Root.pm (modified) (3 diffs)
-
lib/Vee/View/TT.pm (modified) (5 diffs)
-
site_options.yml (modified) (2 diffs)
-
templates/index.tt (modified) (2 diffs)
-
templates/style/index.tt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
veekun/trunk/README.pod
r256 r407 28 28 Catalyst::Plugin::Session::State::Cookie 29 29 Catalyst::Plugin::Session::Store::DBIC 30 Catalyst::Plugin::Unicode 30 31 DBIx::Class 31 32 DBIx::Class::QueryLog … … 38 39 String::Approx 39 40 Template 41 XML::Feed 40 42 YAML 41 43 -
veekun/trunk/lib/Vee.pm
r328 r407 11 11 -Debug 12 12 StackTrace 13 Static::Simple 13 Static::Simple 14 14 15 15 ConfigLoader 16 Unicode 16 17 17 18 Authentication … … 67 68 { 68 69 # WARNING: HERE BE DRAGONS, AND BY DRAGONS I MEAN HACKS 69 # TODO: WHAT THE FUCK CLEAN THIS GARBAGE UP WITH PLUGINS OR SOMETHING 70 71 no strict 'refs'; 70 no warnings 'redefine'; 72 71 73 72 # I find myself doing this a lot and it's a bit cumbersome 74 * {'DBIx::Class::ResultSet::is_empty'}= sub {73 *DBIx::Class::ResultSet::is_empty = sub { 75 74 my ($self) = @_; 76 75 my $first = $self->first; … … 82 81 # conditions with critical code like this. 83 82 # CAVEAT EMPTOR: may break if you upgrade 84 * {'DBIx::Class::ResultSet::find_or_create'}= sub {83 *DBIx::Class::ResultSet::find_or_create = sub { 85 84 my $self = shift; 86 85 my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}); -
veekun/trunk/lib/Vee/Controller/Index.pm
r406 r407 70 70 $s->{is_unread} = sub { $unread_hash{$_[0]->id} }; 71 71 } 72 73 # check for latest subversion revision every 15 minutes or so74 if (not $c->cache->{svn} or $c->cache->{svn}{last_checked} < time - 15 * 60) {75 eval {76 open my $svn_fh, '-|', 'svn', 'log', '--limit' => 1, '--incremental', $c->site_opts->{svn_url};77 my (undef, $details, undef, @log) = <$svn_fh>;78 close $svn_fh;79 my ($rev, $user, $time, undef) = split / \| /, $details;80 $rev =~ s/^r//;81 my ($yr, $mo, $day, $hr, $min, $sec, $tz) = split /[- :]/, $time, 7;82 83 $c->cache->{svn} = {84 revision => $rev,85 user => $user,86 time => new DateTime(87 year => $yr,88 month => $mo,89 day => $day,90 hour => $hr,91 minute => $min,92 second => $sec,93 time_zone => substr $tz, 0, 5,94 ),95 last_checked => time,96 log => join '', @log,97 }98 };99 }100 101 $s->{recent_revision} = $c->cache->{svn};102 72 103 73 $s->{recent_users} = $c->model('DBIC::Users')->search( 104 74 { time_active => { '>', time - $c->site_opts->{user_activity_timeout} } }, 105 75 { order_by => 'me.time_active DESC' } 106 ); 76 ); 107 77 108 78 my $shoutbox_form = Vee::Form->new( -
veekun/trunk/lib/Vee/Controller/Root.pm
r406 r407 5 5 use base 'Catalyst::Controller'; 6 6 7 use Time::HiRes;8 7 use Data::Dumper; 9 8 use DBIx::Class::QueryLog; 10 9 use File::Path; 10 use Time::HiRes; 11 use URI; 12 use XML::Feed; 13 11 14 use Vee::Authorization; 12 15 use Vee::Utils; … … 54 57 $s->{$_} = $c->flash->{$_} for qw/error_msg info_msg success_msg/; 55 58 } 59 60 $self->_do_periodic_tasks($c); 56 61 57 62 return 1; … … 233 238 } 234 239 240 =head2 _do_periodic_tasks 241 242 Performs various actions if they haven't been done for some amount of time. 243 244 Regular method! Not an action. 245 246 =cut 247 248 sub _do_periodic_tasks 249 { 250 my ($self, $c) = @_; 251 252 if ($c->{cache}{_last_performed} and 253 $c->{cache}{_last_performed} > time - 15 * 60) 254 { 255 next; 256 } 257 258 # Last subversion commit 259 eval { 260 open my $svn_fh, '-|', 'svn', 'log', '--limit' => 1, '--incremental', $c->site_opts->{svn_url}; 261 my (undef, $details, undef, @log) = <$svn_fh>; 262 close $svn_fh; 263 my ($rev, $user, $time, undef) = split / \| /, $details; 264 $rev =~ s/^r//; 265 my ($yr, $mo, $day, $hr, $min, $sec, $tz) = split /[- :]/, $time, 7; 266 267 $c->cache->{svn} = { 268 revision => $rev, 269 user => $user, 270 time => new DateTime( 271 year => $yr, 272 month => $mo, 273 day => $day, 274 hour => $hr, 275 minute => $min, 276 second => $sec, 277 time_zone => substr $tz, 0, 5, 278 ), 279 log => join '', @log, 280 }; 281 }; 282 283 # Refresh Bulbapedia feeds 284 eval { 285 Vee::Utils::timed_exec( 5 => sub { 286 my $uri = URI->new($c->site_opts->{rss_url}); 287 my @entries = XML::Feed->parse($uri)->entries; 288 @entries = grep { defined } 289 @entries[ 0 .. $c->site_opts->{page_sizes}{index}{rss} - 1 ]; 290 $c->cache->{rss_entries} = \@entries; 291 } ); 292 }; 293 294 $c->cache->{_last_performed} = time; 295 } 296 235 297 =head1 AUTHOR 236 298 -
veekun/trunk/lib/Vee/View/TT.pm
r388 r407 4 4 use base 'Catalyst::View::TT'; 5 5 6 use Vee::Utils; 7 use Time::HiRes; 6 use DateTime; 8 7 use File::Temp qw/tempdir/; 9 8 use Template::Namespace::Constants; 10 9 use Template::Stash; 10 use Time::HiRes; 11 12 use Vee::Utils; 11 13 12 14 if (Vee->debug) { … … 45 47 postbar_color => sub { Vee::Utils::hsv2rgb(shift, 84, 192) }, 46 48 49 format_time => \&format_time, 50 47 51 # forum stuff... 48 52 # allowed_postedit => sub { return !$self->test_postedit(@_) }, … … 61 65 bbcode => \&Vee::BBCode::apply_bbcode, 62 66 timespan => \&_format_timespan, 63 date => \& _format_date, # later this may have to change to use user's date prefs67 date => \&format_time, # later this may have to change to use user's date prefs 64 68 email => \&_obfuscate_email, 65 69 # wordcap => \&Vee::wordcap, … … 92 96 } 93 97 94 =head2 _format_date98 =head2 format_time 95 99 96 100 Returns a pretty-printed version of the given UNIX-style timestamp. … … 99 103 100 104 # TODO: add options for this 101 sub _format_date { 102 my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(shift); 103 return sprintf "%02d/%02d/%02d %02d:%02d", $mon+1, $mday, substr($year, -2), $hour, $min; 105 sub format_time { 106 my ($time) = @_; 107 if (not ref $time) { 108 $time = DateTime->from_epoch( epoch => $time, time_zone => 'floating' ); 109 } 110 111 return $time->strftime('%D %R'); 104 112 } 105 113 -
veekun/trunk/site_options.yml
r374 r407 78 78 forum: 20 79 79 users: 25 80 rss: 3 80 81 posts: 20 81 82 posts_preview: 3 … … 103 104 # Note that at the moment this *requires* anon access! 104 105 svn_url: svn://veekun.com/veekun 106 107 # URL for RSS feed on the front page and the site behind it 108 rss_url: http://bulbanews.bulbagarden.net/feed/news.rss 109 rss_site_url: http://bulbanews.bulbagarden.net/ 105 110 106 111 # Number of posts => rank you get -
veekun/trunk/templates/index.tt
r406 r407 28 28 <div id="leftcol"> 29 29 <div class="front-box"> 30 <a href="[% c.site_opts.rss_site_url %]" class="heading"><img src="/images/icons/index/news.png" alt="" class="icon"/> Pokémon News</a> 31 [% FOR feed_entry IN c.cache.rss_entries %] 32 <div class="front-feedentry"> 33 <div class="title"> <a href="[% feed_entry.link %]">[% feed_entry.title %]</a> </div> 34 <div class="time"> [% format_time(feed_entry.issued) %] </div> 35 <p class="summary"> [% feed_entry.content.body | nohtml %] </p> 36 </div> 37 [% END %] 38 [% IF NOT c.cache.rss_entries %] 39 <p> No Pokémon news. </p> 40 [% END %] 41 </div> 42 <div class="front-box"> 30 43 <a href="/forum/[% c.site_opts.special_forums.news %]" class="heading"><img src="/images/icons/index/news.png" alt="" class="icon"/> News</a> 31 44 [% WHILE (t = recent_news.next) %] 32 45 <div class="front-newspost"> 46 <div class="time">[% format_time(t.first_post.time) %]</div> 33 47 <a href="/users/[% t.first_post.user_id %]" class="icon">[% IF t.first_post.user.news_pic %]<img src="/images/news/[% t.first_post.user.news_pic %]" alt="[% t.first_post.user.name %]" title="[% t.first_post.user.name %]"/>[% ELSE; t.first_post.user.name; END %]</a> 34 <div class="date">[% format_date(t.first_post.time) %]</div>35 48 <div class="title">[% t.subject %]</div> 36 49 <div class="body">[% t.first_post.content | bbcode %]</div> … … 113 126 [% END %] 114 127 </div> 115 <div class="front-box"> 116 <a href="/forum/" class="heading"><img src="/images/icons/index/news.png" alt="" class="icon"/> Pokémon News</a> 117 <p> hold yer horses </p> 118 </div> 119 [% IF recent_revision %] 128 [% IF c.svn %] 120 129 <div class="front-box"> 121 130 <a href="http://trac.veekun.com/browser/veekun/trunk" class="heading"><img src="/images/icons/index/svn.png" alt="" class="icon"/>Subversion</a> 122 <p class="svncommit-revision"> <em>Last Subversion commit:</em> <a href="http://trac.veekun.com/changeset/[% recent_revision.revision.replace('r','') %]">[% recent_revision.revision %]</a> </p>123 <p class="svncommit-log">[% recent_revision.log | nohtml %]</p>124 <p class="svncommit-stamp">by [% recent_revision.user %] on [% recent_revision.time%]</p>131 <p class="svncommit-revision"> <em>Last Subversion commit:</em> <a href="http://trac.veekun.com/changeset/[% c.svn.revision.replace('r','') %]">[% c.svn.revision %]</a> </p> 132 <p class="svncommit-log">[% c.svn.log | nohtml %]</p> 133 <p class="svncommit-stamp">by [% c.svn.user %] on [% format_time(c.svn.time) %]</p> 125 134 </div> 126 135 [% END %] -
veekun/trunk/templates/style/index.tt
r287 r407 18 18 .front-forum a { display: block; } 19 19 20 .front-feedentry { padding: 3px; clear: right; } 21 .front-feedentry + .front-feedentry { border-top: 1px dotted [% dark_separator %]; } 22 .front-feedentry .title { font-size: bigger; font-weight: bold; float: left; } 23 .front-feedentry .time { float: right; font-size: 85%; } 24 .front-feedentry .summary { margin: 0.5em; clear: both; } 25 20 26 .front-newspost { padding: 3px; clear: right; } 21 27 .front-newspost + .front-newspost { border-top: 1px dotted [% dark_separator %]; } 22 .front-newspost . icon { float: right; padding: 3px 3px 0 0; }23 .front-newspost . date { float: right; font-size: 85%; }28 .front-newspost .time { float: right; font-size: 85%; } 29 .front-newspost .icon { float: right; clear: right; padding: 3px 3px 0 0; } 24 30 .front-newspost .title { color: [% header_text %]; font-size: bigger; font-weight: bold; } 25 31 .front-newspost .body { margin: 0.5em; }
