* Patch and 2 considerations for inline sorting
authorhttp://ptecza.myopenid.com/ <http://ptecza.myopenid.com/@web>
Tue, 2 Sep 2008 08:23:59 +0000 (04:23 -0400)
committerJoey Hess <joey@kitenet.net>
Tue, 2 Sep 2008 08:23:59 +0000 (04:23 -0400)
doc/todo/inline:_numerical_ordering_by_title.mdwn

index a023c77850c1c0c1cbeb07d0599b6c448525dbe7..ecad4f9db1e5a8f4a41d2fc9c3985e3c8b94890c 100644 (file)
@@ -29,3 +29,46 @@ Do you have any idea how to workaround that issue? --[[Paweł|ptecza]]
 >>     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?
+1. 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})) {