]> sipb.mit.edu Git - ikiwiki.git/blob - doc/bugs/inline_sort-by-title_issues.mdwn
(no commit message)
[ikiwiki.git] / doc / bugs / inline_sort-by-title_issues.mdwn
1 The [[plugins/inline]] plugin has a `sort="title"` option that causes the pages in the list to be sorted by title rather than creation time.  The [[plugins]] list on this wiki was recently changed to use this option.  If you look at the plugin page, you'll notice that it doesn't look correctly sorted.  e.g. `attach (third party plugin)` falls between `conditional` and `default content for *copyright* and *license*`.
2
3 I think the problem here is that the pages are being sorted by their path, whereas only the basename is displayed.  This makes the example above:
4
5  * plugins/conditional
6  * plugins/contrib/attach
7  * plugins/contrib/default content for *copyright* and *license*
8
9 and now you can see why it is ordered that way, and why later on we get:
10
11  * plugins/contrib/unixauth (third party plugin)
12  * plugins/creole
13
14 which appears to list `unixauth` before `creole`.
15
16 I'm not sure what the best fix is.  One fix would be to add another sort option, `sort="path"`, that would use the current (broken) sort by title.  Then add a true `sort="title"` that actually sorts on the title.  It might also be interesting to modify the sort=path to actually list the full path in the links - that way it would be obvious how it is sorted.  Or you could ignore the idea for `sort="path"`, and tell people to use [[plugins/map]] for that.
17
18 --[[users/Will]]
19
20 And here is a [[patch]] for this.  It makes `sort=title` actually sort on the title, and adds `sort=path` if you really want to sort on the path.  `sort=path` still only displays titles.  Just use map if you want more.
21
22     diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
23     index 9c336e7..99f6de3 100644
24     --- a/IkiWiki/Plugin/inline.pm
25     +++ b/IkiWiki/Plugin/inline.pm
26     @@ -185,9 +185,12 @@ sub preprocess_inline (@) {
27                 }
28         }
29      
30     -   if (exists $params{sort} && $params{sort} eq 'title') {
31     +   if (exists $params{sort} && $params{sort} eq 'path') {
32                 @list=sort @list;
33         }
34     +   elsif (exists $params{sort} && $params{sort} eq 'title') {
35     +           @list=sort { lc(pagetitle(basename($a))) cmp lc(pagetitle(basename($b))) } @list;
36     +   }
37         elsif (exists $params{sort} && $params{sort} eq 'mtime') {
38                 @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
39         }
40     diff --git a/doc/ikiwiki/blog.mdwn b/doc/ikiwiki/blog.mdwn
41     index 19ec7ac..7608628 100644
42     --- a/doc/ikiwiki/blog.mdwn
43     +++ b/doc/ikiwiki/blog.mdwn
44     @@ -89,7 +89,8 @@ Here are some less often needed parameters:
45        inlining page.
46      * `sort` - Controls how inlined pages are sorted. The default, "age" is to
47        sort newest created pages first. Setting it to "title" will sort pages by
48     -  title, and "mtime" sorts most recently modified pages first.
49     +  title, "path" sorts by the path to the page, and "mtime" sorts most
50     +  recently modified pages first.
51      * `reverse` - If set to "yes", causes the sort order to be reversed.
52      * `feedshow` - Specify the maximum number of matching pages to include in
53        the rss/atom feeds. The default is the same as the `show` value above.
54
55 > Thanks for the patch. [[done]], but I left off the sort=path. Also left
56 > off the lc (if you ask your locale to sort case-sensatively, it should, I
57 > think). --[[Joey]]