示例#1
0
def index():
	article_qry=cms.Article.query().order(-cms.Article.created)
	pager = Pager(query=article_qry, page=util.param('page') or 1)
	article_dbs, _, _ = pager.paginate(page_size=PAGESIZE)
	return flask.render_template(
		theme_file('index.html'),
		cates=cate_list(),
		data=article_dbs,
		pager=pager)
示例#2
0
def category(category):
	cate_dbs = [c for c in cms.Category.allcates() if c.name.lower() == category.lower()]
	if cate_dbs:
		cate_db = cate_dbs[0]
		article_qry = cms.Article.query(cms.Article.category==cate_db.key).order(-cms.Article.created)
		pager = Pager(query=article_qry, page=util.param('page') or 1)
		article_dbs, _, _ = pager.paginate(page_size=PAGESIZE)
	else:
		pager, article_dbs, cate_db = None, None, None
	return flask.render_template(
		theme_file('index.html'),
		obj=cate_db,
		cates=cate_list(),
		data=article_dbs,
		pager=pager)
示例#3
0
def tag(tag):
	tag_dbs = [t for t in cms.Tag.alltags() if t.name.lower() == tag.lower()]
	if tag_dbs:
		tag_db = tag_dbs[0]
		article_qry = cms.Article.query(cms.Article.tags==tag).order(-cms.Article.created)
		pager = Pager(query=article_qry, page=util.param('page') or 1)
		article_dbs, _, _ = pager.paginate(page_size=PAGESIZE)
	else:
		pager, article_db, tag_db = None, [], None
	return flask.render_template(
		theme_file('index.html'),
		obj=tag_db,
		cates=cate_list(),
		data=article_dbs,
		pager=pager)