You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by "Greg Kable (JIRA)" <ji...@apache.org> on 2009/04/22 05:55:48 UTC

[jira] Created: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Allow administrators to select the Comparator used for sorting page lists by name
---------------------------------------------------------------------------------

                 Key: JSPWIKI-526
                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
             Project: JSPWiki
          Issue Type: Improvement
          Components: Localization
            Reporter: Greg Kable
            Priority: Minor
             Fix For: 2.8.3, 3.0


I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:

WikiPage1
WikiPage10
WikiPage2

I'd like to get the list:

WikiPage1
WikiPage2
WikiPage10

There are also many other case, especially for localisation, where being able to set the page name order would be useful.

To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:

- Would this be a welcome feature?
- Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by Harry Metske <ha...@gmail.com>.
+1



2009/4/27 Janne Jalkanen (JIRA) <ji...@apache.org>

>
>    [
> https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703211#action_12703211]
>
> Janne Jalkanen commented on JSPWIKI-526:
> ----------------------------------------
>
> The patch looks good (very good in fact, I wish we always got patches of
> this quality!).  I definitely would like to have this for 3.0 - any
> objections if we take this also in 2.8.3?
>
> Greg, can you also port this to SVN trunk, please?
>
> > Allow administrators to select the Comparator used for sorting page lists
> by name
> >
> ---------------------------------------------------------------------------------
> >
> >                 Key: JSPWIKI-526
> >                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
> >             Project: JSPWiki
> >          Issue Type: Improvement
> >          Components: Localization
> >            Reporter: Greg Kable
> >            Priority: Minor
> >         Attachments: jspwiki-526-PageSorter.patch
> >
> >
> > I personally hate the order of pages returned by the standard sorting
> routines and would rather an order that understood numeric ordering.  That
> is, instead of having the list:
> > WikiPage1
> > WikiPage10
> > WikiPage2
> > I'd like to get the list:
> > WikiPage1
> > WikiPage2
> > WikiPage10
> > There are also many other case, especially for localisation, where being
> able to set the page name order would be useful.
> > To achieve this, I propose adding a JSPWiki property which specifies the
> Comparator to be used for page names.  Before I do the work and submit a
> patch, I'd like to know:
> > - Would this be a welcome feature?
> > - Is jswpwiki.pageNameComparator an appropriate property name?  If not,
> what do you suggest?
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>

[jira] Updated: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Greg Kable (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Kable updated JSPWIKI-526:
-------------------------------

    Attachment: jspwiki-526-PageSorter.patch

Patch as discussed in the previous comment.

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>         Attachments: jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Harry Metske (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707892#action_12707892 ] 

Harry Metske commented on JSPWIKI-526:
--------------------------------------

OK, I'll apply the patches tomorrow and close it.

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>         Attachments: jspwiki-526-PageSorter.patch, jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Greg Kable (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12701776#action_12701776 ] 

Greg Kable commented on JSPWIKI-526:
------------------------------------

Sorry for being thick but what do you mean by a ClassMapping.  My intention was to have a property containing a class name - similar to LoginModule.  In fact a better name for property would be jspwiki.PageNameComparator.class.

Is this what you meant?



> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Janne Jalkanen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12702665#action_12702665 ] 

Janne Jalkanen commented on JSPWIKI-526:
----------------------------------------

Check out ClassUtils and WikiEngine.initialize(). JSPWiki provides a second way of replacing internal classes with your own classes and it might work better with this one.

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Greg Kable (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703083#action_12703083 ] 

Greg Kable commented on JSPWIKI-526:
------------------------------------

Thanks for the tips Janne.

Attached is the patch for the current 2.8 trunk.  I decided to implement on 2.8 first because I have production wiki running 2.8 and the 2.8 code is more stable.  The patch ended up a little bigger than I expected because I added in some extra stuff.

The brief summary of the jspwiki-526-PageSorter.patch is:

- Added a new JSPWiki property  called jspwiki.pageNameComparator..class which specifies a Comparator<String> class to be used as the default sort order for pages sorted by name.
- Added a util class PageSorter which wraps up the pageNameComparator. This class is initialised by and made available through WikiEngine.  For a future change, I think it would be better as a User preference rather than a global property.
- Added a couple of Comparators which can be used as the default comparator.  I couldn't find a "human" comparator so I created one.  If you know of one, we can use it instead.
- Changed all places I could find where pages were presented in alphabetical order to use PageSorter
- Added a new sortOrder parameter to AbstractReferralPlugin as suggested by Santiago Gala on http://www.jspwiki.org/wiki/PluginRefactoring

All tests pass bar one WikIEngine test which seems to be invalid anyway.  I also have the patch in production on a small but fairly active wiki.

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>         Attachments: jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Greg Kable (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707864#action_12707864 ] 

Greg Kable commented on JSPWIKI-526:
------------------------------------

Thanks Harry.  You're right and I somehow managed to screw up the test code.

Your code is correct.

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>         Attachments: jspwiki-526-PageSorter.patch, jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Harry Metske (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Harry Metske resolved JSPWIKI-526.
----------------------------------

       Resolution: Fixed
    Fix Version/s: 2.8.3

fixed in 2.8.3-svn-7

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>             Fix For: 2.8.3
>
>         Attachments: jspwiki-526-PageSorter.patch, jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Janne Jalkanen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12703211#action_12703211 ] 

Janne Jalkanen commented on JSPWIKI-526:
----------------------------------------

The patch looks good (very good in fact, I wish we always got patches of this quality!).  I definitely would like to have this for 3.0 - any objections if we take this also in 2.8.3?

Greg, can you also port this to SVN trunk, please?

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>         Attachments: jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Greg Kable (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Greg Kable updated JSPWIKI-526:
-------------------------------

    Attachment: jspwiki-526-PageSorter.patch

Updated the patch file - please use this new version! 

this updated version is functionally almost identical (one bug fix).  Details are:

- fixed my own stupid typo bug in AbstractReferralPlugin.  In finalising the first patch, I managed to stop it using sortOrder.
- Slight optimisation of PageSorter
- Some comment and format changes

The last two could have waited until later but, given the first was necessary, I did them all.

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>         Attachments: jspwiki-526-PageSorter.patch, jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Janne Jalkanen (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Janne Jalkanen updated JSPWIKI-526:
-----------------------------------

    Fix Version/s:     (was: 2.8.3)
                       (was: 3.0)

Please do not set fix versions, those are assigned by the dev team.

I think this may be a fairly complicated job, since we sort based on String and WikiPages here and there. So there is no single place where you could just simply change it. Also, it's doubtful that a single Comparator would work, you might have to add two (one for WikiPages and one for String-based names -and for 3.0, WikiPaths). So go ahead, but be conservative in your estimates on how long this might take ;-)

Perhaps a ClassMapping is more appropriate than a property?

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (JSPWIKI-526) Allow administrators to select the Comparator used for sorting page lists by name

Posted by "Harry Metske (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JSPWIKI-526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12707693#action_12707693 ] 

Harry Metske commented on JSPWIKI-526:
--------------------------------------

Greg, after applying the patches, I noticed that the JUnit test fails.

If I change it to this, it succeeds :

{code}

        // Default order first
        assertTrue( comparator.compare( "a c", "a1c" ) < 0 );
        assertTrue( comparator.compare( "a1c", "abc" ) < 0 );

        // Now letters then numbers then other
        HumanComparator.CharType sortOrder[] = { HumanComparator.CharType.TYPE_LETTER, HumanComparator.CharType.TYPE_DIGIT,
                                                HumanComparator.CharType.TYPE_OTHER };
        comparator.setSortOrder( sortOrder );
        assertTrue( comparator.compare( "a c", "a1c" ) > 0 );
        assertTrue( comparator.compare( "a1c", "abc" ) > 0 );

        // Now numbers then letters then other
        sortOrder[0] = HumanComparator.CharType.TYPE_DIGIT;
        sortOrder[1] = HumanComparator.CharType.TYPE_LETTER;
        sortOrder[2] = HumanComparator.CharType.TYPE_OTHER;
        comparator.setSortOrder( sortOrder );
        assertTrue( comparator.compare( "a c", "a1c" ) > 0 );
        assertTrue( comparator.compare( "a1c", "abc" ) < 0 );

{code}
Could you check that ?

thanks, Harry

> Allow administrators to select the Comparator used for sorting page lists by name
> ---------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-526
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-526
>             Project: JSPWiki
>          Issue Type: Improvement
>          Components: Localization
>            Reporter: Greg Kable
>            Priority: Minor
>         Attachments: jspwiki-526-PageSorter.patch, jspwiki-526-PageSorter.patch
>
>
> I personally hate the order of pages returned by the standard sorting routines and would rather an order that understood numeric ordering.  That is, instead of having the list:
> WikiPage1
> WikiPage10
> WikiPage2
> I'd like to get the list:
> WikiPage1
> WikiPage2
> WikiPage10
> There are also many other case, especially for localisation, where being able to set the page name order would be useful.
> To achieve this, I propose adding a JSPWiki property which specifies the Comparator to be used for page names.  Before I do the work and submit a patch, I'd like to know:
> - Would this be a welcome feature?
> - Is jswpwiki.pageNameComparator an appropriate property name?  If not, what do you suggest?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.