Changeset 5

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

Added: Forum view (thread list) is now paged.
Changed: While I was at it, shuffled options around because the names made me sick. Paging options are now in a subhash called page_sizes.

Location:
veekun
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • veekun/lib/Vee/Controller/Forum.pm

    r1 r5  
    6767        or $c->vee_abort('There is no forum with id ' . $c->vee_cleanse($id) . '.  You may have followed an old link, or might be playing with URLs.'); 
    6868 
    69     $s->{page_title } = $forum->name . ' - Forums'; 
     69    my $skip = $c->req->params->{skip} || 0; 
     70    my $perpage = $c->site_opts->{page_sizes}{threads}; 
     71 
     72    $s->{page_title}  = $forum->name . ' - Forums'; 
    7073    $s->{page_header} = $forum->name; 
    71     $s->{link_name  } = 'forum'; 
    72     $s->{extra_css  } = 'forum'; 
    73     $s->{crumbs     } = [ '<a href="/forum">Forum Index</a>', '<a href="/forum/'.$forum->id.'">'.$forum->name.'</a>' ]; 
     74    $s->{link_name = 'forum'; 
     75    $s->{extra_css = 'forum'; 
     76    $s->{crumbs}      = [ '<a href="/forum">Forum Index</a>', '<a href="/forum/'.$forum->id.'">'.$forum->name.'</a>' ]; 
    7477 
    7578    $s->{announcements} = [ $c->model('DBIC::Threads')->search_announcements ]; 
    76     $s->{forum        } = $forum; 
    77     $s->{threads      } = [ $forum->search_related('threads', \ 'NOT FIND_IN_SET("deleted", me.flags)', { order_by => 'FIND_IN_SET("sticky", me.flags) > 0 DESC, lastpost.time DESC', prefetch => { firstpost => 'user', lastpost => 'user' } }) ]; 
     79    $s->{forum}         = $forum; 
     80    $s->{threads}       = [ $forum->search_related('threads', \ 'NOT FIND_IN_SET("deleted", me.flags)', { 
     81        order_by => 'FIND_IN_SET("sticky", me.flags) > 0 DESC, lastpost.time DESC', 
     82        prefetch => { firstpost => 'user', lastpost => 'user' }, 
     83        offset => $skip, 
     84        rows => $perpage, 
     85    } ) ]; 
    7886 
    7987    $s->{template} = 'forum/view.tt'; 
     
    113121    } 
    114122     
    115     my $perpage = $c->site_opts->{perpage_posts}; 
     123    my $perpage = $c->site_opts->{page_sizes}{posts}; 
    116124    my $lastpage = ($skip + $perpage >= $thread->postct); 
    117     #my @posts = $c->model('DBIC::Posts')->search({ threadid => $id, ( $filter_user ? ( userid => $filter_user->id ) : () ) }, { order_by => 'me.time ASC', prefetch => [ 'user', { lastedit => 'user' } ], page => $skip / $perpage, rows => $perpage } ); 
    118125    my @posts = $c->model('DBIC::Posts')->search( 
    119126        { 'me.threadid' => $id, ( $filter_user ? ( 'me.userid' => $filter_user->id ) : () ) }, 
     
    141148    $s->{postbar_color} = sub { Vee::Utils::hsv2rgb(shift, 192, 192) }; # Remove after making global 
    142149 
    143     # probably don't want announcements here?  not in template anyway 
    144     #$s->{announcements} = [ $c->model('DBIC::Threads')->search_announcements ]; 
    145150    $s->{forum}       = $thread->forum; 
    146151    $s->{thread}      = $thread; 
     
    150155#    $s->{can_post    = !$sess->test_post($thread, $thread->forumid), 
    151156    $s->{skip}        = $skip; 
    152     $s->{perpage}     = $perpage; 
    153157    $s->{filter}      = $filter; 
    154158 
     
    174178        ], 
    175179    }); 
    176     my $perpage = $c->site_opts->{perpage_posts}; 
     180    my $perpage = $c->site_opts->{page_sizes}{posts}; 
    177181    my $skip = $offset - $offset % $perpage; 
    178182    $c->res->redirect( $c->uri('Forum', 'thread', $post->threadid, ($skip ? { skip => $skip } : ()) ) . "#p$id" ); 
  • veekun/lib/Vee/Controller/Index.pm

    r1 r5  
    4141 
    4242    # TODO: omit deleted postses: by thread or post or what? 
    43     my $news_forum = $c->model('DBIC::Forums')->find( $c->site_opts->{index_news_forum} ); 
    44     $s->{recent_news  } = [ $news_forum->threads( undef, { prefetch => 'firstpost', order_by => 'me.id DESC', rows => $c->site_opts->{index_news_count} } ) ]; 
    45     $s->{recent_shouts} = [ $c->model('DBIC::Shoutbox')->search( undef,  { order_by => 'me.time DESC', rows => $c->site_opts->{index_shout_count} } ) ]; 
    46     $s->{recent_art   } = [ $c->model('DBIC::Gallery')->search( undef, { order_by => 'me.time DESC', rows => $c->site_opts->{index_gallery_count} } ) ]; 
     43    my $news_forum = $c->model('DBIC::Forums')->find( $c->site_opts->{special_forums}{news} ); 
     44    my $page_sizes = $c->site_opts->{page_sizes}; 
     45    $s->{recent_news  } = [ $news_forum->threads( undef, { prefetch => 'firstpost', order_by => 'me.id DESC', rows => $page_sizes->{news} } ) ]; 
     46    $s->{recent_shouts} = [ $c->model('DBIC::Shoutbox')->search( undef,  { order_by => 'me.time DESC', rows => $page_sizes->{shoutbox} } ) ]; 
     47    $s->{recent_art   } = [ $c->model('DBIC::Gallery')->search( undef, { order_by => 'me.time DESC', rows => $page_sizes->{gallery} } ) ]; 
    4748    $s->{recent_posts } = [ $c->model('DBIC::Threads')->search( undef, { 
    4849        order_by => 'lastpost.time DESC', 
    49         rows => $c->site_opts->{index_posts_count}, 
     50        rows => $page_sizes->{forum}, 
    5051        prefetch => { 'lastpost' => 'user' } 
    5152    } ) ]; 
    5253 
    5354    $s->{recent_users } = [ $c->model('DBIC::Users')->search( 
    54         { lastactive => { '>', time - $c->site_opts->{stat_user_activetime} } }, 
     55        { lastactive => { '>', time - $c->site_opts->{user_activity_timeout} } }, 
    5556        { order_by => 'me.lastactive DESC' } 
    5657    ) ];     
  • veekun/lib/Vee/Controller/Shoutbox.pm

    r1 r5  
    4242            order_by => 'time DESC', 
    4343            prefetch => ['user'], 
    44             rows     => $c->site_opts->{shoutbox_page}, 
     44            rows     => $c->site_opts->{page_sizes}{shoutbox}, 
    4545            offset   => $skip, 
    4646        } 
  • veekun/lib/Vee/Controller/Users.pm

    r1 r5  
    189189     
    190190    my @recent_users = $c->model('DBIC::Users')->search( 
    191             { lastactive => { '>', time - $c->site_opts->{stat_user_activetime} } }, 
     191            { lastactive => { '>', time - $c->site_opts->{user_activity_timeout} } }, 
    192192            { order_by => 'me.lastactive DESC' } 
    193193    ); 
     
    199199    # TODO: these are probably completely unnecessary 
    200200     
    201     $s->{postrank     } = sub { Vee::Utils::postrank(shift, $c->site_opts->{postranks}) }; 
     201    $s->{postrank     } = sub { Vee::Utils::postrank(shift, $c->site_opts->{post_ranks}) }; 
    202202    $s->{postwidth    } = \&Vee::Utils::post_width; 
    203203    $s->{postbar_color} = sub { Vee::Utils::hsv2rgb(shift, 192, 192) }; 
     
    226226 
    227227    # TODO: these are probably completely unnecessary 
    228     $s->{postrank} = sub { Vee::Utils::postrank(shift, $c->site_opts->{postranks}) }; 
     228    $s->{postrank} = sub { Vee::Utils::postrank(shift, $c->site_opts->{post_ranks}) }; 
    229229    $s->{postwidth} = \&Vee::Utils::post_width; 
    230230    $s->{postbar_color} = sub { Vee::Utils::hsv2rgb(shift, 192, 192) }; 
  • veekun/site_options.yml

    r1 r5  
    4343#   news link 
    4444 
     45# Numbers of certain thingies to show per page. 
     46page_sizes: 
     47    index: 
     48        # Boxes on the index page 
     49        shoutbox: 10 
     50        news: 5 
     51        gallery: 10 
     52        forum: 20 
     53        users: 10 
     54    posts: 20 
     55    shoutbox: 50 
     56    threads: 30 
     57    users: 50 
    4558 
    46 index_news_forum: 1 
    47 index_news_count: 5 
    48 index_shout_count: 10 
    49 index_gallery_count: 10 
    50 index_posts_count: 20 
     59# Forum ids of some forums used for non-forum purposes. 
     60special_forums: 
     61    news: 1 
    5162 
    52 shoutbox_page: 50 
     63# Number of seconds before a user is considered inactive 
     64user_activity_timeout: 900 
    5365 
    54 userlist_page: 10 
    55  
    56 stat_user_activetime: 900 
    57  
    58 perpage_posts: 20 
    59 perpage_threads: 30 
    60  
     66# Number of posts => rank you get 
    6167postranks: 
    6268    0: Uninterested 
  • veekun/templates/forum/thread/view.tt

    r1 r5  
    44[% IF thread.blurb %]<div class="forum-blurb">[% thread.blurb %]</div>[% END %] 
    55<div class="forum-postct">[% thread.postct %] post[% 's' IF thread.postct != 1 %], [% thread.hitct %] view[% 's' IF thread.hitct != 1 %]</div> 
    6 [% pagelist(skip, perpage, thread.postct, c.uri('Forum', 'thread', thread.id), c.req.params) %] 
     6[% this_pagelist = pagelist(skip, c.site_opts.page_sizes.posts, thread.postct, c.uri('Forum', 'thread', thread.id), c.req.params); this_pagelist %] 
    77[% INCLUDE posts_start %] 
    88[% FOREACH p IN posts %] 
     
    4343</div> 
    4444[% END %] 
    45 [% page_list %] 
     45[% this_pagelist %] 
    4646 
    4747[% IF can_post(thread) %] 
  • veekun/templates/forum/view.tt

    r1 r5  
     1[% PROCESS 'common.tt' %] 
    12[% PROCESS 'forum/common.tt' %] 
    23 
    34[% IF forum.blurb %]<div class="forum-blurb">[% forum.blurb %]</div>[% END %] 
     5[% this_pagelist = pagelist(skip, c.site_opts.page_sizes.threads, forum.threadct, c.uri('Forum', 'forum', forum.id), c.req.params); this_pagelist %] 
    46[% INCLUDE show_announcements announcements=announcements %] 
    57[% forum_flags = BLOCK %] 
     
    1719[% INCLUDE threads_end %] 
    1820[% forum_flags %] 
     21[% this_pagelist %] 
    1922 
    2023<h1>Create a new thread</h1> 
  • veekun/templates/shoutbox.tt

    r1 r5  
    77 
    88<p class="total center">[% shout_total %] shoutbox comments total</p> 
    9 [% pagelist(skip, c.site_opts.shoutbox_page, shout_total, '/shoutbox', {}) %] 
    10  
    11 <!-- hay vee throw in some IPs and stuff I dunno? --> 
     9[% pagelist(skip, c.site_opts.page_sizes.shoutbox, shout_total, '/shoutbox', {}) %] 
    1210 
    1311[% can_nuke = has_permission('shoutbox_nuke') %]