aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2010-04-03 13:57:38 +0100
committerSimon McVittie <smcv@debian.org>2010-04-03 14:28:21 +0100
commit04a59b3c65e8e60805b6ed6d11d448b1d5babe64 (patch)
tree3bd1565e918b1944a18b641f70af48ffc28a2e06
parent75fd08046548940c443c46bcdf9a5b0b6968b175 (diff)
downloadikiwiki-04a59b3c65e8e60805b6ed6d11d448b1d5babe64.tar
ikiwiki-04a59b3c65e8e60805b6ed6d11d448b1d5babe64.tar.gz
Move sort hooks to the IkiWiki::SortSpec namespace
Also rename cmpspec_translate (internal function) to sortspec_translate for consistency.
-rw-r--r--IkiWiki.pm14
-rw-r--r--IkiWiki/Plugin/meta.pm2
-rw-r--r--IkiWiki/Plugin/sortnaturally.pm2
-rw-r--r--doc/plugins/write.mdwn2
-rwxr-xr-xt/pagespec_match_list.t2
5 files changed, 13 insertions, 9 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 7547f1751..d716e8b39 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -37,7 +37,7 @@ our $DEPEND_LINKS=4;
# Optimisation.
use Memoize;
memoize("abs2rel");
-memoize("cmpspec_translate");
+memoize("sortspec_translate");
memoize("pagespec_translate");
memoize("template_file");
@@ -1935,7 +1935,7 @@ sub add_link ($$) {
unless grep { $_ eq $link } @{$links{$page}};
}
-sub cmpspec_translate ($) {
+sub sortspec_translate ($) {
my $spec = shift;
my $code = "";
@@ -1972,13 +1972,13 @@ sub cmpspec_translate ($) {
$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 {
@@ -2095,7 +2095,7 @@ sub pagespec_match_list ($$;@) {
}
if (defined $params{sort}) {
- my $f = cmpspec_translate($params{sort});
+ my $f = sortspec_translate($params{sort});
@candidates = sort { $f->($a, $b) } @candidates;
}
@@ -2410,6 +2410,8 @@ sub match_ip ($$;@) {
}
}
+package IkiWiki::SortSpec;
+
sub cmp_title {
IkiWiki::pagetitle(IkiWiki::basename($_[0]))
cmp
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index e8cc1e392..cd7d0d127 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -348,6 +348,8 @@ sub match_copyright ($$;@) {
IkiWiki::Plugin::meta::match("copyright", @_);
}
+package IkiWiki::SortSpec;
+
sub cmp_meta_title {
IkiWiki::Plugin::meta::titlesort($_[0])
cmp
diff --git a/IkiWiki/Plugin/sortnaturally.pm b/IkiWiki/Plugin/sortnaturally.pm
index 0023f31f9..f498820a5 100644
--- a/IkiWiki/Plugin/sortnaturally.pm
+++ b/IkiWiki/Plugin/sortnaturally.pm
@@ -22,7 +22,7 @@ sub checkconfig () {
error $@ if $@;
}
-package IkiWiki::PageSpec;
+package IkiWiki::SortSpec;
sub cmp_title_natural {
Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($_[0])),
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 06c8f8e44..b67142230 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -1114,7 +1114,7 @@ while "glob(*)" is not influenced by the contents of any page.
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
diff --git a/t/pagespec_match_list.t b/t/pagespec_match_list.t
index 743ae4637..68112f5c0 100755
--- a/t/pagespec_match_list.t
+++ b/t/pagespec_match_list.t
@@ -10,7 +10,7 @@ $config{srcdir}=$config{destdir}="/dev/null";
IkiWiki::checkconfig();
{
- package IkiWiki::PageSpec;
+ package IkiWiki::SortSpec;
sub cmp_path { $_[0] cmp $_[1] }
}