Exemplo n.º 1
0
	def get(self,page=1):
		search_query = request.args.get('q')
		if search_query:
			posts = Post.search(search_query)
			max_page = PostIndex.max_post_page_public(search_query)
		else:
			max_page = Post.max_post_page_public()
			posts = Post.public().order_by(Post.timestamp.desc()).paginate(page,POST_PER_PAGE)
		return render_template('posts/list.html', posts=posts, page=page, max_page= max_page)
Exemplo n.º 2
0
def search():
    title_text = request.query.get('query', '')
    posts = Post.search(title_text)
    return json.dumps([p.serialize() for p in posts])