Snippet List
Update to https://djangosnippets.org/snippets/1907/ to be a bit more flexible, and code cleaned up a tiny bit.
To use, add this snippet as a file in a templatetags folder in an app or in a project. Then include and call the tag with
{% obfuscate_email 'email' %}
or
{% obfuscate_email 'email' 'link_text' %}
if 'link_text' is provided, it will be used as the text in the body of the <a> tag. If not, then the email will be used.
..
- akismet
- spam
- comments
- command
Put this snippet in a file in a templatetags/ directory and load it in your templates. Then use it to encode your emails:
`{{"[email protected]"|html_encode_email}}`
Or if you want some control over the anchor tag:
`<a href="mailto:{{"[email protected]"|html_encode}}&subject=Feedback">Send Feedback</a>`
From [fahhem.com](http://fahhem.com/) and [Recrec Labs](http://recreclabs.com/)
- templatetag
- email
- spam
- encode
A general AntiSpamForm using some tricks to prevent spam based on current [django.contrib.comments.forms](http://code.djangoproject.com/browser/django/trunk/django/contrib/comments/forms.py). It uses a timestamp, a security hash and a honeypot field. See [AntiSpamModelForm](http://www.djangosnippets.org/snippets/1856/) too.
A general AntiSpamModelForm using some tricks to prevent spam based on current [django.contrib.comments.forms](http://code.djangoproject.com/browser/django/trunk/django/contrib/comments/forms.py). It uses a timestamp, a security hash and a honeypot field. See [AntiSpamForm](http://www.djangosnippets.org/snippets/1925/) too.
This is a rewrite of [snippet #1006](http://www.djangosnippets.org/snippets/1006/) to use the moderation features available in Django's comments framework. This is more customizable than the signals approach and works well if other moderation features are being used. If you want to make comments that are flagged as spam become hidden instead of deleted, change the allow() method to moderate(). [See the blog post here](http://sciyoshi.com/blog/2009/jul/17/prevent-django-newcomments-spam-akismet-reloaded/)
- akismet
- spam
- comments
- antispam
- newcomments
entity encoded string for a somewhat safer email-address.
this filter encodes strings to numeric entities, almost every standard-browsers decodes the entities and display them the right way.
needless to say that bots are smart, so this is not a 100% guaranteed spam prevention.
Simple anti-spam field which will cause the form to raise a `ValidationError` if the value in this field changes. Displays as a CSS hidden `<input type="text" />` field.
If you specify a `class` in the `attrs` of the widget, the default `style="display:none;"` won't be rendered with the widget so that you can use a predefined CSS style to do your hiding instead. You can also cause the widget to be wrapped in an html comment to ensure it is not visible to the end user:
class EmailForm(Form):
email = EmailField()
website = HoneypotField(widget=HoneypotWidget(
attrs={'class':'fish'}, html_comment=True))
A short little bit of code to test for comment spam against Akimet.
Use:
a = Akismet('<AkismetKey>', 'http://sneeu.com/blog/')
a.verify_key()
print a.comment_check(
comment_author='...',
comment_author_email='[email protected]',
user_ip='10.0.0.1',
comment_content="""Comment content!"""
)
- rest
- python
- akismet
- spam
- webservice
- comment
13 snippets posted so far.