Split out sortnaturally into a plugin
parent
b86276ffed
commit
a875ee8be7
11
IkiWiki.pm
11
IkiWiki.pm
|
@ -2423,15 +2423,4 @@ sub cmp_title {
|
||||||
sub cmp_mtime { $IkiWiki::pagemtime{$_[1]} <=> $IkiWiki::pagemtime{$_[0]} }
|
sub cmp_mtime { $IkiWiki::pagemtime{$_[1]} <=> $IkiWiki::pagemtime{$_[0]} }
|
||||||
sub cmp_age { $IkiWiki::pagectime{$_[1]} <=> $IkiWiki::pagectime{$_[0]} }
|
sub cmp_age { $IkiWiki::pagectime{$_[1]} <=> $IkiWiki::pagectime{$_[0]} }
|
||||||
|
|
||||||
sub check_cmp_title_natural {
|
|
||||||
eval q{use Sort::Naturally};
|
|
||||||
if ($@) {
|
|
||||||
error(gettext("Sort::Naturally needed for title_natural sort"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sub cmp_title_natural {
|
|
||||||
Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($_[0])),
|
|
||||||
IkiWiki::pagetitle(IkiWiki::basename($_[1])))
|
|
||||||
}
|
|
||||||
|
|
||||||
1
|
1
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
# Sort::Naturally-powered title_natural sort order for IkiWiki
|
||||||
|
package IkiWiki::Plugin::sortnaturally;
|
||||||
|
|
||||||
|
use IkiWiki 3.00;
|
||||||
|
no warnings;
|
||||||
|
|
||||||
|
sub import {
|
||||||
|
hook(type => "getsetup", id => "sortnaturally", call => \&getsetup);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub getsetup {
|
||||||
|
return
|
||||||
|
plugin => {
|
||||||
|
safe => 1,
|
||||||
|
rebuild => 1,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
sub checkconfig () {
|
||||||
|
eval q{use Sort::Naturally};
|
||||||
|
error $@ if $@;
|
||||||
|
}
|
||||||
|
|
||||||
|
package IkiWiki::PageSpec;
|
||||||
|
|
||||||
|
sub cmp_title_natural {
|
||||||
|
Sort::Naturally::ncmp(IkiWiki::pagetitle(IkiWiki::basename($_[0])),
|
||||||
|
IkiWiki::pagetitle(IkiWiki::basename($_[1])))
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
|
@ -1,3 +1,11 @@
|
||||||
|
ikiwiki (3.20100320) UNRELEASED; urgency=low
|
||||||
|
|
||||||
|
The sort="title_natural" option on [[!inline]] etc. now requires the
|
||||||
|
new sortnaturally plugin. This is not enabled by default, because it requires
|
||||||
|
the Sort::Naturally module.
|
||||||
|
|
||||||
|
-- Simon McVittie <smcv@debian.org> Sat, 03 Apr 2010 13:46:08 +0100
|
||||||
|
|
||||||
ikiwiki (3.20091017) unstable; urgency=low
|
ikiwiki (3.20091017) unstable; urgency=low
|
||||||
|
|
||||||
To take advantage of significant performance improvements, all
|
To take advantage of significant performance improvements, all
|
||||||
|
|
|
@ -6,9 +6,10 @@ orders can be specified.
|
||||||
* `age` - List pages from the most recently created to the oldest.
|
* `age` - List pages from the most recently created to the oldest.
|
||||||
* `mtime` - List pages with the most recently modified first.
|
* `mtime` - List pages with the most recently modified first.
|
||||||
* `title` - Order by title (page name).
|
* `title` - Order by title (page name).
|
||||||
* `title_natural` - Only available if [[!cpan Sort::Naturally]] is
|
[[!if test="enabled(sortnaturally)" then="""
|
||||||
installed. Orders by title, but numbers in the title are treated
|
* `title_natural` - Orders by title, but numbers in the title are treated
|
||||||
as such, ("1 2 9 10 20" instead of "1 10 2 20 9")
|
as such, ("1 2 9 10 20" instead of "1 10 2 20 9")
|
||||||
|
"""]]
|
||||||
[[!if test="enabled(meta)" then="""
|
[[!if test="enabled(meta)" then="""
|
||||||
* `meta_title` - Order according to the `\[[!meta title="foo" sort="bar"]]`
|
* `meta_title` - Order according to the `\[[!meta title="foo" sort="bar"]]`
|
||||||
or `\[[!meta title="foo"]]` [[ikiwiki/directive]], or the page name if no
|
or `\[[!meta title="foo"]]` [[ikiwiki/directive]], or the page name if no
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
[[!template id=plugin name=sortnaturally core=1 author="[[chrysn]], [[smcv]]"]]
|
||||||
|
[[!tag type/meta]]
|
||||||
|
|
||||||
|
This plugin provides the `title_natural` [[ikiwiki/pagespec/sorting]] order,
|
||||||
|
which uses Sort::Naturally to sort numbered pages in a more natural order.
|
Loading…
Reference in New Issue