Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

61 lines (45 sloc) 1.783 kb
import hashlib
import re
import urllib
from django.conf import settings
from django.template import Context
from django.template.loader import get_template
from django.utils.safestring import mark_safe
import jinja2
from funfactory.utils import absolutify
from jingo import register
PARAGRAPH_RE = re.compile(r'(?:\r\n|\r|\n){2,}')
absolutify = register.function(absolutify)
def paragraphize(value):
return jinja2.Markup(
u'\n\n'.join(u'<p>%s</p>' % p.replace('\n', '<br>\n')
for p in PARAGRAPH_RE.split(jinja2.escape(value))))
def search_result(context, profile):
d = dict(context.items())
return d
def gravatar(email, default='%simg/unknown.png' % (settings.MEDIA_URL),
size=175, rating='pg'):
"""Return the Gravatar URL for an email address."""
return '' % (
urllib.urlencode({'d': absolutify(default),
's': str(size),
'r': rating}))
def bootstrap(element):
"""Renders bootstrap forms in jinja2.
Takes an element that is either a field or an entire form and
renders the appropriate bootstrap elements.
element_type = element.__class__.__name__.lower()
if element_type == 'boundfield':
template = get_template("bootstrapform/field.html")
context = Context({'field': element})
template = get_template("bootstrapform/form.html")
context = Context({'form': element})
return mark_safe(template.render(context))
Jump to Line
Something went wrong with that request. Please try again.