Mercurial > public > sg101
view gpp/messages/utils.py @ 490:f0f3966ea44f
For #233, switched to asynchronous loading of the social media sharing javascript. Also switched to Facebook's javascript SDK instead of using an iframe for the like/share button.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Thu, 20 Oct 2011 00:36:37 +0000 |
parents | 538a1bd2f1f4 |
children | 4b9970ad0edb |
line wrap: on
line source
""" This file contains various helper utility functions for the messages application. """ from django.utils.text import wrap def reply_subject(subject): """ Builds a subject line for a reply. If the subject already starts with Re: then return the subject. Otherwise, prepend Re: to the subject and return it. """ if subject.startswith('Re: '): return subject return 'Re: ' + subject def quote_message(who, date, message): """ Builds a message reply by quoting the existing message in a typical email-like fashion. The quoting is compatible with Markdown. """ header = '> On %s, %s wrote:\n>\n' % (date.strftime('%a, %b %d %Y, %I:%M %p'), who) lines = wrap(message, 55).split('\n') for i, line in enumerate(lines): lines[i] = '> ' + line return header + '\n'.join(lines) + '\n\n'