You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by el...@apache.org on 2015/05/03 06:42:12 UTC
svn commit: r1677365 - in /lucene/dev/trunk/solr: CHANGES.txt
licenses/javacscript-natural-sort-NOTICE.txt
licenses/javascript-natural-sort-LICENSE-MIT.txt
webapp/web/js/lib/naturalSort.js webapp/web/js/main.js
webapp/web/js/scripts/dataimport.js
Author: elyograg
Date: Sun May 3 04:42:11 2015
New Revision: 1677365
URL: http://svn.apache.org/r1677365
Log:
SOLR-7409: Sort datimport handlers in the admin UI
Added:
lucene/dev/trunk/solr/licenses/javacscript-natural-sort-NOTICE.txt (with props)
lucene/dev/trunk/solr/licenses/javascript-natural-sort-LICENSE-MIT.txt (with props)
lucene/dev/trunk/solr/webapp/web/js/lib/naturalSort.js (with props)
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/webapp/web/js/main.js
lucene/dev/trunk/solr/webapp/web/js/scripts/dataimport.js
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1677365&r1=1677364&r2=1677365&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Sun May 3 04:42:11 2015
@@ -308,6 +308,10 @@ Other Changes
in solr/server/solr/configsets instead of example and harden error checking / validation
logic. (hossman, Timothy Potter)
+* SOLR-7409: When there are multiple dataimport handlers defined, the admin UI
+ was listing them in a random order. Now they are sorted in a natural order
+ that handles numbers properly. (Jellyfrog via Shawn Heisey)
+
================== 5.1.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release
Added: lucene/dev/trunk/solr/licenses/javacscript-natural-sort-NOTICE.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/licenses/javacscript-natural-sort-NOTICE.txt?rev=1677365&view=auto
==============================================================================
--- lucene/dev/trunk/solr/licenses/javacscript-natural-sort-NOTICE.txt (added)
+++ lucene/dev/trunk/solr/licenses/javacscript-natural-sort-NOTICE.txt Sun May 3 04:42:11 2015
@@ -0,0 +1,5 @@
+javascript-natural-sort is a javascript library for sorting data with embedded
+numbers naturally, the way a human would expect.
+https://github.com/jarinudom/naturalSort.js
+
+javascript-natural-sort is licensed under the MIT license.
\ No newline at end of file
Added: lucene/dev/trunk/solr/licenses/javascript-natural-sort-LICENSE-MIT.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/licenses/javascript-natural-sort-LICENSE-MIT.txt?rev=1677365&view=auto
==============================================================================
--- lucene/dev/trunk/solr/licenses/javascript-natural-sort-LICENSE-MIT.txt (added)
+++ lucene/dev/trunk/solr/licenses/javascript-natural-sort-LICENSE-MIT.txt Sun May 3 04:42:11 2015
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2011 Jim Palmer and other contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
Added: lucene/dev/trunk/solr/webapp/web/js/lib/naturalSort.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/lib/naturalSort.js?rev=1677365&view=auto
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/lib/naturalSort.js (added)
+++ lucene/dev/trunk/solr/webapp/web/js/lib/naturalSort.js Sun May 3 04:42:11 2015
@@ -0,0 +1,85 @@
+/*
+
+naturalSort.js
+- by Jim Palmer and other contributors
+
+The MIT License (MIT)
+
+Copyright (c) 2011 Jim Palmer and other contributors
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+*/
+
+# naturalSort.js 0.7.0
+# https://github.com/jarinudom/naturalSort.js
+# (c) 2011 Jim Palmer and other contributors
+# naturalSort.js may be freely distributed under the MIT license.
+window.naturalSort = (a, b) ->
+ re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/g
+ sre = /(^[ ]*|[ ]*$)/g
+ dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/
+ hre = /^0x[0-9a-f]+$/i
+ ore = /^0/
+ i = (s) ->
+ naturalSort.insensitive and ('' + s).toLowerCase() or '' + s
+
+ # convert all to strings strip whitespace
+ x = i(a).replace(sre, '') or ''
+ y = i(b).replace(sre, '') or ''
+
+ # chunk/tokenize
+ xN = x.replace(re, '\u0000$1\u0000').replace(/\0$/, '').replace(/^\0/, '').split('\u0000')
+ yN = y.replace(re, '\u0000$1\u0000').replace(/\0$/, '').replace(/^\0/, '').split('\u0000')
+
+ # numeric, hex or date detection
+ xD = parseInt(x.match(hre), 16) or (xN.length isnt 1 and x.match(dre) and Date.parse(x))
+ yD = parseInt(y.match(hre), 16) or xD and y.match(dre) and Date.parse(y) or null
+ oFxNcL = undefined
+ oFyNcL = undefined
+
+ # first try and sort Hex codes or Dates
+ if yD
+ return -1 if xD < yD
+ return 1 if xD > yD
+
+ # natural sorting through split numeric strings and default strings
+ cLoc = 0
+ numS = Math.max(xN.length, yN.length)
+
+ while cLoc < numS
+ # find floats not starting with '0', string or 0 if not defined (Clint Priest)
+ oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0
+ oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0
+
+ # handle numeric vs string comparison - number < string - (Kyle Adams)
+ if isNaN(oFxNcL) != isNaN(oFyNcL)
+ return (if (isNaN(oFxNcL)) then 1 else -1)
+
+ # Rely on string comparison of different types - i.e. '02' < 2 != '02' < '2'
+ else if typeof oFxNcL != typeof oFyNcL
+ oFxNcL += ''
+ oFyNcL += ''
+
+ return -1 if oFxNcL < oFyNcL
+ return 1 if oFxNcL > oFyNcL
+
+ cLoc++
+
+ return 0
Modified: lucene/dev/trunk/solr/webapp/web/js/main.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/main.js?rev=1677365&r1=1677364&r2=1677365&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/main.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/main.js Sun May 3 04:42:11 2015
@@ -32,6 +32,7 @@ require
'lib/order!lib/ZeroClipboard',
'lib/order!lib/d3',
'lib/order!lib/chosen',
+ 'lib/order!lib/naturalSort',
'lib/order!scripts/app',
'lib/order!scripts/analysis',
Modified: lucene/dev/trunk/solr/webapp/web/js/scripts/dataimport.js
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/webapp/web/js/scripts/dataimport.js?rev=1677365&r1=1677364&r2=1677365&view=diff
==============================================================================
--- lucene/dev/trunk/solr/webapp/web/js/scripts/dataimport.js (original)
+++ lucene/dev/trunk/solr/webapp/web/js/scripts/dataimport.js Sun May 3 04:42:11 2015
@@ -45,7 +45,7 @@ sammy.bind
dataimport_handlers.push( key );
}
}
- params.callback( dataimport_handlers );
+ params.callback( dataimport_handlers.sort(naturalSort) );
},
error : function( xhr, text_status, error_thrown)
{