コード例 #1
0
ファイル: bridge.py プロジェクト: jvimedia/alpha
    def from_response_data(cls, data):
        user = super(APIUser, cls).from_response_data(data)
        user.avatar_image["30s"] = append_query_string(user.avatar_image.url, params={"w": 30, "h": 30})
        user.avatar_image["57s"] = append_query_string(user.avatar_image.url, params={"w": 57, "h": 57})
        user.avatar_image["80s"] = append_query_string(user.avatar_image.url, params={"w": 80, "h": 80})
        user.cover_image["720r"] = append_query_string(user.cover_image.url, params={"w": 720})
        user.cover_image["862r"] = append_query_string(user.cover_image.url, params={"w": 862})
        user.id = int(user.id)
        # XXX: We need to change our code at some point to handle datetimes with a timezone
        user.created_at = parse_date(user.created_at).replace(tzinfo=None)
        if "name" not in user:
            user.name = ""

        return user
コード例 #2
0
ファイル: bridge.py プロジェクト: dvabhishek/alpha
    def from_response_data(cls, data):
        user = super(APIUser, cls).from_response_data(data)
        user.avatar_image['30s'] = append_query_string(user.avatar_image.url, params={'w': 30, 'h': 30})
        user.avatar_image['57s'] = append_query_string(user.avatar_image.url, params={'w': 57, 'h': 57})
        user.avatar_image['80s'] = append_query_string(user.avatar_image.url, params={'w': 80, 'h': 80})
        user.cover_image['720r'] = append_query_string(user.cover_image.url, params={'w': 720})
        user.cover_image['862r'] = append_query_string(user.cover_image.url, params={'w': 862})
        user.id = int(user.id)
        # XXX: We need to change our code at some point to handle datetimes with a timezone
        user.created_at = parse_date(user.created_at).replace(tzinfo=None)
        if 'name' not in user:
            user.name = ''

        return user
コード例 #3
0
ファイル: bridge.py プロジェクト: AYCHUB/AYCHBlogging.micro
    def from_response_data(cls, data):
        user = super(APIUser, cls).from_response_data(data)
        user.avatar_image['30s'] = append_query_string(user.avatar_image.url, params={'w': 30, 'h': 30})
        user.avatar_image['57s'] = append_query_string(user.avatar_image.url, params={'w': 57, 'h': 57})
        user.avatar_image['80s'] = append_query_string(user.avatar_image.url, params={'w': 80, 'h': 80})
        user.cover_image['720r'] = append_query_string(user.cover_image.url, params={'w': 720})
        user.cover_image['862r'] = append_query_string(user.cover_image.url, params={'w': 862})
        user.id = int(user.id)
        # XXX: We need to change our code at some point to handle datetimes with a timezone
        user.created_at = parse_date(user.created_at).replace(tzinfo=None)
        if 'name' not in user:
            user.name = ''

        return user
コード例 #4
0
ファイル: feed.py プロジェクト: 0xMF/alpha
    def _generate_facepile(self, user):
        facepile_size = 40 * 2
        facepile_img_url = append_query_string(user.avatar_image.url, params={'w': facepile_size, 'h': facepile_size})

        facepile_block = html.a(href=self._user_link(user), *[
            html.img(class_=('interaction-facepile',), alt=user['username'], title=user['username'], src=facepile_img_url)
        ])
        return facepile_block
コード例 #5
0
ファイル: feed.py プロジェクト: 0xMF/alpha
    def generate_html(self):
        if self.post_a.get('is_deleted') and not self.show_deleted:
            return ''

        post_data = {
            'post-id': self.post_a.id,
            # Should the post be remove from the page.
            # or should we insert [deleted] text
            'post-remove-from-page': '0' if self.show_deleted else '1'
        }

        if self.post_a.user:
            post_data['post-author-username'] = self.post_a.user.username
            post_data['post-author-id'] = self.post_a.user.id
        else:
            post_data['post-author-deleted'] = '1'

        if self.repost:
            post_data['post-parent-id'] = self.repost.id

        classes = ['post-container', 'subpixel']
        if not self.single_post and self.in_conversation:
            classes += ['p-in-reply-to', 'h-cite']
        else:
            classes += ['h-entry']

        if self.post_a.get('is_deleted'):
            classes.append('deleted')
        if self.hidden:
            classes.append('hide')

        avatar_size = 114
        avatar_classes = ['avatar']
        if self.single_post:
            classes.append('single-post-container')
            avatar_classes.append('large')
            avatar_size = 160

        avatar_block = ''
        if self.post_a.user:
            avatar_url = append_query_string(self.post_a.user.avatar_image.url, params={'w': avatar_size, 'h': avatar_size})
            avatar_block = html.div(class_='media', *[
                html.a(class_=avatar_classes, data=self.click_data, style={'background-image': 'url(%s)' % avatar_url},
                       href=self.user_detail_url)
            ])

        tree = html.div(class_=classes, data=post_data, name=str(self.post_a.id), *[
            html.div(class_='content', *[
                avatar_block,
                self.generate_post_header(),
                self.generate_post_body(),
                self.generate_post_footer()
            ]),
        ])
        return tree
コード例 #6
0
    def _generate_facepile(self, user):
        facepile_size = 40 * 2
        facepile_img_url = append_query_string(user.avatar_image.url,
                                               params={
                                                   'w': facepile_size,
                                                   'h': facepile_size
                                               })

        facepile_block = html.a(href=self._user_link(user),
                                *[
                                    html.img(class_=('interaction-facepile', ),
                                             alt=user['username'],
                                             title=user['username'],
                                             src=facepile_img_url)
                                ])
        return facepile_block
コード例 #7
0
    def generate_html(self):
        if self.post_a.get('is_deleted') and not self.show_deleted:
            return ''

        post_data = {
            'post-id': self.post_a.id,
            # Should the post be remove from the page.
            # or should we insert [deleted] text
            'post-remove-from-page': '0' if self.show_deleted else '1'
        }

        if self.post_a.user:
            post_data['post-author-username'] = self.post_a.user.username
            post_data['post-author-id'] = self.post_a.user.id
        else:
            post_data['post-author-deleted'] = '1'

        if self.repost:
            post_data['post-parent-id'] = self.repost.id

        classes = ['post-container', 'subpixel']
        if not self.single_post and self.in_conversation:
            classes += ['p-in-reply-to', 'h-cite']
        else:
            classes += ['h-entry']

        if self.post_a.get('is_deleted'):
            classes.append('deleted')
        if self.hidden:
            classes.append('hide')

        avatar_size = 114
        avatar_classes = ['avatar']
        if self.single_post:
            classes.append('single-post-container')
            avatar_classes.append('large')
            avatar_size = 160

        avatar_block = ''
        if self.post_a.user:
            avatar_url = append_query_string(self.post_a.user.avatar_image.url,
                                             params={
                                                 'w': avatar_size,
                                                 'h': avatar_size
                                             })
            avatar_block = html.div(
                class_='media',
                *[
                    html.a(class_=avatar_classes,
                           data=self.click_data,
                           style={'background-image': 'url(%s)' % avatar_url},
                           href=self.user_detail_url)
                ])

        tree = html.div(class_=classes,
                        data=post_data,
                        name=str(self.post_a.id),
                        *[
                            html.div(class_='content',
                                     *[
                                         avatar_block,
                                         self.generate_post_header(),
                                         self.generate_post_body(),
                                         self.generate_post_footer()
                                     ]),
                        ])
        return tree