Ejemplo n.º 1
0
    def get(self):
        title = 'Latest'

        p = self.get_argument('p', 1)
        pagination = Topic.query.order_by('-last_reply_time').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('topic_list.html', title=title, pagination=pagination)
Ejemplo n.º 2
0
    def get(self):
        title = 'Popular'

        p = self.get_argument('p', 1)
        pagination = Topic.query.order_by('-impact').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('topic_list.html', title=title, pagination=pagination)
Ejemplo n.º 3
0
    def get(self):
        title = 'Popular'

        p = self.get_argument('p', 1)
        pagination = Topic.query.order_by('-impact').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('topic_list.html', title=title, pagination=pagination)
Ejemplo n.º 4
0
    def get(self):
        title = 'Latest'

        p = self.get_argument('p', 1)
        pagination = Topic.query.order_by('-last_reply_time').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('topic_list.html', title=title, pagination=pagination)
Ejemplo n.º 5
0
    def get(self, slug):
        node = Node.query.filter_by(slug=slug).first_or_404()

        p = self.get_argument('p', 1)
        pagination = Topic.query.filter_by(node_id=node.id)\
                .order_by('-impact').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('node.html', node=node, pagination=pagination)
Ejemplo n.º 6
0
    def get(self, username):
        user = Member.query.filter_by(username=username).first_or_404()

        q = Topic.query.filter_by(user_id=user.id)
        topics = get_full_topics(q.order_by('-id')[:10])

        #: user's faved topics {{{
        #: TODO cache
        votes = Vote.query.filter_by(user_id=user.id, type='up')\
                .values('topic_id')
        topic_ids = (v[0] for v in votes)
        q = Topic.query.filter_by(id__in=topic_ids)
        likes = get_full_topics(q.order_by('-id')[:10])
        #: }}}

        replies = Reply.query.filter_by(user_id=user.id).order_by('-id')[:20]
        self.render('member.html', topics=topics, likes=likes, user=user,
                    replies=replies)
Ejemplo n.º 7
0
    def get(self, slug):
        node = Node.query.filter_by(slug=slug).first_or_404()

        p = self.get_argument('p', 1)
        pagination = Topic.query.filter_by(node_id=node.id)\
                .order_by('-impact').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('node.html', node=node, pagination=pagination)
Ejemplo n.º 8
0
 def get(self):
     self.set_header('Content-Type', 'text/xml; charset=utf-8')
     html = cache.get('sitefeed')
     if html is not None:
         self.write(html)
         return
     topics = get_full_topics(Topic.query.order_by('-id')[:20])
     html = self.render_string('feed.xml', topics=topics)
     cache.set('sitefeed', html, 1800)
     self.write(html)
Ejemplo n.º 9
0
 def get(self):
     self.set_header('Content-Type', 'text/xml; charset=utf-8')
     html = cache.get('sitefeed')
     if html is not None:
         self.write(html)
         return
     topics = get_full_topics(Topic.query.order_by('-id')[:20])
     html = self.render_string('feed.xml', topics=topics)
     cache.set('sitefeed', html, 1800)
     self.write(html)
Ejemplo n.º 10
0
    def get(self, username):
        user = Member.query.filter_by(username=username).first_or_404()

        q = Topic.query.filter_by(user_id=user.id)
        topics = get_full_topics(q.order_by('-id')[:10])

        #: user's faved topics {{{
        #: TODO cache
        votes = Vote.query.filter_by(user_id=user.id, type='up')\
                .values('topic_id')
        topic_ids = (v[0] for v in votes)
        q = Topic.query.filter_by(id__in=topic_ids)
        likes = get_full_topics(q.order_by('-id')[:10])
        #: }}}

        replies = Reply.query.filter_by(user_id=user.id).order_by('-id')[:20]
        self.render('member.html',
                    topics=topics,
                    likes=likes,
                    user=user,
                    replies=replies)
Ejemplo n.º 11
0
    def get(self):
        title = 'Following'

        user_id = self.current_user.id
        fs = FollowNode.query.filter_by(user_id=user_id).values('node_id')
        node_ids = (f[0] for f in fs)

        p = self.get_argument('p', 1)
        pagination = Topic.query.filter_by(node_id__in=node_ids)\
                .order_by('-last_reply_time').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('topic_list.html', title=title, pagination=pagination)
Ejemplo n.º 12
0
    def get(self):
        title = 'Following'

        user_id = self.current_user.id
        fs = FollowNode.query.filter_by(user_id=user_id).values('node_id')
        node_ids = (f[0] for f in fs)

        p = self.get_argument('p', 1)
        pagination = Topic.query.filter_by(node_id__in=node_ids)\
                .order_by('-last_reply_time').paginate(p, 30)

        pagination.items = get_full_topics(pagination.items)
        self.render('topic_list.html', title=title, pagination=pagination)
Ejemplo n.º 13
0
    def get(self, slug):
        node = Node.query.get_first(slug=slug)
        if not node:
            self.send_error(404)
            return

        self.set_header('Content-Type', 'text/xml; charset=utf-8')
        key = 'nodefeed:%s' % str(slug)
        html = cache.get(key)
        if html is not None:
            self.write(html)
            return

        topics = Topic.query.filter_by(node_id=node.id)[:20]
        topics = get_full_topics(topics)
        html = self.render_string('node_feed.xml', topics=topics, node=node)
        cache.set(key, html, 1800)
        self.write(html)
Ejemplo n.º 14
0
    def get(self, slug):
        node = Node.query.get_first(slug=slug)
        if not node:
            self.send_error(404)
            return

        self.set_header('Content-Type', 'text/xml; charset=utf-8')
        key = 'nodefeed:%s' % str(slug)
        html = cache.get(key)
        if html is not None:
            self.write(html)
            return

        topics = Topic.query.filter_by(node_id=node.id)[:20]
        topics = get_full_topics(topics)
        html = self.render_string('node_feed.xml', topics=topics, node=node)
        cache.set(key, html, 1800)
        self.write(html)