def message(username): """ 显示个人消息 """ query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, messages_list = MessageService( ).getlist_by_receiver_id(user.id, page, sort, order) current_entry_type = 'message' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, messages_list=messages_list, record_total=record_total, page_total=page_total, current_page=page, page_url='/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def message(username): """ 显示个人消息 """ query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, messages_list = MessageService().getlist_by_receiver_id(user.id, page, sort, order) current_entry_type = 'message' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, messages_list=messages_list, record_total=record_total, page_total=page_total, current_page=page, page_url = '/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, comments_list = CommentService.getlist_by_author_id(user.id, page, sort, order) # for comment in comments_list: # entry = EntryService.get_by_id(comment.entry_id) # comment.entry_title = entry.title # # http://127.0.0.1:5000/article/5.html#comment-90 # comment.entry_url = url_for('portal.entry', slug=entry.slug)+ "#comment-%d" % comment.id current_entry_type = 'comment' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=comments_list, record_total=record_total, page_total=page_total, current_page=page, page_url = '/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def entry(slug): """ 文章显示 @param slug: @return: """ slug = '/%s' % slug entry = Entry.query.filter_by(slug=slug).first() if entry is None: abort(404) # todo g.user.is_supervisor if entry.entry_status != EntryStatus.published: if g.user and not g.user.is_supervisor: return render_template('common/entry_pending.html') if entry.category.show_role: if not g.user or entry.category.show_role > g.user.role: abort(404) query, sort, order, page = query_condition() return render_show(entry, sort, order, page)
def get_people_entries(people_id, page, entry_type): """ 渲染内容列表页 :param people_id: :param page: :param entry_type: :return: """ # 内容类型检查 if entry_type is not None: check_entry_type(entry_type) int_value_verify(people_id) int_value_verify(page) query, sort, order, page = query_condition() tag = None entries_total, page_total, entries_list = EntryService.get_page_by_user( people_id, tag, entry_type, query, sort, order, page) return dict( entries_list=entries_list, record_total=entries_total, page_total=page_total, )
def favorites_comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) _total, _pages, _list = CommentService.getlist_by_author_id(user.id, page) current_entry_type = 'comment' return render_template("favorites/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=_list, record_total=_total, page_total=_pages, current_page=page, page_url='/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def get_people_entries(people_id, page, entry_type): """ 渲染内容列表页 :param people_id: :param page: :param entry_type: :return: """ # 内容类型检查 if entry_type is not None: check_entry_type(entry_type) int_value_verify(people_id) int_value_verify(page) query, sort, order, page = query_condition() tag = None entries_total, page_total, entries_list = EntryService.get_page_by_user(people_id, tag, entry_type, query, sort, order, page) return dict( entries_list=entries_list, record_total=entries_total, page_total=page_total, )
def entrytype(type): #用于显示所有文章类型的内容 if type is None: abort(404) if type >= 17: abort(404) template_list = [ 'article_list.html', 'news_list.html', 'code_list.html', 'software_list.html', 'forum_list.html', 'question_list.html', 'tips_list.html', 'gallery_list.html', 'video_list.html', 'audio_list.html', 'link_list.html', 'quote_list.html', 'status_list.html', 'document_list.html', 'chat_list.html', 'aside_list.html', 'special_list.html', 'list.html' ] query, sort, order, page = query_condition() if sort == 'id': sort = 'updated_time' entries_total, page_total, entries_list = EntryService.get_page_by_entryType( sort, order, page, type) return render_template("entrytype/%s" % template_list[type], type=type, record_total=entries_total, page_total=page_total, current_page=page, entries_list=entries_list)
def entrytype(type): #用于显示所有文章类型的内容 if type is None: abort(404) if type >= 17: abort(404) template_list = ['article_list.html', 'news_list.html', 'code_list.html', 'software_list.html', 'forum_list.html', 'question_list.html', 'tips_list.html', 'gallery_list.html', 'video_list.html', 'audio_list.html', 'link_list.html', 'quote_list.html', 'status_list.html', 'document_list.html', 'chat_list.html', 'aside_list.html', 'special_list.html', 'list.html'] query, sort, order, page = query_condition() if sort == 'id': sort = 'updated_time' entries_total, page_total, entries_list = EntryService.get_page_by_entryType(sort, order, page, type) return render_template("entrytype/%s" % template_list[type], type=type, record_total=entries_total, page_total=page_total, current_page=page, entries_list=entries_list)
def comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) record_total, page_total, comments_list = CommentService.getlist_by_author_id( user.id, page, sort, order) # for comment in comments_list: # entry = EntryService.get_by_id(comment.entry_id) # comment.entry_title = entry.title # # http://127.0.0.1:5000/article/5.html#comment-90 # comment.entry_url = url_for('portal.entry', slug=entry.slug)+ "#comment-%d" % comment.id current_entry_type = 'comment' return render_template("people/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=comments_list, record_total=record_total, page_total=page_total, current_page=page, page_url='/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def index(): """ 门户首页 :return: 渲染后的html数据 """ # Googlebot # Baiduspider # Sosospider # Sogou web spider user_Agent = request.headers['User-Agent'] ''.find('MSIE') print user_Agent # 'accept_charsets', # 'accept_encodings', # 'accept_languages', # 'accept_mimetypes', # 'access_route', # 'application', # 'args', # 'authorization', # 'base_url', # 'blueprint', # 'cache_control', # 'charset', # 'content_length', # 'content_type', # 'cookies', # 'data', # 'date', # 'dict_storage_class', # 'encoding_errors', # 'endpoint', # 'environ', # 'files', # 'form', # 'form_data_parser_class', # 'from_values', # 'headers', # 'host', # 'host_url', # 'if_match', # 'if_modified_since', # 'if_none_match', # 'if_range', # 'if_unmodified_since', # 'input_stream', # 'is_multiprocess', # 'is_multithread', # 'is_run_once', # 'is_secure', 'is_xhr', 'json', 'list_storage_class', 'make_form_data_parser', 'max_content_length', 'max_form_memory_size', 'max_forwards', 'method', 'mimetype', 'mimetype_params', 'module', 'on_json_loading_failed', 'parameter_storage_class', 'path', 'pragma', 'query_string', 'range', 'referrer', 'remote_addr', 'remote_user', 'routing_exception', 'scheme', 'script_root', 'shallow', 'stream', 'url', 'url_charset', 'url_root', 'url_rule', 'user_agent', 'values', 'view_args', 'want_form_data_parsed'] query, sort, order, page = query_condition() return render_template( "portal/home.html", current_page=page, )
def index(): """ 门户首页 :return: 渲染后的html数据 """ # Googlebot # Baiduspider # Sosospider # Sogou web spider user_Agent = request.headers['User-Agent'] ''.find('MSIE') print user_Agent # 'accept_charsets', # 'accept_encodings', # 'accept_languages', # 'accept_mimetypes', # 'access_route', # 'application', # 'args', # 'authorization', # 'base_url', # 'blueprint', # 'cache_control', # 'charset', # 'content_length', # 'content_type', # 'cookies', # 'data', # 'date', # 'dict_storage_class', # 'encoding_errors', # 'endpoint', # 'environ', # 'files', # 'form', # 'form_data_parser_class', # 'from_values', # 'headers', # 'host', # 'host_url', # 'if_match', # 'if_modified_since', # 'if_none_match', # 'if_range', # 'if_unmodified_since', # 'input_stream', # 'is_multiprocess', # 'is_multithread', # 'is_run_once', # 'is_secure', 'is_xhr', 'json', 'list_storage_class', 'make_form_data_parser', 'max_content_length', 'max_form_memory_size', 'max_forwards', 'method', 'mimetype', 'mimetype_params', 'module', 'on_json_loading_failed', 'parameter_storage_class', 'path', 'pragma', 'query_string', 'range', 'referrer', 'remote_addr', 'remote_user', 'routing_exception', 'scheme', 'script_root', 'shallow', 'stream', 'url', 'url_charset', 'url_root', 'url_rule', 'user_agent', 'values', 'view_args', 'want_form_data_parsed'] query, sort, order, page = query_condition() return render_template("portal/home.html", current_page=page, )
def tag(category, tag): #tagged/android+activity+-android-asynctask slug = '/%s' % category category = Category.query.filter_by(slug=slug).first() if category is None: abort(404) tag = TagService.get_by_slug(tag) query, sort, order, page = query_condition() if sort == 'id': sort = 'updated_time' return rander_category(category, tag, query, sort, order, page)
def json(page=1): """ 显示 notice 列表 """ int_value_verify(page) query, sort, order, page = query_condition() # todo # query['notice_status'] = 1 notice_list = [] # NoticeService.get_page(query, _fields, page, PER_PAGE, sort, order) count = 0 # notice_srv.count(query) page_total = int(ceil(count / float(PER_PAGE))) return jsonify(notice_list=notice_list, page_total=page_total, current_page=page)
def tagged(slug, page=1): # todo tag = TagService.get_by_slug(slug) if not tag: abort(404) query, sort, order, page = query_condition() entries_total, page_total, entries_list = EntryService.get_page_by_tag( tag, query, sort, order, page) return render_template( "common/tag_entries_list.html", entries_list=entries_list, current_tag=tag, record_total=entries_total, page_total=page_total, current_page=page, )
def category(category, entry_type): """ 分类/栏目入口 @param category: @return: """ slug = '/%s' % category category = Category.query.filter_by(slug=slug).first() if category is None: abort(404) query, sort, order, page = query_condition() if sort == 'id': sort = 'updated_time' return rander_category(category, None, query, sort, order, page, entry_type)
def tagged(slug, page=1): # todo tag = TagService.get_by_slug(slug) if not tag: abort(404) query, sort, order, page = query_condition() entries_total, page_total, entries_list = EntryService.get_page_by_tag(tag, query, sort, order, page) return render_template("common/tag_entries_list.html", entries_list=entries_list, current_tag = tag, record_total=entries_total, page_total=page_total, current_page=page, )
def get_people_favorites(people_id, entry_type): """ 渲染内容列表页 :param people_id: :param entry_type: :return: """ # 内容类型检查 if entry_type is not None: check_entry_type(entry_type) int_value_verify(people_id) query, sort, order, page = query_condition() _total, _pages, _list = FavoritesService.get_favorites(people_id, entry_type, page, PER_PAGE) return dict( favorites_list=_list, record_total=_total, page_total=_pages, )
def get_people_favorites(people_id, entry_type): """ 渲染内容列表页 :param people_id: :param entry_type: :return: """ # 内容类型检查 if entry_type is not None: check_entry_type(entry_type) int_value_verify(people_id) query, sort, order, page = query_condition() _total, _pages, _list = FavoritesService.get_favorites( people_id, entry_type, page, PER_PAGE) return dict( favorites_list=_list, record_total=_total, page_total=_pages, )
def favorites_comment(username): query, sort, order, page = query_condition() user = UserService.get_by_username(username) if not user: abort(404) statistic = EntryService.get_statistic_by_author_id(user.id) _total, _pages, _list = CommentService.getlist_by_author_id(user.id, page) current_entry_type = 'comment' return render_template("favorites/%s.html" % current_entry_type, current_entry_type=current_entry_type, comments_list=_list, record_total=_total, page_total=_pages, current_page=page, page_url = '/%s/%s/%s/index' % (URL_BASE, username, current_entry_type), statistic=statistic, notices=NoticeService.get_list_for_show(), people=user)
def favorites_index(username): query, sort, order, page = query_condition() return render_favorites_entry(username, page)
def question(username): query, sort, order, page = query_condition() return render_entry(username, page, EntryType.question)
def favorites_forum(username): query, sort, order, page = query_condition() return render_favorites_entry(username, page, EntryType.forum)
def article(username): query, sort, order, page = query_condition() return render_entry(username, page, EntryType.article)
def index(username): query, sort, order, page = query_condition() return render_entry(username, page)