# Optimisation.
use Memoize;
memoize("abs2rel");
-memoize("cmpspec_translate");
+memoize("sortspec_translate");
memoize("pagespec_translate");
memoize("template_file");
unless grep { $_ eq $link } @{$links{$page}};
}
-sub cmpspec_translate ($) {
+sub sortspec_translate ($) {
my $spec = shift;
my $code = "";
$code .= "-";
}
- if (exists $IkiWiki::PageSpec::{"cmp_$word"}) {
+ if (exists $IkiWiki::SortSpec::{"cmp_$word"}) {
if (defined $params) {
push @data, $params;
- $code .= "IkiWiki::PageSpec::cmp_$word(\@_, \$data[$#data])";
+ $code .= "IkiWiki::SortSpec::cmp_$word(\@_, \$data[$#data])";
}
else {
- $code .= "IkiWiki::PageSpec::cmp_$word(\@_, undef)";
+ $code .= "IkiWiki::SortSpec::cmp_$word(\@_, undef)";
}
}
else {
}
if (defined $params{sort}) {
- my $f = cmpspec_translate($params{sort});
+ my $f = sortspec_translate($params{sort});
@candidates = sort { $f->($a, $b) } @candidates;
}
}
}
+package IkiWiki::SortSpec;
+
sub cmp_title {
IkiWiki::pagetitle(IkiWiki::basename($_[0]))
cmp
Similarly, it's possible to write plugins that add new functions as
[[ikiwiki/pagespec/sorting]] methods. To achieve this, add a function to
-the IkiWiki::PageSpec package named `cmp_foo`, which will be used when sorting
+the IkiWiki::SortSpec package named `cmp_foo`, which will be used when sorting
by `foo` or `foo(...)` is requested.
The function will be passed three or more parameters. The first two are