]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Have the meta plugin add a meta_title sort order
authorSimon McVittie <smcv@debian.org>
Wed, 24 Mar 2010 00:59:01 +0000 (00:59 +0000)
committerSimon McVittie <smcv@debian.org>
Wed, 24 Mar 2010 03:15:50 +0000 (03:15 +0000)
IkiWiki/Plugin/meta.pm
doc/ikiwiki/pagespec/sorting.mdwn

index 5f046cb2a06e90fdc53939ae2d2b3490d2d4d30e..bf8159814ac61d498917826305a6d083bd2699e4 100644 (file)
@@ -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;
index 9007c23bfc1b38cfd8c2ac5fc9f1ad08db608642..3a9fef9b622c55d7604b7dafc27cdd386eaecde3 100644 (file)
@@ -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"]]