[interchange-cvs] interchange - kwalsh modified 2 files
interchange-cvs at icdevgroup.org
interchange-cvs at icdevgroup.org
Tue Nov 6 05:20:39 EST 2007
User: kwalsh
Date: 2007-11-06 10:20:39 GMT
Modified: lib/Vend Interpolate.pm
Modified: . WHATSNEW-5.5
Log:
* Fix to the "random" parameter used by looping tags.
-- If set to "no" or "false" then do nothing (previously returned
one random result).
-- If set to "yes" or "true" then then return all results in a
random order (again, previously returned one random result).
-- If set to a numeric > 0 then return that many random results.
-- If set to 0 then return 1 random result (as before).
-- If set to a numeric > the available results then return all
results in a random order (previously returned the original
results in the original order).
If you're using "random=yes" to request one random result then you
will need to change your code to use random=1 instead.
Revision Changes Path
2.289 +5 -4 interchange/lib/Vend/Interpolate.pm
rev 2.289, prev_rev 2.288
Index: Interpolate.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Interpolate.pm,v
retrieving revision 2.288
retrieving revision 2.289
diff -u -r2.288 -r2.289
--- Interpolate.pm 30 Oct 2007 16:27:43 -0000 2.288
+++ Interpolate.pm 6 Nov 2007 10:20:38 -0000 2.289
@@ -1,6 +1,6 @@
# Vend::Interpolate - Interpret Interchange tags
#
-# $Id: Interpolate.pm,v 2.288 2007/10/30 16:27:43 mheins Exp $
+# $Id: Interpolate.pm,v 2.289 2007/11/06 10:20:38 kwalsh Exp $
#
# Copyright (C) 2002-2007 Interchange Development Group
# Copyright (C) 1996-2002 Red Hat, Inc.
@@ -28,7 +28,7 @@
require Exporter;
@ISA = qw(Exporter);
-$VERSION = substr(q$Revision: 2.288 $, 10);
+$VERSION = substr(q$Revision: 2.289 $, 10);
@EXPORT = qw (
@@ -3525,7 +3525,7 @@
my %seen;
my ($j, @out);
my $count = scalar @$ary;
- return (0 .. $#$ary) if $count <= $wanted;
+ $wanted = $count if $wanted > $count;
for($j = 0; $j < $wanted; $j++) {
my $cand = int rand($count);
redo if $seen{$cand}++;
@@ -3582,7 +3582,8 @@
if (defined $obj->{more_in_progress} and $obj->{mv_first_match}) {
$i = $obj->{mv_first_match};
}
- elsif (defined $opt->{random}) {
+ elsif (defined $opt->{random} && $opt->{random} !~ /^[nf]/i) {
+ $opt->{random} = scalar(@$ary) if $opt->{random} =~ /^[yt]/i;
@$ary = @$ary[random_elements($ary, $opt->{random})];
$i = 0; $end = $#$ary;
undef $obj->{mv_matchlimit};
1.66 +19 -0 interchange/WHATSNEW-5.5
rev 1.66, prev_rev 1.65
Index: WHATSNEW-5.5
===================================================================
RCS file: /var/cvs/interchange/WHATSNEW-5.5,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -r1.65 -r1.66
--- WHATSNEW-5.5 17 Sep 2007 05:37:30 -0000 1.65
+++ WHATSNEW-5.5 6 Nov 2007 10:20:39 -0000 1.66
@@ -12,6 +12,25 @@
Core
----
+* Fix to the "random" parameter used by looping tags.
+
+ -- If set to "no" or "false" then do nothing (previously returned
+ one random result).
+
+ -- If set to "yes" or "true" then then return all results in a
+ random order (again, previously returned one random result).
+
+ -- If set to a numeric > 0 then return that many random results.
+
+ -- If set to 0 then return 1 random result (as before).
+
+ -- If set to a numeric > the available results then return all
+ results in a random order (previously returned the original
+ results in the original order).
+
+ If you're using "random=yes" to request one random result then you
+ will need to change your code to use random=1 instead.
+
* Altered the DomainTail directive to take subdomains of various ccTLDs
into account. For example, if "foo.example.co.uk" pays a visit then
"example.co.uk" as the domain tail will be used instead of just "co.uk".
More information about the interchange-cvs
mailing list