hexo功能捣鼓里特意没有提到评论,就是为了自建评论系统.对,还是为了不被卡脖子,就不用第三方评论系统了第三方评论系统有disqus/gitalk/valine/waline/giscus
等等.
HashOver 不同的地方在于它是要放在你自己的服务器内。完全实现了自主可控.
部署hashover
hashover是一个基于php的服务端程序,我们需要找到一个开启了php服务的动态网站托管起来
去官网 下载安装文件
下载之后解压在托管网站下 网站地址/hashover
hashover/admin/view-setup.php:67行代码有错误,修改如下
$language = file_exists ('docs/' . $language) ? $language : 'en-us';
同时此服务器上需要使用宝塔面板,新建一个评论数据库,供后面使用
hashover配置
打开 hashover/backend/classes/secrets.php 修改以下配置
class Secrets { protected $notificationEmail = 'example@example.com' ; protected $encryptionKey = '8CharKey' ; protected $adminName = 'admin' ; protected $adminPassword = 'passwd' ; protected $databaseType = 'sql' ; protected $databaseName = 'hashover' ; protected $databaseHost = 'localhost' ; protected $databaseUser = 'root' ; protected $databasePassword = 'a;lsjdf;aisuralsjdf;lk' ; protected $databaseCharset = 'utf8' ; protected $smtpHost = 'smtp.gmail.com' ; protected $smtpPort = 465 ; protected $smtpCrypto = 'ssl' ; protected $smtpAuth = true ; protected $smtpUser = 'user' ; protected $smtpPassword = 'password' ; }
打开 hashover/backend/classes/safesettings.php
修改以下配置
class Secrets { public $language = 'zh-cn' ; public $passwordField = 'off' ; public $websiteField = 'off' ; }
打开 hashover/backend/classes/sensitivesettings.php
修改以下配置
class Secrets { public $dataFormat = 'sql' ; public $mailer = 'smtp' ; public $requiresLogin = false ; public $allowedDomains = array ( '托管网站' , '127.0.0.1' ); }
本地hexo配置
在themes\next\layout\_partials\comments.njk
第35行加上如下代码
<section class ="hashover " id ="comments "> <script type = "text /javascript ">(function () { var s = document.createElement ('script' ), t = document.getElementsByTagName ('script' )[0 ]; s.type = 'text/javascript' ; s.async = true ; s.src = "托管网站/hashover/comments.php" ; t.parentNode.insertBefore (s, t); })(); </script> <div id="hashover" ></div> </section>