diff browser_side/tools.py @ 306:52b1afd7ac3f

server_side: display rich text in blogs (addURLToText is now in sat_frontends/tools/strings)
author souliane <souliane@mailoo.org>
date Wed, 18 Dec 2013 15:39:13 +0100
parents 0eba1c4f9c6f
children 6abd099c7007
line wrap: on
line diff
--- a/browser_side/tools.py	Wed Dec 18 13:59:25 2013 +0100
+++ b/browser_side/tools.py	Wed Dec 18 15:39:13 2013 +0100
@@ -22,7 +22,6 @@
 from pyjamas.ui.DragWidget import DragWidget
 from pyjamas.ui.FileUpload import FileUpload
 from pyjamas import Window
-import re
 from nativedom import NativeDOM
 from sat_frontends.tools import xml
 
@@ -40,19 +39,6 @@
     return xml.inlineRoot(doc)
 
 
-def addURLToText(string):
-    """Check a text for what looks like an URL and make it clickable. Regexp
-    from http://daringfireball.net/2010/07/improved_regex_for_matching_urls"""
-
-    def repl(match):
-        url = match.group(0)
-        if not re.match(r"""[a-z]{3,}://|mailto:|xmpp:""", url):
-            url = "http://" + url
-        return '<a href="%s" target="_blank" class="url">%s</a>' % (url, match.group(0))
-    pattern = r"""(?i)\b((?:[a-z]{3,}://|(www|ftp)\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/|mailto:|xmpp:)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?]))"""
-    return re.sub(pattern, repl, string)
-
-
 def setPresenceStyle(item, state, base_style="contact"):
     """
     @item: any UI element