Mercurial > traipse_dev
comparison plugins/xxurl2link.py @ 212:13054be69834 beta
Traipse Beta 'OpenRPG' {100428-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for
developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to
the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user.
Update Summary (Patch-2)
New Features:
New Namespace method with two new syntaxes
New Namespace Internal is context sensitive, always!
New Namespace External is 'as narrow as you make it'
New Namespace FutureCheck helps ensure you don't receive an incorrect node
New PluginDB access for URL2Link plugin
New to Forms, they now show their content in Design Mode
New to Update Manager, checks Repo for updates on software start
Fixes:
Fix to Server GUI startup errors
Fix to Server GUI Rooms tab updating
Fix to Chat and Settings if non existant die roller is picked
Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated
Fix to Alias Lib's Export to Tree, Open, Save features
Fix to alias node, now works properly
Fix to Splitter node, minor GUI cleanup
Fix to Backgrounds not loading through remote loader
Fix to Node name errors
Fix to rolling dice in chat Whispers
Fix to Splitters Sizing issues
Fix to URL2Link plugin, modified regex compilation should remove memory leak
Fix to mapy.py, a roll back due to zoomed grid issues
Fix to whiteboard_handler, Circles work by you clicking the center of the circle
Fix to Servers parse_incoming_dom which was outdated and did not respect XML
Fix to a broken link in the server welcome message
Fix to InterParse and logger requiring traceback
Fix to Update Manager Status Bar
Fix to failed image and erroneous pop up
author | sirebral |
---|---|
date | Wed, 28 Apr 2010 08:08:09 -0500 |
parents | 15488fe94f52 |
children |
comparison
equal
deleted
inserted
replaced
194:44ef45e77880 | 212:13054be69834 |
---|---|
7 # !self : instance of self | 7 # !self : instance of self |
8 # !chat : instance of the chat window to write to | 8 # !chat : instance of the chat window to write to |
9 def __init__(self, plugindb, parent): | 9 def __init__(self, plugindb, parent): |
10 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent) | 10 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent) |
11 | 11 |
12 # The Following code should be edited to contain the proper information | |
13 self.name = 'URL to link conversion' | 12 self.name = 'URL to link conversion' |
14 self.author = 'tdb30 tbaleno@wrathof.com' | 13 self.author = 'tdb30 tbaleno@wrathof.com' |
15 self.help = "This plugin automaticaly wraps urls in link tags\n" | 14 self.help = "This plugin automaticaly wraps urls in link tags\n" |
16 self.help += "making them clickable." | 15 self.help += "making them clickable." |
17 | 16 |
18 self.url_regex = None | |
19 self.mailto_regex = None | |
20 | |
21 def plugin_menu(self): | 17 def plugin_menu(self): |
22 self.menu = wx.Menu() | 18 self.menu = wx.Menu() |
23 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On') | 19 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On') |
24 self.topframe.Bind(wx.EVT_MENU, self.plugin_toggle, self.toggle) | 20 self.topframe.Bind(wx.EVT_MENU, self.plugin_toggle, self.toggle) |
25 self.toggle.Check(True) | |
26 | 21 |
27 def plugin_toggle(self, evt): | 22 def plugin_toggle(self, evt): |
23 if self.toggle.IsChecked() == True: self.plugindb.SetString('xxurl2link', 'url2link', 'True') | |
24 if self.toggle.IsChecked() == False: self.plugindb.SetString('xxurl2link', 'url2link', 'False') | |
28 pass | 25 pass |
29 | 26 |
30 def plugin_enabled(self): | 27 def plugin_enabled(self): |
31 #This is where you set any variables that need to be initalized when your plugin starts | 28 self.url_regex = re.compile( #from Paul Hayman of geekzilla |
32 self.url_regex = re.compile("(?<![\[=\"a-z0-9:/.])((?:http|ftp|gopher)://)?(?<![@a-z])((?:[a-z0-9\-]+[-.]?[a-z0-9]+)*\.(?:[a-z]{2,4})(?:[a-z0-9_=\?\#\&~\%\.\-/\:\+;]*))", re.I) | 29 "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.I) |
33 | 30 self.mailto_regex = re.compile( #Taken from Django |
34 self.mailto_regex = re.compile("(?<![=\"a-z0-9:/.])((?:[a-z0-9]+[_]?[a-z0-9]*)+@{1}(?:[a-z0-9]+[-.]?[a-z0-9]+)*\.(?:[a-z]{2,4}))", re.I) | 31 r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom |
32 r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string | |
33 r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE) | |
34 self.link = self.plugindb.GetString('xxurl2link', 'url2link', '') or 'False' | |
35 self.toggle.Check(True) if self.link == 'True' else self.toggle.Check(False) | |
35 | 36 |
36 def plugin_disabled(self): | 37 def plugin_disabled(self): |
37 #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin | |
38 #such as closing windows created by the plugin | |
39 pass | 38 pass |
40 | 39 |
41 def pre_parse(self, text): | 40 def pre_parse(self, text): |
41 text2 = text | |
42 if self.toggle.IsChecked() == True: | 42 if self.toggle.IsChecked() == True: |
43 text = self.mailto_regex.sub(self.regmailsub, text) | 43 text = self.mailto_regex.sub(self.regmailsub, text) |
44 text = self.url_regex.sub(self.regurlsub, text) | 44 text = self.url_regex.sub(self.regurlsub, text) |
45 return text | 45 return text |
46 | 46 |
54 term = m.group(0).lower() | 54 term = m.group(0).lower() |
55 return '<a href="mailto:' + term + '">' + m.group(0) + '</a>' | 55 return '<a href="mailto:' + term + '">' + m.group(0) + '</a>' |
56 | 56 |
57 def regurlsub(self, m): | 57 def regurlsub(self, m): |
58 link = m.group(2) | 58 link = m.group(2) |
59 if m.group(1) != None: | 59 if m.group(1) != None: return '<a href="' + m.group(1).lower() + '">' + m.group(0) + '</a>' |
60 return '<a href="' + m.group(1).lower() + link + '">' + m.group(0) + '</a>' | 60 else: return '<a href="http://' + link + '">' + link + '</a>' |
61 else: | |
62 return '<a href="http://' + link + '">' + link + '</a>' |