]> scripts.mit.edu Git - www/ikiwiki.git/blobdiff - doc/todo/allow_plugins_to_add_sorting_methods.mdwn
relationship with [[plugins/contrib/report]]
[www/ikiwiki.git] / doc / todo / allow_plugins_to_add_sorting_methods.mdwn
index 3aa1d94a61e382be4689b1ba80805cc98657e431..21800f4ded3f2d4098e25b099f325aa16be3f3c1 100644 (file)
@@ -14,6 +14,32 @@ and changing the meaning of sort=title in 4.0, though).
 Gitweb:
 <http://git.pseudorandom.co.uk/smcv/ikiwiki.git?a=shortlog;h=refs/heads/sort-hooks>
 
+I briefly tried to turn *all* the current sort types into hook functions, and
+have some of them pre-registered, but decided that probably wasn't a good idea.
+That earlier version of the branch is also available for comparison:
+
+<http://git.pseudorandom.co.uk/smcv/ikiwiki.git?a=shortlog;h=refs/heads/sort-hooks-excessive>
+
+(The older version is untested, and probably doesn't really work as-is - I
+misunderstood the details of how the built-in function `sort` works when using
+`$a` and `$b`. The newer version has been tested, and has a regression test for
+its core functionality.)
+
+This hook *isn't* (yet) sufficient to implement [[plugins/contrib/report]]'s
+NIH'd sorting mechanisms:
+
+* `report` can sort by any [[plugins/contrib/field]], whereas this one has a
+  finite number of hooks: if the `field` plugin's functionality is desirable,
+  perhaps parameterized sort mechanisms similar to pagespec match functions
+  would be useful? Then the `field` plugin could register
+  `hook(type => "sort", id => "field")` and you could have
+  `\[[!inline ... sort="field(Mood)"]]` or something?
+
+* `report` can sort by multiple criteria, with independent direction-changing:
+  if this is desirable, perhaps `pagespec_match_list` could be enhanced to
+  interpret `sort="x -y z(w)"` as sorting by (pseudocode)
+  `{ $cmp_x->($a, $b) || (-$cmp_y->($a, $b)) || $cmp_z->($a, $b, "w") }`?
+
 ## Documentation extracted from the branch
 
 ### sort hook (added to [[plugins/write]])