wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r19883: LJSUP-9615.

Committer: gprochaev
LJSUP-9615.

U   trunk/cgi-bin/LJ/Widget/Browse.pm
U   trunk/templates/Browse/recent_posts.tmpl
Modified: trunk/cgi-bin/LJ/Widget/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Browse.pm	2011-08-29 07:50:56 UTC (rev 19882)
+++ trunk/cgi-bin/LJ/Widget/Browse.pm	2011-08-29 10:53:48 UTC (rev 19883)
@@ -67,7 +67,7 @@
         my @journals = map {
             $_->{'userid'},
         } @comms;
-        my @recent_posts = LJ::Browse->search_posts ( comms => \@journals, page_size => 1, vertical => $vertical );
+        my @recent_posts = LJ::Browse->search_posts ( comms => \@journals, page_size => 3, vertical => $vertical );
     } @all_verticals;
 
     return \@posts;
@@ -126,6 +126,8 @@
 
     my $post_count = 0;
     my @tmpl_posts = ();
+    my $vertical = undef;
+    my @temp_array_post = ();
     foreach my $entry_href (@$posts) {
         my $entry = $entry_href->{'entry'};
 
@@ -140,6 +142,9 @@
         $post_count++;
         next if $post_count <= $post_skip || $post_count > $post_last;
 
+        $vertical = LJ::Vertical->new ( vert_id => $entry_href->{'vert_id'} )
+            unless $vertical;
+
         my $logtime = LJ::TimeUtil->mysqldate_to_time($entry->{logtime}, 0);
         my $secondsold = $logtime ? time() - $logtime : undef;
         my $poster = $entry->poster;
@@ -166,9 +171,18 @@
             $sharing_js = LJ::Share->render_js({ 'entry' => $entry });
         }
 
-        my $vertical = LJ::Vertical->new ( vert_id => $entry_href->{'vert_id'} );
+        if ($vertical && $entry_href->{'vert_id'} != $vertical->vert_id) {
+            my @posts = @temp_array_post;
+            push @tmpl_posts, {
+                vertical_name   => $vertical->name,
+                vertical_url    => $vertical->url,
+                vertical_posts  => \@posts,
+            };
+            @temp_array_post = ();
+            $vertical = LJ::Vertical->new ( vert_id => $entry_href->{'vert_id'} );
+        }
 
-        push @tmpl_posts, {
+        push @temp_array_post, {
             subject         => $trimmed_subj,
             is_subject_trimmed => $subject ne $trimmed_subj ? 1 : 0,
             userpic         => $userpic ? $userpic->url : '',
@@ -189,6 +203,12 @@
             vertical_url    => $vertical->url,
         };
     }
+    my @posts = @temp_array_post;
+    push @tmpl_posts, {
+        vertical_name   => $vertical->name,
+        vertical_url    => $vertical->url,
+        vertical_posts  => \@posts,
+    } if @posts;
 
     return {
         posts       => \@tmpl_posts,
@@ -356,7 +376,7 @@
                 };
         }
     } else {
-        unless (@comms) {
+        if (!$vertical && !@comms) {
             my $posts = _get_recent_posts ();
             my $result = render_posts ( $posts, post_skip => $post_skip, post_last => $post_last );
             @tmpl_posts = @{$result->{'posts'}};

Modified: trunk/templates/Browse/recent_posts.tmpl
===================================================================
--- trunk/templates/Browse/recent_posts.tmpl	2011-08-29 07:50:56 UTC (rev 19882)
+++ trunk/templates/Browse/recent_posts.tmpl	2011-08-29 10:53:48 UTC (rev 19883)
@@ -11,6 +11,7 @@
 
 <tmpl_loop posts>
 <tmpl_unless is_vertical_selected><h2 class="title"><a href="<tmpl_var vertical_url>" class="link"><TMPL_VAR expr="ml('widget.browse.more.recent.posts')"></a><tmpl_var vertical_name></h2></tmpl_unless>
+<tmpl_loop vertical_posts>
 <ul class="b-catalogue-list b-recent-posts">
 	<li class="b-catalogue-item">
 		<dl class="b-catalogue-item-header">
@@ -52,6 +53,7 @@
 	</li>
 </ul>
 </tmpl_loop>
+</tmpl_loop>
 
 <TMPL_IF expr="post_pages gt 1">
 	<ul class="b-nav-counter">

Tags: livejournal, pm, tmpl, wisest-owl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments