summaryrefslogtreecommitdiff
path: root/doc/todo/inline:_numerical_ordering_by_title.mdwn
blob: ecad4f9db1e5a8f4a41d2fc9c3985e3c8b94890c (plain)

Could you please add numerical ordering by title to [[inline|plugins/inline]] plugin? Now I can do only alphabetical order by title, but sometime it's not enough.

BTW, it seems that ordering by title is rather ordering by filename of page. For me "title" means title of page I can set using title parameter of [[meta|plugins/meta]] plugin :)

Why do I need that feature? I've just been migrating an info site of our university mail system to Ikiwiki from very static, console handling Makefile+WML+XML+XSL=HTML solution. I have many news files (1.mdwn, 2.mdwn, etc.) and unfortunately I did very stupid thing. I've commited all of them in the same revision of our Subversion repo...

Now I have a problem with sorting these files using inline plugin. I can't do sorting by age, because both old and young news files have the same age. I can't sort by title too. For example, when I sort them by title, then 9.mdwn page is between 90.mdwn and 89.mdwn pages... It sucks, of course. Sorting by mtime also is not a solution for me, because it means that I can't touch/fix old news anymore.

Do you have any idea how to workaround that issue? --[[Paweł|ptecza]]

Maybe you can rename 9.mdwn to 09.mdwn? See rename(1), it renames multiple files in one go. --[[buo]]

Thanks for your suggestion! But what about if number of my news files grows to 100+?

$ ls
09.mdwn  100.mdwn  101.mdwn  102.mdwn  89.mdwn  90.mdwn

I don't want to rename all previous files to add 0 prefix. --[[Paweł|ptecza]]


Below is my simple patch. Feel free to use it or comment!

I have also 2 considerations for inline sorting:

  1. Maybe changing name of sort parameter to sortby or sortkey will be good idea?
  2. Maybe you should use title sort key for title from meta plugin and name, filename, page or pagename for page names? In the future you can also sort by meta author, license or another key.

--[[Paweł|ptecza]]

--- inline.pm-orig  2008-09-02 09:53:20.000000000 +0200
+++ inline.pm       2008-09-02 10:09:02.000000000 +0200
@@ -186,7 +186,15 @@
    }

    if (exists $params{sort} && $params{sort} eq 'title') {
-           @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
+           if (! $params{sorttype} || $params{sorttype} eq 'lexical') {
+                   @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
+           }
+           elsif ($params{sorttype} eq 'numeric') {
+                   @list=sort { pagetitle(basename($a)) <=> pagetitle(basename($b)) } @list;
+           }
+           else {
+                   return sprintf(gettext("unknown sort type %s"), $params{sorttype});
+           }
    }
    elsif (exists $params{sort} && $params{sort} eq 'mtime') {
            @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
@@ -195,7 +203,7 @@
            @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
    }
    else {
-           return sprintf(gettext("unknown sort type %s"), $params{sort});
+           return sprintf(gettext("unknown sort key %s"), $params{sort});
    }

    if (yesno($params{reverse})) {