aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2010-04-05 22:50:51 +0100
committerSimon McVittie <smcv@debian.org>2010-04-05 22:50:51 +0100
commitcb8b2f80b2f8c91eba3f3a6a5b9913ab80326df8 (patch)
tree9e009b2f7ca8c34c59a1f5ecda786063227f0964 /IkiWiki.pm
parent490f95616a8a49f2120655d07c282eefd067e640 (diff)
downloadikiwiki-cb8b2f80b2f8c91eba3f3a6a5b9913ab80326df8.tar
ikiwiki-cb8b2f80b2f8c91eba3f3a6a5b9913ab80326df8.tar.gz
Use $a and $b for SortSpec cmp callbacks
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm27
1 files changed, 18 insertions, 9 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index d716e8b39..da36494fb 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1975,10 +1975,10 @@ sub sortspec_translate ($) {
if (exists $IkiWiki::SortSpec::{"cmp_$word"}) {
if (defined $params) {
push @data, $params;
- $code .= "IkiWiki::SortSpec::cmp_$word(\@_, \$data[$#data])";
+ $code .= "IkiWiki::SortSpec::cmp_$word(\$data[$#data])";
}
else {
- $code .= "IkiWiki::SortSpec::cmp_$word(\@_, undef)";
+ $code .= "IkiWiki::SortSpec::cmp_$word(undef)";
}
}
else {
@@ -2095,9 +2095,8 @@ sub pagespec_match_list ($$;@) {
}
if (defined $params{sort}) {
- my $f = sortspec_translate($params{sort});
-
- @candidates = sort { $f->($a, $b) } @candidates;
+ @candidates = IkiWiki::SortSpec::sort_pages($params{sort},
+ @candidates);
}
@candidates=reverse(@candidates) if $params{reverse};
@@ -2412,13 +2411,23 @@ sub match_ip ($$;@) {
package IkiWiki::SortSpec;
+# This is in the SortSpec namespace so that the $a and $b that sort() uses
+# $IkiWiki::SortSpec::a and $IkiWiki::SortSpec::b, so that plugins' cmp
+# functions can access them easily.
+sub sort_pages
+{
+ my $f = IkiWiki::sortspec_translate(shift);
+
+ return sort $f @_;
+}
+
sub cmp_title {
- IkiWiki::pagetitle(IkiWiki::basename($_[0]))
+ IkiWiki::pagetitle(IkiWiki::basename($a))
cmp
- IkiWiki::pagetitle(IkiWiki::basename($_[1]))
+ IkiWiki::pagetitle(IkiWiki::basename($b))
}
-sub cmp_mtime { $IkiWiki::pagemtime{$_[1]} <=> $IkiWiki::pagemtime{$_[0]} }
-sub cmp_age { $IkiWiki::pagectime{$_[1]} <=> $IkiWiki::pagectime{$_[0]} }
+sub cmp_mtime { $IkiWiki::pagemtime{$b} <=> $IkiWiki::pagemtime{$a} }
+sub cmp_age { $IkiWiki::pagectime{$b} <=> $IkiWiki::pagectime{$a} }
1