diff options
author | Simon McVittie <smcv@debian.org> | 2010-03-24 00:59:01 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2010-03-24 03:15:50 +0000 |
commit | 0618f099dab8bd4f7f47e2695db01eabe49e3316 (patch) | |
tree | c78708de1b55897884bc011ddd0cfe3e2cbb2952 | |
parent | e67a9382f67e745af3be7d367fe7a0d36c1777e6 (diff) | |
download | ikiwiki-0618f099dab8bd4f7f47e2695db01eabe49e3316.tar ikiwiki-0618f099dab8bd4f7f47e2695db01eabe49e3316.tar.gz |
Have the meta plugin add a meta_title sort order
-rw-r--r-- | IkiWiki/Plugin/meta.pm | 15 | ||||
-rw-r--r-- | doc/ikiwiki/pagespec/sorting.mdwn | 7 |
2 files changed, 21 insertions, 1 deletions
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 5f046cb2a..bf8159814 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -13,6 +13,7 @@ sub import { hook(type => "needsbuild", id => "meta", call => \&needsbuild); hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1); hook(type => "pagetemplate", id => "meta", call => \&pagetemplate); + hook(type => "sort", id => "meta_title", call => \&sort_meta_title); } sub getsetup () { @@ -282,6 +283,20 @@ sub pagetemplate (@) { } } +sub title { + my $title = $pagestate{$_[0]}{meta}{title}; + + if (defined $title) { + return $title; + } + + return pagetitle(IkiWiki::basename($_[0])); +} + +sub sort_meta_title { + return title($_[0]) cmp title($_[1]); +} + sub match { my $field=shift; my $page=shift; diff --git a/doc/ikiwiki/pagespec/sorting.mdwn b/doc/ikiwiki/pagespec/sorting.mdwn index 9007c23bf..3a9fef9b6 100644 --- a/doc/ikiwiki/pagespec/sorting.mdwn +++ b/doc/ikiwiki/pagespec/sorting.mdwn @@ -9,7 +9,12 @@ orders can be specified. * `title_natural` - Only available if [[!cpan Sort::Naturally]] is installed. Orders by title, but numbers in the title are treated as such, ("1 2 9 10 20" instead of "1 10 2 20 9") +[[!if test="enabled(meta)" then=""" +* `meta_title` - Order by the full title set by the `\[[!meta title="foo"]]` + [[ikiwiki/directive]]. +"""]] -Plugins can add additional sort orders. +Plugins can add additional sort orders, so more might be available on this +wiki. [[!meta robots="noindex, follow"]] |