class ProjectEditForm(forms.ModelForm): project_name = forms.CharField(label=mark_safe(u'Project name'), max_length=50, error_messages=required_error) project_owner = forms.ModelChoiceField( label=mark_safe(u'Product owner'), queryset=User.objects.all().order_by('username'), error_messages=required_error) scrum_master = forms.ModelChoiceField( label=mark_safe(u'Scrum master'), queryset=User.objects.all().order_by('username'), error_messages=required_error) team = forms.ModelMultipleChoiceField(widget=forms.HiddenInput(), queryset=User.objects.none(), required=False) #validate if name already taken under other roles def clean_scrum_master(self): scrum_master = self.cleaned_data['scrum_master'] try: project_owner = self.cleaned_data['project_owner'] except KeyError: return scrum_master if scrum_master == project_owner: raise ValidationError("Role " + str(scrum_master) + " is already taken.") return return scrum_master class Meta: model = Project
class UserForm(forms.ModelForm): email = forms.EmailField(label=mark_safe(u'Email'), error_messages=required_error) is_superuser = forms.BooleanField(label=mark_safe(u'Administrator'), required=False) username = forms.CharField(label=mark_safe(u'Username'), error_messages=required_error) first_name = forms.CharField(label=mark_safe(u'Name'), error_messages=required_error) last_name = forms.CharField(label=mark_safe(u'Surname'), error_messages=required_error) password = forms.CharField(widget=forms.PasswordInput(), label="Password", error_messages=required_error) password2 = forms.CharField(widget=forms.PasswordInput(), label="Repeat password", error_messages=required_error) def clean_password(self): if self.data['password'] != self.data['password2']: raise forms.ValidationError('Passwords do not match.') return self.data['password'] class Meta: model = User fields = ( 'first_name', 'last_name', 'username', 'email', 'is_superuser', 'password', )
def admin_actions(request, modelname, appname): if not request.user.is_superuser: return HttpResponseForbidden('Superuser only!') model = get_model(modelname, appname) id_list = request.POST.getlist('item_id_list') if id_list: for id in id_list: obj = model.objects.get(pk=id) # Delete Item if request.POST.has_key('_delete'): obj.delete() request.user.message_set.create(message=_('"%s" was deleted') % mark_safe(obj.title)) # Open Item elif request.POST.has_key('_markopen'): obj.public = True obj.save() request.user.message_set.create(message=_('"%s" was opened') % mark_safe(obj.title)) # Close Item elif request.POST.has_key('_markclosed'): obj.public = False obj.save() request.user.message_set.create(message=_('"%s" was closed') % mark_safe(obj.title)) # Wrong Action Parameter else: request.user.message_set.create(message='Wrong Action Parameter') # None Checkbox checked else: request.user.message_set.create(message=_('Nothing to do...')) return HttpResponseRedirect('/admin/%s/%s/' % (modelname, appname))
class TaskEditForm(forms.ModelForm): story = forms.ModelChoiceField(widget=forms.HiddenInput(), queryset=Story.objects.all(), required=False) duratino = forms.FloatField( label=mark_safe(u'Planned duration'), error_messages=velocity_error, validators=[ RegexValidator(regex='^(?!0*(\.0+)?$)(\d+|\d*\.\d+)$', message='Please enter a positive float number.', code='invalid_value'), ]) status = forms.IntegerField(widget=forms.HiddenInput(), initial=0) worker = forms.ModelChoiceField(queryset=User.objects.all(), label=mark_safe('Member'), required=False) def __init__(self, project_id, *args, **kwargs): super(TaskEditForm, self).__init__(*args, **kwargs) # populates the post self.fields['worker'].queryset = Project.objects.get( id=project_id).team.order_by('username') class Meta: model = Task
class AdminForm(forms.Form): admin_username = forms.CharField( label=mark_safe('<strong>Username</strong>'), max_length=20) admin_password = forms.CharField( label=mark_safe('<strong>Password</strong>'), max_length=11, widget=forms.PasswordInput)
def plainorhtml(value, autoescape=None): if "<p>" in value.lower() or "<br" in value.lower(): return mark_safe(value) else: from django.utils.html import linebreaks return mark_safe(linebreaks(value, autoescape))
class ColourForm(forms.ModelForm): colour = forms.CharField(max_length=50, label=mark_safe('<strong>Colour</strong>')) hex = forms.CharField(max_length=50, label=mark_safe('<strong>Hex Code</strong>')) class Meta: model = Colour fields = "__all__"
class ModuleForm(forms.ModelForm): modCode = forms.CharField(max_length=7, label=mark_safe('<strong>Module Code</strong>')) modName = forms.CharField(max_length=70, label=mark_safe('<strong>Module Name</strong>')) colour = Colour.objects.all() class Meta: model = Module fields = "__all__"
class CourseForm(forms.ModelForm): courseCode = forms.CharField(max_length=15, label=mark_safe('<strong>Code</strong>')) courseName = forms.CharField(max_length=50, label=mark_safe('<strong>Name</strong>')) department = queryset = Department.objects.all() class Meta: model = Course fields = "__all__"
def render(self, name, value, attrs=None): x = randint(self.min_images, self.max_images) y = self.max_images - x self.x = x self.y = y self.hashed_answer = hashlib.sha1(settings.SECRET_KEY + str(x)). \ hexdigest() + hexlify(str(x)) if value: value[1] = self.hashed_answer # render image output = StringIO.StringIO() im_answer = Image.open(settings.CAPTCHA_IMAGE_ANSWER) im_other = Image.open(settings.CAPTCHA_IMAGE_OTHER) im_answer_size = im_answer.size im_other_size = im_other.size padding = getattr(settings, 'CAPTCHA_IMAGE_PADDING', 0) im = Image.new( "RGBA", ( max((im_answer_size[0] + padding) * self.max_images, (im_other_size[0] + padding) * self.max_images), max(im_answer_size[1], im_other_size[1]) ) ) for i in xrange(self.x): im.paste(im_answer, (i * (im_answer_size[0] + padding), 0), im_answer) for i in xrange(self.y): im.paste( im_other, (self.x * (im_answer_size[0] + padding) + i * (im_other_size[0] + padding), 0), im_other ) im.save(output, format="PNG") output.seek(0) image_b64 = base64.b64encode(output.read()) image_position = getattr(settings, 'CAPTCHA_IMAGE_POSITION', "left") if image_position == "left": return mark_safe( u'<img src="data:image/png;base64,%s" class="cp-image"> %s' % ( image_b64, super(ImageCountCaptchaWidget, self).render(name, value, attrs) )) return mark_safe( u'%s <img src="data:image/png;base64,%s" class="cp-image">' % ( super(ImageCountCaptchaWidget, self).render(name, value, attrs), image_b64 ))
def render_html(page): if page.text_format == 'text/plain': return mark_safe(linebreaks(escape(page.content))) elif page.text_format == 'text/markdown': return mark_safe(markdown(escape(page.content))) elif page.text_format == 'text/html': return mark_safe(page.content) else: raise Exception('invalid content type')
class ContactForm(forms.Form): c_name = forms.CharField(required=True, label=mark_safe(u'<strong>username</strong>')) c_email = forms.EmailField(required=True, label=mark_safe(u'<strong>email</strong>')) m_title = forms.CharField( required=True, label=mark_safe(u'<strong>message title</strong>')) m_content = forms.CharField( required=True, widget=forms.Textarea, label=mark_safe(u'<strong>message content</strong>')) captcha = CaptchaField()
class RoomForm(forms.ModelForm): roomCode = forms.CharField(max_length=15, label=mark_safe('<strong>Room Code</strong>')) roomName = forms.CharField(max_length=30, label=mark_safe('<strong>Room Name</strong>')) building = queryset = Building.objects.all() #lat = forms.CharField(max_length = 19, label = mark_safe('<strong>Latitude</strong>')) #lng = forms.CharField(max_length = 19, label = mark_safe('<strong>Longitude</strong>')) class Meta: model = Room fields = "__all__"
class StoryEditForm(forms.ModelForm): project_name = forms.ModelChoiceField(queryset=Project.objects.all(), widget=forms.HiddenInput()) story_name = forms.CharField(label=mark_safe('Name'), error_messages=required_error) text = forms.CharField(label=mark_safe('Content'), widget=forms.Textarea, error_messages=required_error) bussines_value = forms.IntegerField( label=mark_safe('Bussines value'), error_messages=velocity_error, validators=[ RegexValidator(regex='^[0-9]*$', message='Please enter a positive integer.', code='invalid'), ]) priority = forms.TypedChoiceField(label=mark_safe('Priority'), choices=Story.PRIORITY_CHOICES) test_text = forms.CharField(label=mark_safe('Acceptance tests'), widget=forms.Textarea, error_messages=required_error) class Meta: model = Story fields = ( 'project_name', 'story_name', 'text', 'bussines_value', 'priority', 'test_text', ) def clean_story_name(self): story_name_new = self.cleaned_data['story_name'] project_name_id = self.cleaned_data['project_name'] #covering with the other story name covering = Story.objects.filter(story_name=story_name_new, project_name=project_name_id) if len(covering) > 0: if not story_name_new == covering[0].story_name: raise ValidationError("Story with same name already exists.") return return story_name_new
def get_id(self, obj): # 这里的obj就是这个模型的一条数据对象,如果你有10条数据,这个方法就要执行10次 get_pk = int(obj.pk) # 获取这个队列的pk mm = int(obj.number) if mm == 0: return mark_safe("""<a href="/lunbotu/?pk=%s">点我上传</a>""" % get_pk) else: return mark_safe("""<p>上传成功 </p> """)
class LecturerForm(forms.ModelForm): lecCode = forms.CharField( max_length=7, label=mark_safe('<strong>Code</strong>'), ) lecFirst_Name = forms.CharField( max_length=50, label=mark_safe('<strong>First Name</strong>')) lecLast_Name = forms.CharField( max_length=50, label=mark_safe('<strong>Last Name</strong>')) lecEmail = forms.EmailField(label=mark_safe('<strong>Email</strong>')) class Meta: model = Lecturer fields = "__all__"
class Work_Time_Edit_Form(forms.ModelForm): task = forms.ModelChoiceField(widget=forms.HiddenInput(), queryset=Task.objects.all(), required=True) worker = forms.ModelChoiceField(widget=forms.HiddenInput(), queryset=User.objects.all(), required=True) day = forms.DateField(label=mark_safe(u'Day')) time = forms.DecimalField(max_digits=4, decimal_places=1, label=mark_safe(u'Working time (in hours)'), required=True) class Meta: model = Work_Time
def _processDownloadedFile(self, vidFile, title, desc, mediaPath): orig = os.path.join(self.tmp, vidFile) new = os.path.join(settings.MEDIA_ROOT, mediaPath, vidFile) subprocess.call(['yamdi', '-i', orig, '-o', new]) try: mf = MediaFile.objects.get(file=os.path.join(mediaPath, vidFile)) except MediaFile.DoesNotExist: mf = MediaFile(file=os.path.join(mediaPath, vidFile)) mf.save() tr = mf.get_translation() if tr == None: tr = MediaFileTranslation(parent=mf, language_code='cs') tr.caption = mark_safe(title) tr.description = mark_safe(desc) tr.save()
def admin_disable_on_organizations(self): return format_html_join( mark_safe('<br>'), '<a href="{}?id={}" class="view_tipology">{}</a>', ((reverse(admin_urlname(obj._meta, 'changelist')), obj.pk, obj.title) for obj in self.disable_on_organizations.all()))
class RegistrationForm(forms.Form): email = forms.EmailField(label=mark_safe('<strong>Email</strong>')) #password = forms.CharField(widget=forms.PasswordInput) # Set the widget to # PasswordInput #password2 = forms.CharField(widget=forms.PasswordInput,label="Confirm password") # Set the widget to # PasswordInput and # set an appropriate # label captcha = CaptchaField(label=mark_safe('<strong>Captcha</strong>')) # clean_<fieldname> method in a form class is used to do custom validation # for the field. # We are doing a custom validation for the 'password2' field and raising # a validation error if the password and its confirmation do not match """def clean_password2(self):
class OrderForm(forms.ModelForm): packer = forms.ModelChoiceField( required=True, label=mark_safe('<label id="packer_id_label">Empacador</label>'), queryset=User.objects.filter(groups__name__in=['empacador']), widget=forms.Select(attrs={})) expiration = forms.DateField(label='Caducidad', required=False, widget=forms.TextInput()) def __init__(self, *args, **kwargs): super(OrderForm, self).__init__(*args, **kwargs) for field_name, field in self.fields.items(): field.widget.attrs['class'] = 'form-control' class Meta: model = Orders exclude = ('flag', 'packer_name', 'client_name', 'product_name', 'qty', 'weight', 'delta_weight') def clean_bpid(self): return self.cleaned_data.get('bpid').upper() def clean_order(self): return self.cleaned_data.get('order').upper() as_myp = as_myp
class UserProfileForm(forms.ModelForm): picture = forms.ImageField(label=mark_safe(u'Prikazna slika'), required=False) class Meta: model = UserProfile fields = ('picture', )
class NotificationPermissionForm(forms.ModelForm): permission = forms.BooleanField( label=mark_safe(u'Allow story notifications'), required=False) class Meta: model = NotificationPermission fields = ('permission', )
def due_date_status_badge(self): color = 'default' overdue = '' if self.due_date: due_date = self.due_date now = datetime.date.today() if due_date >= now: date_diff = due_date - now days_from_due_date = date_diff.days if days_from_due_date == 2: color = 'info' days_from_due_date_string = "%s days" %(days_from_due_date) elif days_from_due_date == 1: color = 'warning' days_from_due_date_string = 'Tomorrow' elif days_from_due_date == 0: color = 'danger' days_from_due_date_string = 'Today' else: days_from_due_date_string = "%s" %(due_date.strftime("%b %d")) else: color = 'danger' overdue = 'overdue' date_diff = now - due_date days_from_due_date = date_diff.days if days_from_due_date == 1: days_from_due_date_string = "%s day" %(days_from_due_date) else: days_from_due_date_string = "%s days" %(days_from_due_date) return mark_safe('<span class="label label-%s"><span class="glyphicon glyphicon-time" aria-hidden="true"></span> %s %s</span>' %(color, days_from_due_date_string, overdue)) return ''
def stop_time_span(dt): if not dt: return '----' dt_il = dt.astimezone(ISRAEL_TIMEZONE) return mark_safe('<span title="{0}">{1}</span>').format( dt_il.isoformat(), dt_il.strftime('%H:%M:%S'))
def _get_last_post_info(self): if self.last_post: params = ( self.last_post.date_created.strftime('%d %b %y at %H:%M:%S'), timesince(self.last_post.date_created), ) return mark_safe('<abbr title="Posted %s">%s</abbr>' % params)
def render(self, to, context, from_email=''): context = Context(dict(context, subject=self.subject)) subject = Template(self.subject).render(context) base_template = get_template(self.base_template_name) content = mark_safe(Template(self.content).render(context)) body = base_template.render(Context({'content': content})) connection = get_connection() connection.__dict__.update(**dict( (field, getattr(self.connection_profile, field)) for field in ( 'host', 'port', 'use_tls', 'username', 'password', ))) # accept a single email as a string if not isinstance(to, (list, tuple)): to = [to] email = EmailMultiAlternatives(subject, striptags(body), from_email, to, connection=connection) email.attach_alternative(body, 'text/html') return email
def __unicode__(self): try: target_url = self.target_object.get_absolute_url() except: target_url = None context = { "sender": self.sender_object, "action": truncatechars(self.action_object, 30), "target": self.target_object, "target_url": target_url, "verb": self.verb, "recipient": self.recipient, "verify_read": reverse('notifications_read', kwargs={ "id": self.id, }) } if self.target_object: if self.action_object: if target_url: return mark_safe( '<a href="%(verify_read)s?next=%(target_url)s">%(sender)s %(verb)s %(target)s</a>' % context) return '%(sender)s %(verb)s %(target)s' % context return '%(sender)s %(verb)s %(target)s' % context return '%(sender)s %(verb)s' % context
class DepartmentForm(forms.ModelForm): depName = forms.CharField( max_length=50, label=mark_safe('<strong>Department Name</strong>')) class Meta: model = Department fields = "__all__"
def __init__(self, *args, **kwargs): super(UserRolesForm, self).__init__(*args, **kwargs) if 'group' in self.fields: # readonly forms doesn't have fields instance = kwargs.get('instance', None) if instance: self.fields['group'].widget = ReadOnlyWidget(original_value=instance.group.pk, display_value=mark_safe('<b>'+get_admin_link(instance.group)))
class BuildingForm(forms.ModelForm): buildingName = forms.CharField( max_length=75, label=mark_safe('<strong>Building Name</strong>')) class Meta: model = Building fields = "__all__"
def set_question(self, x, y, operator): question_tmpl = _('What is %i %s %i?') # make multiplication operator more human-readable operator_for_label = '×' if operator == '*' else operator question = question_tmpl % (x, operator_for_label, y) html = '<span class="%s">%s</span>' % (self.question_class, question) self.question_html = mark_safe(html)
class NewWorkoutForm(forms.Form): max_squat = forms.IntegerField( min_value=0, max_value=9999, label=mark_safe('<strong>Back Squat 1 RM</strong>')) max_bench = forms.IntegerField( min_value=0, max_value=9999, label=mark_safe('<strong>Bench Press 1 RM</strong>')) max_deadlift = forms.IntegerField( min_value=0, max_value=9999, label=mark_safe('<strong>Deadlift 1 RM</strong>')) max_overhead = forms.IntegerField( min_value=0, max_value=9999, label=mark_safe('<strong>Overhead Press 1 RM</strong>'))
def render(self, name, value, attrs=None): # hash answer and set as the hidden value of form hashed_answer = self.generate_captcha() value = ['', hashed_answer] rendered_widgets = super(MathCaptchaWidget, self).render(name, value, attrs=attrs) return mark_safe(self.format_output(rendered_widgets))
def fail_out(self): messages.error( self.request, mark_safe( 'That activation key appears to be invalid. Please contact ' '<a href="mailto:[email protected]">our web developer</a> ' 'to see about getting this fixed.' ) ) return HttpResponseRedirect(reverse("index"))
def set_question(self, x, y, operator): # make multiplication operator more human-readable operator_for_label = '×' if operator == '*' else operator question = self.question_tmpl % { 'num1': x, 'operator': operator_for_label, 'num2': y } self.question_html = mark_safe(question)
def render(self, context): obj = self.obj.resolve(context) annotation_list = Annotation.objects.filter(content_type=ContentType.objects.get_for_model(obj.entity), object_id=obj.entity.id) annotation_list = annotation_list.values('id', 'commentor_id', 'comment', 'position') annotation_json = simplejson.dumps(list(annotation_list)) return mark_safe(annotation_json)
def __init__(self, *args, **kwargs): super(UserRolesForm, self).__init__(*args, **kwargs) if 'group' in self.fields: # readonly forms doesn't have fields instance = kwargs.get('instance', None) if instance: self.fields['group'].widget = ReadOnlyWidget( original_value=instance.group.pk, display_value=mark_safe('<b>' + get_admin_link(instance.group)))
def set_question(self, x, y, operator): # make multiplication operator more human-readable operator_for_label = '×' if operator == '*' else operator question = self.question_tmpl % { 'num1': x, 'operator': operator_for_label, 'num2': y } html = '<span class="%s">%s</span>' % (self.question_class, question) self.question_html = mark_safe(html)
def __init__(self, *args, **kwargs): super(GroupRolesInlineForm, self).__init__(*args, **kwargs) if 'user' in self.fields: # readonly forms doesn't have fields instance = kwargs.get('instance', None) if instance: self.fields['user'].widget = ReadOnlyWidget(original_value=instance.user.pk, display_value=mark_safe('<b>'+get_admin_link(instance.user))) elif self.group: users = User.objects.exclude(roles__group=self.group).distinct() self.fields['user'].queryset = users.order_by('username')
def get_params_only(context, **params): """Build a GET query string from current GET params and kwargs. The result can be appended behind URL path because starts with '?' This modification will append only given parameters and discard any existing """ if 'request' not in context: raise ValueError("Context does not have a request") if len(params) == 0: return '' return mark_safe(u'?{0}'.format(urlencode(params)))
def _get_author_link(self): if self.author: params = ( reverse('vcboard-user-profile', args=[self.author.username]), self.author.username ) link = '<a href="%s" class="author-link">%s</a>' % params val = mark_safe(link) else: val = _('Anonymous') return val
def context_helper(context): result = [] #(o, repr, link) seen = set() if not context: result.append("<p>No context given.</p>") else: result.append("<p>Context includes:</p>") result.append("<table><tr><th>name</th><th>type</th><th>value</th></tr>") for k,v in context.items(): _context_helper([k], context[k], 0, seen, result) result.append("</table><p>Context finished.</p>") return mark_safe("\n".join(result))
def __init__(self, user, *args, **kwargs): super(MultiplayerGameForm, self).__init__(*args, **kwargs) self.fields["color"] = forms.ChoiceField( label=mark_safe('<span class="text-large">Meine Farbe</span>'), choices=( (CELL_PLAYER1, user.theme.player1), (CELL_PLAYER2, user.theme.player2), ), widget=forms.RadioSelect(attrs={ 'inline': True, 'class': 'input-xlarge' }))
def __init__(self, *args, **kwargs): super(GroupAdminForm, self).__init__(*args, **kwargs) group = kwargs.get('instance', False) if group: for resource, verbose in ResourceRequest.RESOURCES: has_request = group.resource_requests.filter(resource=resource).exists() if 'request_%s' % resource in self.fields: self.fields['request_%s' % resource].initial = has_request # show a message to the operators if exists a resource request elif has_request and 'allow_%s' % resource in self.fields: label = mark_safe("%s <span class='help' style='color:black'>" "(resource requested by the admin of the group)</span>" % self.fields['allow_%s' % resource].label) self.fields['allow_%s' % resource].label = label
def __init__(self, user, *args, **kwargs): super(MultiplayerGameForm, self).__init__(*args, **kwargs) self.fields["color"] = forms.ChoiceField( label=mark_safe('<span class="text-large">Meine Farbe</span>'), choices=( (CELL_PLAYER1, user.theme.player1), (CELL_PLAYER2, user.theme.player2), ), widget=forms.RadioSelect( attrs={ 'inline': True, 'class': 'input-xlarge' } ) )
def _radio_button_label(name, value, label_text, radio_number, checked = False): """Create a label for a form field with a radio button next to it Parameters: name - the name of the entire radio field value - the value of the particular radio button label_text - the text to display next to the button checked - True if the radio button is selected (default False) """ if checked: checked = 'checked="checked"' else: checked = "" template = '<input type="radio" name="{0}" value="{1}" id="id_{0}_{4}" {2}/> {3}' return mark_safe(template.format(name, value, checked, label_text, radio_number))
def get_link(self): try: target_url = self.target_object.get_absolute_url() except: target_url = reverse('notifications_all') context = { "sender": self.sender_object, "action": truncatechars(self.action_object,30), "target": self.target_object, "target_url":target_url, "verb": self.verb, "recipient": self.recipient, "verify_read": reverse('notifications_read', kwargs={"id":self.id,}) } if self.target_object: return mark_safe('<a href="%(verify_read)s?next=%(target_url)s">%(sender)s %(verb)s %(target)s</a>' %context) return '<a href="%(verify_read)s?next=%(target_url)s">%(sender)s %(verb)s</a>' %context
def get_commit_history(): parsed = feedparser.parse(TEHORNG_COMMIT_URL) entries = parsed['entries'] commits = [] for entry in entries: commit_updated = datetime.datetime.fromtimestamp(time.mktime(entry.updated_parsed)) commit_link = entry.link commit_hash = entry.link.split('/')[-1][:7] commit_msg = entry.title time_format = "%H:%M:%S on %b. %d %Y" s = mark_safe("""<a href="%s" title="%s">%s</a> %s <strong>%s</strong>""" % (commit_link, commit_msg, commit_hash, commit_msg, commit_updated.strftime(time_format) )) commits.append(s) return commits
def render(self, to, context, from_email=''): context = Context(dict(context, subject=self.subject)) subject = Template(self.subject).render(context) base_template = get_template(self.base_template_name) content = mark_safe(Template(self.content).render(context)) body = base_template.render(Context({'content': content})) connection = get_connection() connection.__dict__.update(**dict( (field, getattr(self.connection_profile, field)) for field in ('host', 'port', 'use_tls', 'username', 'password',))) # accept a single email as a string if not isinstance(to, (list, tuple)): to = [to] email = EmailMultiAlternatives( subject, striptags(body), from_email, to, connection=connection) email.attach_alternative(body, 'text/html') return email
def uid(obj): if hasattr(obj,'get_absolute_url'): return mark_safe('<a href="{0}">{1}</a>'.format(obj.get_absolute_url(),obj.id)) return obj.id
def smarty(value): # smartypants return mark_safe(smartyPants(value))
def widont(value): # http://shauninman.com/archive/2006/08/22/widont_wordpress_plugin return mark_safe(value)
def rewritesrc(value): return mark_safe(srcregex.sub('<\g<1>data-src', styleregex.sub('', value)))
def titlecase(value): return mark_safe(tc(value))
def purge_content(value): return mark_safe(value.replace('<p> </p>', ''))