Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes. Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702 git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
- Loading branch information
Showing
193 changed files
with
3,000 additions
and
1,598 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,110 @@ | ||
var LATIN_MAP = | ||
{ | ||
'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'AE', 'Ç': | ||
'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I', | ||
'Ï': 'I', 'Ð': 'D', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö': | ||
'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'U', 'Ý': 'Y', 'Þ': 'TH', | ||
'ß': 'ss', 'à':'a', 'á':'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': | ||
'ae', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'ì': 'i', 'í': 'i', | ||
'î': 'i', 'ï': 'i', 'ð': 'o', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': | ||
'o', 'ö': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ü': 'u', 'ý': 'y', | ||
'þ': 'th', 'ÿ': 'y', | ||
} | ||
var LATIN_SYMBOLS_MAP = | ||
{ | ||
'©':'(c)', | ||
} | ||
var GREEK_MAP = | ||
{ | ||
'α':'a', 'β':'b', 'γ':'g', 'δ':'d', 'ε':'e', 'ζ':'z', 'η':'h', 'θ':'8', | ||
'ι':'i', 'κ':'k', 'λ':'l', 'μ':'m', 'ν':'n', 'ξ':'3', 'ο':'o', 'π':'p', | ||
'ρ':'r', 'σ':'s', 'τ':'t', 'υ':'y', 'φ':'f', 'χ':'x', 'ψ':'ps', 'ω':'w', | ||
'ά':'a', 'έ':'e', 'ί':'i', 'ό':'o', 'ύ':'y', 'ή':'h', 'ώ':'w', 'ς':'s', | ||
'ϊ':'i', 'ΰ':'y', 'ϋ':'y', 'ΐ':'i', | ||
'Α':'A', 'Β':'B', 'Γ':'G', 'Δ':'D', 'Ε':'E', 'Ζ':'Z', 'Η':'H', 'Θ':'8', | ||
'Ι':'I', 'Κ':'K', 'Λ':'L', 'Μ':'M', 'Ν':'N', 'Ξ':'3', 'Ο':'O', 'Π':'P', | ||
'Ρ':'R', 'Σ':'S', 'Τ':'T', 'Υ':'Y', 'Φ':'F', 'Χ':'X', 'Ψ':'PS', 'Ω':'W', | ||
'Ά':'A', 'Έ':'E', 'Ί':'I', 'Ό':'O', 'Ύ':'Y', 'Ή':'H', 'Ώ':'W', 'Ϊ':'I', | ||
'Ϋ':'Y' | ||
} | ||
var TURKISH_MAP = { | ||
'ş':'s', 'Ş':'S', 'ı':'i', 'İ':'I', 'ç':'c', 'Ç':'C', 'ü':'u', 'Ü':'U', | ||
'ö':'o', 'Ö':'O', 'ğ':'g', 'Ğ':'G', | ||
} | ||
// var RUSSIAN_MAP = | ||
// { | ||
// } | ||
|
||
var ALL_DOWNCODE_MAPS=new Array() | ||
ALL_DOWNCODE_MAPS[0]=LATIN_MAP | ||
ALL_DOWNCODE_MAPS[1]=LATIN_SYMBOLS_MAP | ||
ALL_DOWNCODE_MAPS[2]=GREEK_MAP | ||
ALL_DOWNCODE_MAPS[3]=TURKISH_MAP | ||
//ALL_DOWNCODE_MAPS[4]=RUSSIAN_MAP | ||
|
||
var Downcoder = new Object(); | ||
Downcoder.Initialize = function() | ||
{ | ||
if (Downcoder.map) // already made | ||
return ; | ||
Downcoder.map ={} | ||
Downcoder.chars = '' ; | ||
for(var i in ALL_DOWNCODE_MAPS) | ||
{ | ||
var lookup = ALL_DOWNCODE_MAPS[i] | ||
for (var c in lookup) | ||
{ | ||
Downcoder.map[c] = lookup[c] ; | ||
Downcoder.chars += c ; | ||
} | ||
} | ||
Downcoder.regex = new RegExp('[' + Downcoder.chars + ']|[^' + Downcoder.chars + ']+','g') ; | ||
} | ||
|
||
downcode= function( slug ) | ||
{ | ||
Downcoder.Initialize() ; | ||
var downcoded ="" | ||
var pieces = slug.match(Downcoder.regex); | ||
if(pieces) | ||
{ | ||
for (var i = 0 ; i < pieces.length ; i++) | ||
{ | ||
if (pieces[i].length == 1) | ||
{ | ||
var mapped = Downcoder.map[pieces[i]] ; | ||
if (mapped != null) | ||
{ | ||
downcoded+=mapped; | ||
continue ; | ||
} | ||
} | ||
downcoded+=pieces[i]; | ||
} | ||
} | ||
else | ||
{ | ||
downcoded = slug; | ||
} | ||
return downcoded; | ||
} | ||
|
||
|
||
function URLify(s, num_chars) { | ||
// changes, e.g., "Petty theft" to "petty_theft" | ||
// remove all these words from the string before urlifying | ||
s = downcode(s); | ||
removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from", | ||
"is", "in", "into", "like", "of", "off", "on", "onto", "per", | ||
"since", "than", "the", "this", "that", "to", "up", "via", | ||
"with"]; | ||
r = new RegExp('\\b(' + removelist.join('|') + ')\\b', 'gi'); | ||
s = s.replace(r, ''); | ||
// if downcode doesn't hit, the char will be stripped here | ||
s = s.replace(/[^-\w\s]/g, ''); // remove unneeded chars | ||
s = s.replace(/^\s+|\s+$/g, ''); // trim leading/trailing spaces | ||
s = s.replace(/[-\s]+/g, '-'); // convert spaces to hyphens | ||
s = s.toLowerCase(); // convert to lowercase | ||
return s.substring(0, num_chars);// trim to first num_chars chars | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.