def get_article_list(): offset = request.form.get('offset') limit = request.form.get('limit') article_list = article_server.get_list(offset, limit, current_user) sum = article_server.get_count(current_user) return jsonify(article_list=[get_article_list_item(article) for article in article_list], sum=sum, offset=int(offset), limit=len(article_list))
def article_list(page=0): limit = config.ARTICLE_PER_PAGE query_type = request.args.get('query_type') keyword = request.args.get('keyword') keyword = keyword if keyword else '' sum = article_server.get_count(query_type=query_type, keyword = keyword) try : offset = int(page) * limit tags = article_server.get_all_tags() articles = article_server.get_list(offset, limit, query_type=query_type, keyword = keyword) recent_articles = article_server.get_recent() return render_template('index/article_list.html', title = u'解题报告', articles = articles, tags = tags, recent_articles = recent_articles, page = int(page), sum = sum, limit = limit, query_type = query_type, keyword = keyword) except: return redirect(url_for("main.article_list"))