Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 0437399511
Fetching contributors…

Cannot retrieve contributors at this time

38 lines (30 sloc) 1.076 kb
import datetime
from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.auth.models import User
from django.http import Http404
from profiles.models import Profile
from webfinger import rel
from xrd import Link
def _build_uri(path):
current_site = Site.objects.get_current()
return 'http://' + current_site.domain + '/' + path
def webfinger(acct, xrd):
try:
user = User.objects.get(username=acct.userinfo)
profile = user.get_profile()
except User.DoesNotExist, Profile.DoesNotExist:
raise Http404
xrd.aliases.append(
_build_uri('profile/%s/' % user.username))
xrd.expires = datetime.datetime.utcnow() + datetime.timedelta(0, 10)
xrd.links.append(Link(
rel=rel.HCARD,
href=_build_uri('profile/%s/' % user.username),
type_='text/html'
))
media_url = settings.MEDIA_URL.rstrip('/').lstrip('/')
xrd.links.append(Link(
rel=rel.AVATAR,
href=_build_uri('%s/%s' % (media_url, profile.avatar)),
type_='image/jpeg'))
Jump to Line
Something went wrong with that request. Please try again.