fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-11-17 04:43 am

[dw-free] Filter by multiple tags

[commit: http://hg.dwscoalition.org/dw-free/rev/680147b0e586]

http://bugs.dwscoalition.org/show_bug.cgi?id=1585

Make sure that changes to tag mode are carried over to next/previous pages.
Some refactoring for common code.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/DW/Logic/LogItems.pm
  • cgi-bin/LJ/S2/RecentPage.pm
--------------------------------------------------------------------------------
diff -r 01b24e83f294 -r 680147b0e586 cgi-bin/DW/Logic/LogItems.pm
--- a/cgi-bin/DW/Logic/LogItems.pm	Tue Nov 16 17:38:12 2010 -0600
+++ b/cgi-bin/DW/Logic/LogItems.pm	Wed Nov 17 12:42:57 2010 +0800
@@ -450,6 +450,8 @@ sub recent_items
         if ( $args{tagmode} eq 'and' ) {
 
             my $limit = $LJ::TAG_INTERSECTION;
+            die "\$LJ::TAG_INTERSECTION not set!"
+                unless $limit && $limit > 0;
             my $need = scalar @{ $args{tagids} };
             $#{ $args{tagids} } = $limit - 1 if $need > $limit;
 
diff -r 01b24e83f294 -r 680147b0e586 cgi-bin/LJ/S2/RecentPage.pm
--- a/cgi-bin/LJ/S2/RecentPage.pm	Tue Nov 16 17:38:12 2010 -0600
+++ b/cgi-bin/LJ/S2/RecentPage.pm	Wed Nov 17 12:42:57 2010 +0800
@@ -227,18 +227,26 @@ sub RecentPage
         'count' => $itemnum,
     };
 
+    my %valid_modes = ( all => 'all', and => 'all' );
+    my $tagmode = $valid_modes{$get->{mode} || ''};
+
+    # these are the same for both previous and next links
+    my %linkattrs = ( style    => $mine                        || "",
+                      mode     => $tagmode                     || "",
+                      s2id     => LJ::eurl( $get->{s2id} )     || "",
+                      tag      => LJ::eurl( $get->{tag} )      || "",
+                      security => LJ::eurl( $get->{security} ) || "",
+                      poster   => $posteru_filter ?
+                                  $posteru_filter->user         : "",
+                    );
+
     # if we've skipped down, then we can skip back up
     if ($skip) {
         my $newskip = $skip - $itemshow;
         $newskip = 0 if $newskip <= 0;
         $nav->{'forward_skip'} = $newskip;
         $nav->{'forward_url'} = LJ::make_link( "$p->{'base_url'}/",
-                                { skip     => $newskip                        || "",
-                                  style    => $mine                           || "",
-                                  s2id     => LJ::eurl( $get->{s2id} )        || "",
-                                  tag      => LJ::eurl( $get->{tag} )         || "",
-                                  security => LJ::eurl( $get->{security} )    || "",
-                                  poster   => $posteru_filter ? $posteru_filter->user : "" } );
+                                { skip => $newskip || "", %linkattrs } );
         $nav->{'forward_count'} = $itemshow;
         $p->{head_content} .= qq{<link rel="next" href="$nav->{forward_url}" />\n}
     }
@@ -255,12 +263,7 @@ sub RecentPage
         } elsif ($is_prev_exist) {
             my $newskip = $skip + $itemshow;
             $nav->{'backward_url'} = LJ::make_link( "$p->{'base_url'}/",
-                                     { skip     => $newskip                        || "",
-                                       style    => $mine                           || "",
-                                       s2id     => LJ::eurl( $get->{s2id} )        || "",
-                                       tag      => LJ::eurl( $get->{tag} )         || "",
-                                       security => LJ::eurl( $get->{security} )    || "",
-                                       poster   => $posteru_filter ? $posteru_filter->user : "" } );
+                                { skip => $newskip || "", %linkattrs } );
             $nav->{'backward_skip'} = $newskip;
         }
         $p->{head_content} .= qq{<link rel="prev" href="$nav->{backward_url}" />\n};
--------------------------------------------------------------------------------
turlough: Prince Caspian & Trumpkin dancing with fauns, art by Pauline Baynes from 'Prince Caspian' ((narnia) celebration)

[personal profile] turlough 2010-11-17 10:24 pm (UTC)(link)
Filter by multiple tags

WHEEEEEEEEEEEE!!!!!!!!!!!!!!!