Hello,
I have problem with submiting ticket in trac (details below) with my
patch, so I decided to post it here.
-----------------------------------------
Short summary: [patch] Generating slug for words with accents
Full description: In my language (czech) there are a lot of characters
with accents. When I type titles in admin forms, the slug field
autogenerated values are incorect (for example:title="sršeň",
autogenerated slug="sre"; correct is "srsen"). So I wrote little patch
to urlify.js code, which first convert all accents chars to their ASCII
equivalent. For now, my code respect only czech accents. I will be glad,
If some others of you add your own national characters.
Priority: normal
Component: Admin interface
Severity: normal
Version: SVN
Keywords: slug urlify
-----------------------------------------
Trac error
Trac detected an internal error:
Traceback (most recent call last):
File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 299,
in dispatch_request
dispatcher.dispatch(req)
File "/usr/lib/python2.3/site-packages/trac/web/main.py", line 189,
in dispatch
resp = chosen_handler.process_request(req)
File "/usr/lib/python2.3/site-packages/trac/ticket/web_ui.py", line
104, in process_request
self._do_create(req, db)
File "/usr/lib/python2.3/site-packages/trac/ticket/web_ui.py", line
163, in _do_create
self._validate_ticket(req, ticket)
File "/usr/lib/python2.3/site-packages/trac/ticket/web_ui.py", line
47, in _validate_ticket
for field, message in manipulator.validate_ticket(req, ticket):
File "build/bdist.linux-i686/egg/tracspamfilter/adapters.py", line
40, in validate_ticket
File "build/bdist.linux-i686/egg/tracspamfilter/api.py", line 74, in test
herror: (1, 'Unknown host')
(I was trying to submit ticket from FreeBSD 5.4 system & Firefox 1.5.0.1)
Regards
Michal
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
Index: django/contrib/admin/media/js/urlify.js
===================================================================
--- django/contrib/admin/media/js/urlify.js (revision 3657)
+++ django/contrib/admin/media/js/urlify.js (working copy)
@@ -1,4 +1,20 @@
+function replAccents(s)
+{
+ // from and to strings must have same number of characters
+ var from = 'áčďéěíňóřšťúůýžÁČĎÉĚÍŇÓŘŠŤÚŮÝŽ';
+ var to = 'acdeeinorstuuyzACDEEINORSTUUYZ';
+ for (var i = 0; i != s.length; i++) {
+ var x = from.indexOf(s[i]);
+ if (x != -1) {
+ r = new RegExp(from[x], 'g');
+ s = s.replace(r, to[x]);
+ }
+ }
+ return s;
+}
+
function URLify(s, num_chars) {
+ s = replAccents(s);
// changes, e.g., "Petty theft" to "petty_theft"
// remove all these words from the string before urlifying
removelist = ["a", "an", "as", "at", "before", "but", "by", "for", "from",