1 Could you please add numerical ordering by title to [[inline|plugins/inline]]
2 plugin? Now I can do only alphabetical order by title, but sometime it's not enough.
4 BTW, it seems that ordering by title is rather ordering by filename of page.
5 For me "title" means title of page I can set using `title` parameter
6 of [[meta|plugins/meta]] plugin :)
8 Why do I need that feature? I've just been migrating an info site of our university
9 [mail system](http://poczta.uw.edu.pl/) to Ikiwiki from very static, console handling
10 Makefile+[WML](http://thewml.org/)+XML+XSL=HTML solution. I have many news files
11 (`1.mdwn`, `2.mdwn`, etc.) and unfortunately I did very stupid thing. I've commited
12 all of them in the same revision of our Subversion repo...
14 Now I have a problem with sorting these files using inline plugin. I can't do
15 sorting by age, because both old and young news files have the same age. I can't
16 sort by title too. For example, when I sort them by title, then `9.mdwn` page is
17 between `90.mdwn` and `89.mdwn` pages... It sucks, of course. Sorting by mtime
18 also is not a solution for me, because it means that I can't touch/fix old news
21 Do you have any idea how to workaround that issue? --[[Paweł|ptecza]]
23 > Maybe you can rename `9.mdwn` to `09.mdwn`? See `rename(1)`, it renames multiple files
24 > in one go. --[[buo]]
26 >> Thanks for your suggestion! But what about if number of my news files grows to 100+?
29 >> 09.mdwn 100.mdwn 101.mdwn 102.mdwn 89.mdwn 90.mdwn
31 >> I don't want to rename all previous files to add `0` prefix. --[[Paweł|ptecza]]
33 >>> Rather than adding 0's or or a 'sorttype' parameter, I'd just fix the sort order.
34 >>> Both MacOS and Windows use a smarter sort order than just lexical in their
35 >>> file browsers (e.g. <http://support.microsoft.com/default.aspx?kbid=319827>,
36 >>> <http://docs.info.apple.com/article.html?artnum=300989>).
38 >>> The [Unicode Collation algorithm](http://en.wikipedia.org/wiki/Unicode_collation_algorithm)
39 >>> would seem to be a reasonable sort order. (See also <http://www.unicode.org/unicode/reports/tr10/>.)
40 >>> Unfortunately the standard perl implementation, [Unicode::Collate](http://perldoc.perl.org/Unicode/Collate.html)
41 >>> doesn't handle the optional [numbers](http://www.unicode.org/unicode/reports/tr10/#Customization)
42 >>> extension which is what you want. --[[Will]]
46 Below is my simple patch. Feel free to use it or comment!
48 I have also 2 considerations for inline sorting:
50 1. Maybe changing name of `sort` parameter to `sortby` or `sortkey` will
52 1. Maybe you should use `title` sort key for title from meta plugin and `name`,
53 `filename`, `page` or `pagename` for page names? In the future you can also
54 sort by meta author, license or another key.
58 --- inline.pm-orig 2008-09-02 09:53:20.000000000 +0200
59 +++ inline.pm 2008-09-02 10:09:02.000000000 +0200
63 if (exists $params{sort} && $params{sort} eq 'title') {
64 - @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
65 + if (! $params{sorttype} || $params{sorttype} eq 'lexical') {
66 + @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
68 + elsif ($params{sorttype} eq 'numeric') {
69 + @list=sort { pagetitle(basename($a)) <=> pagetitle(basename($b)) } @list;
72 + return sprintf(gettext("unknown sort type %s"), $params{sorttype});
75 elsif (exists $params{sort} && $params{sort} eq 'mtime') {
76 @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
78 @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
81 - return sprintf(gettext("unknown sort type %s"), $params{sort});
82 + return sprintf(gettext("unknown sort key %s"), $params{sort});
85 if (yesno($params{reverse})) {
89 Joey, have you forgotten about that request? ;) --[[Paweł|ptecza]]