annotate plugins/xxurl2link.py @ 245:682032381be8 beta

Traipse Beta 'OpenRPG' {101130-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 (Closing/Closed) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order New to Server GUI, can now clear log New Earthdawn Dieroller New IronClaw roller, sheet, and image Updates: Update to Warhammer PC Sheet. Rollers set as macros. Should work with little maintanence. Update to Browser Server window. Display rooms with ' " & cleaner Update to Server. Handles ' " & cleaner Update to Dieroller. Cleaner, more effecient expression system Update to Hidden Die plugin, allows for non standard dice rolls Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created Fix to Single and Double quotes in Whiteboard text Fix to Background images not showing when using the Image Server Fix to Duplicate chat names appearing Fix to Server GUI's logging output Fix to FNB.COLORFUL_TABS bug Fix to Gametree for XSLT Sheets Fix to Gametree for locating gametree files Fix to Send to Chat from Gametree Fix to Gametree, renaming and remapping operates correctly Fix to aliaslib, prevents error caused when SafeHTML is sent None
author sirebral
date Tue, 30 Nov 2010 02:34:58 -0600
parents 13054be69834
children
rev   line source
190
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
1 import os, re, wx
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
2 import orpg.pluginhandler
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 class Plugin(orpg.pluginhandler.PluginHandler):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
5 # Initialization subroutine.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
6 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 # !self : instance of self
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 # !chat : instance of the chat window to write to
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
9 def __init__(self, plugindb, parent):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
10 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 self.name = 'URL to link conversion'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13 self.author = 'tdb30 tbaleno@wrathof.com'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 self.help = "This plugin automaticaly wraps urls in link tags\n"
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 self.help += "making them clickable."
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16
190
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
17 def plugin_menu(self):
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
18 self.menu = wx.Menu()
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
19 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On')
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
20 self.topframe.Bind(wx.EVT_MENU, self.plugin_toggle, self.toggle)
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
21
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
22 def plugin_toggle(self, evt):
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
23 if self.toggle.IsChecked() == True: self.plugindb.SetString('xxurl2link', 'url2link', 'True')
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
24 if self.toggle.IsChecked() == False: self.plugindb.SetString('xxurl2link', 'url2link', 'False')
190
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
25 pass
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
26
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27 def plugin_enabled(self):
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
28 self.url_regex = re.compile( #from Paul Hayman of geekzilla
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
29 "((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.I)
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
30 self.mailto_regex = re.compile( #Taken from Django
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
31 r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
32 r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
33 r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE)
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
34 self.link = self.plugindb.GetString('xxurl2link', 'url2link', '') or 'False'
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
35 self.toggle.Check(True) if self.link == 'True' else self.toggle.Check(False)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
36
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
37 def plugin_disabled(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
38 pass
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
39
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 def pre_parse(self, text):
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
41 text2 = text
190
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
42 if self.toggle.IsChecked() == True:
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
43 text = self.mailto_regex.sub(self.regmailsub, text)
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
44 text = self.url_regex.sub(self.regurlsub, text)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
45 return text
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
46
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
47 def plugin_incoming_msg(self, text, type, name, player):
190
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
48 if self.toggle.IsChecked() == True:
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
49 text = self.mailto_regex.sub(self.regmailsub, text)
15488fe94f52 Traipse Beta 'OpenRPG' {100125-01}
sirebral
parents: 0
diff changeset
50 text = self.url_regex.sub(self.regurlsub, text)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
51 return text, type, name
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
52
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
53 def regmailsub(self, m):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
54 term = m.group(0).lower()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
55 return '<a href="mailto:' + term + '">' + m.group(0) + '</a>'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
56
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
57 def regurlsub(self, m):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
58 link = m.group(2)
212
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
59 if m.group(1) != None: return '<a href="' + m.group(1).lower() + '">' + m.group(0) + '</a>'
13054be69834 Traipse Beta 'OpenRPG' {100428-00}
sirebral
parents: 190
diff changeset
60 else: return '<a href="http://' + link + '">' + link + '</a>'