def article_detail_handler(request, article_id):
account = request.META["user_info"]
result = dict()
renderer = mistune.Renderer(hard_wrap=True, parse_inline_html=True)
markdown = mistune.Markdown(renderer=renderer)
article = BlogArticle.query_article_by_id(article_id)
article["content"] = markdown(article["content"])
article["comment_list"] = BlogComment.query_comment_list(article_id, account.id if account else 0)
result["article"] = article
if account:
article["meta_info"]["liked"] = 1 if BlogLike.query_like_blog(account.id, article_id) else 0
result["user_info"] = UserInfo.query_format_info_by_user_id(request.META["user_info"].id)
# ?????? ????????????????????
author_id = article["user_info"]["id"]
if not account or author_id != account.id:
BlogArticleMeta.change_meta_record(article_id, author_id, ["hit"])
# ????
BlogArticle.query_article_by_id(article_id, False)
return render(request, "article/detail.html", result)
评论列表
文章目录