Beispiel #1
0
 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'),
         },
     ]
Beispiel #2
0
    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',
        )
Beispiel #3
0
    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
Beispiel #4
0
 def _path_formatting(self, formatting):
     return config.get(
         formatting,
         username=self.posted_by.username,
         id=self.id,
     )
Beispiel #5
0
 def outboxURL(self):
     return config.get(
         'USER_OUTBOX_URLS',
         username=self.username,
     )
Beispiel #6
0
 def inboxURL(self):
     return config.get(
         'USER_INBOX_URLS',
         username=self.username,
     )
Beispiel #7
0
 def followingURL(self):
     return config.get(
         'USER_FOLLOWING_URLS',
         username=self.username,
     )
Beispiel #8
0
 def followersURL(self):
     return config.get(
         'USER_FOLLOWERS_URLS',
         username=self.username,
     )
Beispiel #9
0
 def salmonURL(self):
     return config.get(
         'USER_SALMON_URLS',
         username=self.username,
     )
Beispiel #10
0
 def feedURL(self):
     return config.get(
         'USER_FEED_URLS',
         username=self.username,
     )
Beispiel #11
0
 def profileURL(self):
     return config.get(
         'USER_URLS',
         username=self.username,
     )