def links(self): return [ { 'rel': 'http://webfinger.net/rel/profile-page', 'type': 'text/html', 'href': self.profileURL(), }, { 'rel': 'http://schemas.google.com/g/2010#updates-from', 'type': 'application/atom+xml', 'href': self.feedURL(), }, { 'rel': 'self', 'type': 'application/activity+json', 'href': self.feedURL(), }, { 'rel': 'salmon', 'href': self.salmonURL(), }, { 'rel': 'http://ostatus.org/schema/1.0/subscribe', 'template': config.get('AUTHORIZE_FOLLOW_TEMPLATE'), }, ]
def test_gets(self): UN_CHAPEAU['HOSTNAME'] = 'wombat.example.com' UN_CHAPEAU['URL'] = 'https://{hostname}/spong' self.assertEqual( config['HOSTNAME'], 'wombat.example.com', ) self.assertEqual( config.get('HOSTNAME'), 'wombat.example.com', ) self.assertEqual( config.get('URL'), 'https://wombat.example.com/spong', )
def get(self, request, username, *args, **kwargs): user = get_object_or_404(User, username=username) result = user.serialize() return self._render(result) context = { 'user': user, 'statuses': statuses, 'server_name': config['HOSTNAME'], 'hubURL': config['HUB'], } result = render( request=request, template_name='account.atom.xml', context=context, content_type='application/atom+xml', ) link_context = { 'hostname': config['HOSTNAME'], 'username': user.username, 'acct': user.acct(), } links = ', '.join([ '<{}>; rel="{}"; type="{}"'.format( config.get(uri, username=user.username, acct=user.display_name), rel, mimetype) for uri, rel, mimetype in [ ( 'USER_WEBFINGER_URLS', 'lrdd', 'application/xrd+xml', ), ( 'USER_FEED_URLS', 'alternate', 'application/atom+xml', ), ( 'USER_FEED_URLS', 'alternate', 'application/activity+json', ), ] ]) result['Link'] = links return result
def _path_formatting(self, formatting): return config.get( formatting, username=self.posted_by.username, id=self.id, )
def outboxURL(self): return config.get( 'USER_OUTBOX_URLS', username=self.username, )
def inboxURL(self): return config.get( 'USER_INBOX_URLS', username=self.username, )
def followingURL(self): return config.get( 'USER_FOLLOWING_URLS', username=self.username, )
def followersURL(self): return config.get( 'USER_FOLLOWERS_URLS', username=self.username, )
def salmonURL(self): return config.get( 'USER_SALMON_URLS', username=self.username, )
def feedURL(self): return config.get( 'USER_FEED_URLS', username=self.username, )
def profileURL(self): return config.get( 'USER_URLS', username=self.username, )