def blog_id(id): if request.method == 'POST': comment_content = request.form['comment_content'] comment_name = request.form['comment_name'] comment = Comment(id=next_id(), blog_id=id, user_id='guest', user_name=comment_name, user_image='', content=comment_content, created_at=time.time()) comment.save() image = common.create_avatar_by_name(comment_name) user = User(id=next_id(), email='', passwd='', admin=0, name=comment_name, image=image, created_at=time.time()) mylog.info(image) # TODO 先使用name来进行判定是否唯一,后期希望能够使用email来判断是否唯一 _user = User.find_all('name= ?', [comment_name]) if len(_user) == 0: user.save() flash('comment and new user had been saved successfully!') blog = Blog.find(id) md_text = highlight.parse2markdown(blog.content) blog.html_content = md_text comments = Comment.find_all('blog_id= ?', [id]) return render_template('blogdetail.html', blog=blog, comments=comments)
def welcome(): session['page_number'] = 1 blogs = Blog.find_all(orderBy='created_at desc', limit=(0, 8)) for blog in blogs: md = highlight.parse2markdown(blog.summary) blog.md_summary = md # 侧边栏的分类 blog_categories = Blog.find_all(groupby='category') blogs_categories = [] for category in blog_categories: blog_catrgory = Blog.find_all('category=?', [category.category]) blogs_categories.append(blog_catrgory) return render_template('welcome.html', blogs=blogs, blogs_categories=blogs_categories)
def welcome(): session['page_number'] = 1 blogs = Blog.find_all(orderBy='created_at desc', limit=(0, 8)) for blog in blogs: md = highlight.parse2markdown(blog.summary) blog.md_summary = md # 侧边栏的分类 blog_categories = Blog.find_all(groupby='category') blogs_categories = [] for category in blog_categories: blog_catrgory = Blog.find_all('category=?', [category.category]) blogs_categories.append(blog_catrgory) return render_template('welcome.html', blogs=blogs, blogs_categories=blogs_categories)
def blog_id(id): if request.method == 'POST': comment_content = request.form['comment_content'] comment_name = request.form['comment_name'] comment = Comment(id=next_id(), blog_id=id, user_id='guest', user_name=comment_name, user_image='', content=comment_content, created_at=time.time()) comment.save() image = common.create_avatar_by_name(comment_name) user = User(id=next_id(), email='', passwd='', admin=0, name=comment_name, image=image, created_at=time.time()) mylog.info(image) # TODO 先使用name来进行判定是否唯一,后期希望能够使用email来判断是否唯一 _user = User.find_all('name= ?', [comment_name]) if len(_user) == 0: user.save() flash('comment and new user had been saved successfully!') blog = Blog.find(id) md_text = highlight.parse2markdown(blog.content) blog.html_content = md_text comments = Comment.find_all('blog_id= ?', [id]) return render_template('blogdetail.html', blog=blog, comments=comments)