Mercurial > public > sg101
comparison gpp/shoutbox/forms.py @ 1:dbd703f7d63a
Initial import of sg101 stuff from private repository.
author | gremmie |
---|---|
date | Mon, 06 Apr 2009 02:43:12 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:900ba3c7b765 | 1:dbd703f7d63a |
---|---|
1 """ | |
2 Forms for the Shoutbox application. | |
3 """ | |
4 | |
5 import re | |
6 from django import forms | |
7 | |
8 url_re = re.compile('(' | |
9 r'^https?://' # http:// or https:// | |
10 r'(?:(?:[A-Z0-9-]+\.)+[A-Z]{2,6}|' #domain... | |
11 r'localhost|' #localhost... | |
12 r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip | |
13 r'(?::\d+)?' # optional port | |
14 r'(?:/?|/\S+))', re.IGNORECASE) | |
15 | |
16 | |
17 class ShoutBoxForm(forms.Form): | |
18 msg = forms.CharField(label='', max_length=2048, required=True) | |
19 | |
20 def get_shout(self): | |
21 msg = self.cleaned_data['msg'] | |
22 msg = re.sub(url_re, r'<a href="\1">URL</a>', msg) | |
23 return msg | |
24 |