在没有互联网的年代,我们用日记来记录每天的心得体会。小的时候我有一个带锁的日记本,生怕被别人看见里面写了啥,钥匙藏得那叫一个绝。现在时代变了,网络版的日记本:博客,却巴不得越多人看越好。别人看完你写的深度好文,难免也想高谈阔论一番,这就是“评论”功能。本章将要编写的评论模块,几乎没有新的知识点,而是将前面章节内容的综合应用。强烈建议读者自行尝试编写这部分内容,测试自己的知识掌握程度。准备工作...
对会读书的人来说,读一本书要做的第一件事,就是仔细阅读这本书的目录。阅读目录可以对整体内容有所了解,并清楚地知道感兴趣的部分在哪里,提高阅读质量。博文也是同样的,好的目录对博主和读者都很有帮助。更进一步的是,还可以在目录中设置锚点,点击标题就立即前往该处,非常的方便。文中的目录之前我们已经为博文支持了Markdown语法,现在继续增强其功能。有折腾代码高亮的痛苦经历之后,设置Markdown...
有了浏览量之后,文章受欢迎的程度就有了评价标准。随之而来的就有根据浏览量对文章进行排序的需求,即显示“最热文章”。现在你已经很熟悉MTV模式,不需要我啰嗦也能完成任务:文章的模型已经有了,不需要写Model了写一个视图函数article_list_by_views(),取出按浏览排序后的文章对象将文章对象传递到模板,并进行渲染很简单,但也隐藏着问题:最热文章列表和之前的普通文章列表相比,大部...
有了浏览量之后,文章受欢迎的程度就有了评价标准。随之而来的就有根据浏览量对文章进行排序的需求,即显示“最热文章”。现在你已经很熟悉MTV模式,不需要我啰嗦也能完成任务:文章的模型已经有了,不需要写Model了写一个视图函数article_list_by_views(),取出按浏览排序后的文章对象将文章对象传递到模板,并进行渲染很简单,但也隐藏着问题:最热文章列表和之前的普通文章列表相比,大部...
文章浏览量是所有社交类网站所必备的数据,足以显示其重要性了。博主可以通过浏览量来评估某篇文章的受欢迎程度,读者也能够通过浏览量来筛选质量更高的文章。然而,准确统计浏览量并不简单:某些类型的请求不应该统计为浏览量,比如作者自己的浏览或编辑文章之后的重定向请求;由于用户众多,浏览量的数据时刻都在快速更新,会给数据库带来很大的压力。因此很多大型网站都会使用如Redis这样的读写速度非常快的内存数据...