1 Having tried out `field`, some comments (from [[smcv]]):
3 The general concept looks great.
5 The `pagetemplate` hook seems quite namespace-polluting: on a site containing
6 a list of books, I'd like to have an `author` field, but that would collide
7 with IkiWiki's use of `<TMPL_VAR AUTHOR>` for the author of the *page*
8 (i.e. me). Perhaps it'd be better if the pagetemplate hook was only active for
9 `<TMPL_VAR FIELD_AUTHOR>` or something? (For those who want the current
10 behaviour, an auxiliary plugin would be easy.)
12 From a coding style point of view, the `$CamelCase` variable names aren't
13 IkiWiki style, and the `match_foo` functions look as though they could benefit
14 from being thin wrappers around a common `&IkiWiki::Plugin::field::match`
15 function (see `meta` for a similar approach).
17 I think the documentation would probably be clearer in a less manpage-like
18 and more ikiwiki-like style?
20 If one of my branches from [[todo/allow_plugins_to_add_sorting_methods]] is
21 accepted, a `field()` cmp type would mean that [[plugins/contrib/report]] can
22 stop reimplementing sorting. Here's the implementation I'm using, with
23 your "sortspec" concept (a sort-hook would be very similar): if merged,
24 I think it should just be part of `field` rather than a separate plugin.
26 # Copyright © 2010 Simon McVittie, released under GNU LGPL >= 2.1
27 package IkiWiki::Plugin::fieldsort;
31 use IkiWiki::Plugin::field;
34 hook(type => "getsetup", id => "fieldsort", call => \&getsetup);
45 package IkiWiki::PageSpec;
49 error("sort=field requires a parameter");
54 my $left = IkiWiki::Plugin::field::field_get_value($_[2], $_[0]);
55 my $right = IkiWiki::Plugin::field::field_get_value($_[2], $_[1]);
57 $left = "" unless defined $left;
58 $right = "" unless defined $right;
59 return $left cmp $right;