Пример #1
0
 def get(self, nodeid):
     n_obj = Node.get_by_id(int(nodeid))
     if not n_obj:
         self.error(404)
         self.echo('error.html', {
             'page': '404',
             'title': "Can't find out this URL",
             'h2': 'Oh, my god!',
             'msg': 'Something seems to be lost...'
         })
         return
     
     from_id = int(self.request.get('id', '0'))
     if from_id<=0 and n_obj.count:
         from_id = n_obj.count
     
     to_id = from_id - EACH_PAGE_POST_NUM
     if to_id<0:
         to_id = 0
     
     newest_node = Node.get_newest()
     self.echo('nodedetail.html', {
         'title': n_obj.name,
         'n_obj': n_obj,
         'from_id': from_id,
         'to_id': to_id,
         'topic_objs': Node.get_page_topic(nodeid, from_id, to_id),
         'newest_node': newest_node,
         'recent_node': Node.get_recent_node(),
         'hot_node': Node.get_hot_node(),
         'recent_topic_objs': KeyStrValue.get_topic_key_title('recent-topic-home'),
         'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),            
     }, layout='_layout.html')
     if len(newest_node)==10:
         KeyStrValue.add_node_key(nodeid)
Пример #2
0
 def get(self, name):
     name = name.lower()
     m_obj = Member.get_by_key_name(name)
     if m_obj:
         self.echo(
             'member.html',
             {
                 'title':
                 m_obj.name,
                 'm_obj':
                 m_obj,
                 'mi_obj':
                 MemberInfo.get_by_key_name(name),
                 'newest_node':
                 Node.get_newest(),
                 #'recent_node': Node.get_recent_node(),
                 'hot_node':
                 Node.get_hot_node(),
                 'recent_topic_objs':
                 KeyStrValue.get_topic_key_title('recent-topic-home'),
                 'reply_topic_objs':
                 KeyStrValue.get_topic_key_title('recent-reply-topic'),
             },
             layout='_layout.html')
     else:
         self.error(404)
         self.echo(
             'error.html', {
                 'page': '404',
                 'title': "Can't find out this URL",
                 'h2': 'Oh, my god!',
                 'msg': 'Something seems to be lost...'
             })
         return
Пример #3
0
    def get(self, nodeid, topicid):
        topic_key = '%s-%s' % (nodeid, topicid)
        t_obj = Topic.get_by_key_name(topic_key)
        if not t_obj:
            self.error(404)
            self.echo(
                'error.html', {
                    'page': '404',
                    'title': "Can't find out this URL",
                    'h2': 'Oh, my god!',
                    'msg': 'Something seems to be lost...'
                })
            return

        if t_obj.cnum:
            from_id = int(self.request.get('id', '1'))
            if from_id > 1 and from_id % EACH_PAGE_COMMENT_NUM != 1:
                self.redirect('/t-' + topic_key)
                return
            to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
            if to_id > t_obj.cnum:
                to_id = t_obj.cnum
            c_objs = Comment.get_comments(topic_key, from_id, to_id)
        else:
            c_objs = None
            from_id = to_id = cnum = 0

        self.echo(
            'topicdetail.html',
            {
                'title':
                t_obj.title + ' - ' + t_obj.node.name,
                'description':
                'description',
                't_obj':
                t_obj,
                'c_objs':
                c_objs,
                'from_id':
                from_id,
                'to_id':
                to_id,
                'newest_node':
                Node.get_newest(),
                #'recent_node': Node.get_recent_node(),
                'hot_node':
                Node.get_hot_node(),
                'recent_topic_objs':
                KeyStrValue.get_topic_key_title('recent-topic-home'),
                'reply_topic_objs':
                KeyStrValue.get_topic_key_title('recent-reply-topic'),
            },
            layout='_layout.html')
Пример #4
0
 def get(self):
     if self.cur_user:
         self.echo('notifications.html', {
             'title': "站内提醒",
             'newest_node': Node.get_newest(),
             'recent_node': Node.get_recent_node(),
             'hot_node': Node.get_hot_node(),
             'recent_topic_objs': KeyStrValue.get_topic_key_title('recent-topic-home'),
             'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),            
         }, layout='_layout.html')
         
     else:
         self.redirect('/')
Пример #5
0
 def get(self):
     self.echo('home.html', {
         'title': "首页",
         'topic_objs': KeyStrValue.get_topic_objs('recent-topic-home'),
         'site_counts': Counter.get_site_counts(),
         'newest_node': Node.get_newest(),
         'recent_node': Node.get_recent_node(),
         'hot_node': Node.get_hot_node(),
         'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),
     }, layout='_layout.html')
Пример #6
0
 def get(self, nodeid, topicid):
     topic_key = '%s-%s' % (nodeid, topicid)
     t_obj = Topic.get_by_key_name(topic_key)
     if not t_obj:
         self.error(404)
         self.echo('error.html', {
             'page': '404',
             'title': "Can't find out this URL",
             'h2': 'Oh, my god!',
             'msg': 'Something seems to be lost...'
         })
         return
     
     if t_obj.cnum:
         from_id = int(self.request.get('id', '1'))
         if from_id>1 and from_id%EACH_PAGE_COMMENT_NUM!=1:
             self.redirect('/t-'+topic_key)
             return
         to_id = from_id + EACH_PAGE_COMMENT_NUM - 1
         if to_id > t_obj.cnum:
             to_id = t_obj.cnum
         c_objs = Comment.get_comments(topic_key, from_id, to_id)
     else:
         c_objs = None
         from_id = to_id = cnum = 0
     
     self.echo('topicdetail.html', {
         'title': t_obj.title + ' - ' + t_obj.node.name,
         'description':'description',
         't_obj': t_obj,
         'c_objs': c_objs,
         'from_id': from_id,
         'to_id': to_id,
         'newest_node': Node.get_newest(),
         'recent_node': Node.get_recent_node(),
         'hot_node': Node.get_hot_node(),
         'recent_topic_objs': KeyStrValue.get_topic_key_title('recent-topic-home'),
         'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),
     }, layout='_layout.html')
Пример #7
0
 def get(self, name):
     name = name.lower()
     m_obj = Member.get_by_key_name(name)
     if m_obj:
         self.echo('member.html', {
             'title': m_obj.name,
             'm_obj': m_obj,
             'mi_obj': MemberInfo.get_by_key_name(name),
             'newest_node': Node.get_newest(),
             'recent_node': Node.get_recent_node(),
             'hot_node': Node.get_hot_node(),
             'recent_topic_objs': KeyStrValue.get_topic_key_title('recent-topic-home'),
             'reply_topic_objs': KeyStrValue.get_topic_key_title('recent-reply-topic'),            
         }, layout='_layout.html')
     else:
         self.error(404)
         self.echo('error.html', {
             'page': '404',
             'title': "Can't find out this URL",
             'h2': 'Oh, my god!',
             'msg': 'Something seems to be lost...'
         })
         return