疆飞
.NET永远年轻,永远热泪盈眶...
HashOver评论系统,弃坑畅言,致敬多说!
首先说一下多说,多说的关闭其实影响了不少站长,非常感谢多说多年来免费为站长朋友们带来的支持,自从多说关闭后,很多社会化评论运营商也纷纷宣布关闭其评论产品,目前国内仅剩畅言一家了。在多说关闭后,急于寻找多说替代品,所以我选择了畅言,当时将多说评论数据导出,导入了畅言,虽然相比来说畅言不如多说好用,但是也别无他法,也没时间去找更多的替代方案。
随着社会评论系统的低迷走势和现在仅剩畅言一家的情况出现,所以畅言也开启了收费模式,当然也不能叫收费模式,是会员制。免费版依旧可以了使用,但是不得不接受畅言推送的广告,目前发现畅言不仅推送了banner广告,还出现了弹窗广告。虽然可以使用css和js屏蔽掉,但是心里还是有一些不爽。直到发现了 有一款评论系统叫 HashOver。
HashOver 于多说和畅言不同的地方在于它是要放在你自己的服务器内。完全实现了自主化,这个应该叫自主化吧,不管了,我先这样理解。反正这是我遇到的最好用的评论系统。它是由 jacobwb发布在 github 上的开源项目,目前版本为2.0,共有两个分支
原版
HashOver 1.0.1
https://github.com/jacobwb/hashover (原版1.0)
分支版本
HashOver 2.0 (development)
https://github.com/jacobwb/hashover-next (原作者分支版本,我目前使用的版本,作者一直在持续更新)
https://github.com/AndreaCatania/hashover-next (AndreaCatania 的 分支版本 最近一次更新是2016年)
https://gitee.com/jiangfei1006/hashover (国内开源项目平台,我从原作者哪里版过来的)
关于各个版本细节,大家可以自己到 github.com 上去参考一下,这里就不多做介绍了,如果你现在还保存有之前多说的数据的话,那么你可以下载一个转换程序,将多说数据直接转换为 HashOver 数据。转换程序由国人开发,项目地址:https://github.com/JJYing/Duoshuo-to-Hashover 作者:图月志 JJYing (如果能开发一个畅言转换HashOver就更好了! )
本站现在使用的就是 HashOver 评论系统,好了,下面来介绍一下 HashOver 的安装与使用。
1、先到上面的链接下载 HashOver,解压,将 hashover 目录上传到你网站目录。
2、在你的前端模版内容加入
<script type="text/javascript" src="/hashover/loader.php"></script>
<!--请留意你的上传路径-->
3、在评论位置加入
<div id="hashover">
<center id="loading">
<img src="./hashover/images/loading-ltr.gif" alt="Loading..." width="90" height="30">
</center>
</div>
其他说明:
<center id="loading">
<img src="./hashover/images/loading-ltr.gif" alt="Loading..." width="90" height="30">
</center>
这部分是加载提示,你可以直接删除,或者自己制作一个gif 替换。
但是 <div id="hashover"></div> 必须有
4、打开 hashover/backend/classes/secrets.php 进行配置
class Secrets
{
// REQUIRED SETUP INFORMATION
// E-mail for notification of new comments
protected $notificationEmail = 'example@example.com'; //设置接收评论提醒的邮箱
// Unique encryption key (case-sensitive)
protected $encryptionKey = '8CharKey'; //设置一个key 必须修改
// Login name to gain admin rights (case-sensitive)
protected $adminName = 'admin'; //设置你评论管理的用户名
// Login password to gain admin rights (case-sensitive)
protected $adminPassword = 'passwd'; //设置你评论管理的密码
// OPTIONAL SQL INFORMATION
// Type of database, sqlite or mysql
protected $databaseType = 'sqlite'; //设置你评论系统的数据库类型(可以不改)
// Database name
protected $databaseName = 'hashover-threads'; //设置为mysql后的数据库名
// SQL database host name
protected $databaseHost = 'localhost'; //设置为mysql后的数据地址
// SQL database login user
protected $databaseUser = 'root'; //设置为mysql后的数据库用户名
// SQL database login password
protected $databasePassword = 'password'; //设置为mysql后的数据库密码
// SQL database character set
protected $databaseCharset = 'utf8'; //这个还需要在解释一下的话,你就不适合做站长
// OPTIONAL SMTP MAILER SETUP
// SMTP server host name //以下是邮件设置,默认使用sendmail发送邮件,当你设置为smtp发送时下面的设置才会生效,当然,你可以在后台设置发送邮件的方式。
protected $smtpHost = 'smtp.gmail.com'; //SMTP地址
// SMTP server port number //SMTP端口
protected $smtpPort = 465;
// SMTP server encryption method
protected $smtpCrypto = 'ssl'; //SMTP加密
// SMTP server requires login authentication
protected $smtpAuth = true;
// SMTP server user
protected $smtpUser = 'user'; //SMTP用户名
// SMTP server password
protected $smtpPassword = 'password'; //SMTP密码
}
完成上面的设置你的 HashOver 就已经可以用了。设置的话你可以访问 /hashover/admin ,用你刚刚设置的用户名和密码登陆,登陆后在设置中,可以将语言设置为简体中文。然后评论系统的设置也都在这里面。
这个时候你可能发现了评论框上面有 名称、密码、邮件、网址 四个字段,通常密码字段是不需要的。这里后台无法关闭和控制这些。这个时候你需要打开 hashover/backend/classes/settings.php文件来进行设置。
class SafeSettings
{
// Primary settings
public $language = 'auto'; // UI language, for example 'en', 'de', etc. 'auto' to use system locale
public $theme = 'default'; // Comment Cascading Style Sheet (CSS)
public $allowsImages = true; // Whether external image URLs wrapped in [img] tags are embedded
public $allowsLikes = true; // Whether a "Like" link is displayed
public $allowsDislikes = false; // Whether a "Dislike" link is displayed; allowing Reddit-style voting
public $usesAjax = true; // Whether AJAX is used for posting, editing, and loading comments
public $collapsesInterface = false; // Whether the comment form, thread, and end links are all initially hidden
public $collapsesComments = true; // Whether to hide comments and display a link to show them
public $collapseLimit = 3; // Number of comments that aren't hidden
public $replyMode = 'thread'; // Whether to display replies as a 'thread' or as a 'stream'
public $streamDepth = 3; // In stream mode, the number of reply indentions to allow before the thread flattens
public $popularityThreshold = 5; // Minimum likes a comment needs to be popular
public $popularityLimit = 2; // Number of comments allowed to become popular
public $usesMarkdown = true; // Whether comments will be parsed for Markdown
// Date and Time settings
public $serverTimezone = 'America/Los_Angeles'; // Server timezone
public $usesUserTimezone = true; // Whether comment dates should use the user's timezone (JavaScript-mode)
public $usesShortDates = true; // Whether comment dates are shortened, for example "X days ago"
public $timeFormat = 'g:ia'; // Time format, use 'H:i' for 24-hour format (see: http://php.net/manual/en/function.date.php)
public $dateFormat = 'm/d/Y'; // Date format (see: http://php.net/manual/en/function.date.php)
// Field options, use true/false to enable/disable a field,
// use 'required' to require a field be properly filled
public $fieldOptions = array (
'name' => true, #是否显示名称字段 true为显示 false为不显示
'password' => true, #是否显示密码字段 true为显示 false为不显示
'email' => true, #是否显示邮箱字段 true为显示 false为不显示
'website' => true #是否显示网址字段 true为显示 false为不显示
);
// Behavior settings
public $displaysTitle = true; // Whether page title is shown or not
public $formPosition = 'top'; // Position for primary form; options: 'top' or 'bottom'
public $showsReplyCount = true; // Whether to show reply count separately from total
public $countIncludesDeleted = true; // Whether comment counts should include deleted comments
public $iconMode = 'image'; // How to display avatar icons (either 'image', 'count' or 'none')
public $iconSize = 45; // Size of Gravatar icons in pixels
public $imageFormat = 'png'; // Format for icons and other images (use 'svg' for HDPI)
public $usesLabels = false; // Whether to display labels above inputs
public $usesCancelButtons = true; // Whether forms have "Cancel" buttons
public $appendsCss = true; // Whether to automatically add a CSS <link> element to the page <head>
public $appendsRss = true; // Whether a comment RSS feed link is displayed
// Technical settings
public $subscribesUser = true; // Whether to subscribe the user to e-mail notifications by default
public $allowsUserReplies = false; // Whether given e-mails are sent as reply-to address to users
public $gravatarDefault = 'custom'; // Gravatar theme to use ('custom', 'identicon', 'monsterid', 'wavatar', or 'retro')
public $gravatarForce = false; // Whether to force the themed Gravatar images instead of an avatar image
public $minifiesJavascript = false; // Whether JavaScript output should be minified
public $minifyLevel = 4; // How much to minify JavaScript code, options: 1, 2, 3, 4
}
如果你的评论跟网站不在同一台服务器的话,还需要设置一个授权域名,打开 hashover/backend/classes/sensitivesettings.php
class SensitiveSettings extends SafeSettings
{
// Primary settings
public $dataFormat = 'xml'; // Format comments will be stored in; options: xml, json, sql
public $defaultName = 'Anonymous'; // Default name to use when one isn't given
public $allowsLogin = true; // Whether users can login and logout (when false form cookies are still set)
public $usesModeration = false; // Whether comments must be approved before they appear to other visitors
public $pendsUserEdits = false; // Whether comments need to be approved again when edited
// E-mail settings
public $mailer = 'sendmail'; // How to send notification e-mails, either 'sendmail' or 'smtp'
public $mailType = 'text'; // What format to send e-mails in, either 'text' or 'html'
public $noreplyEmail = 'noreply@example.com'; // E-mail used when no e-mail is given
// Behavior settings
public $usesAutoLogin = true; // Whether a user's first comment automatically logs them in
// Technical settings
public $loginMethod = 'defaultLogin'; // Login method class for handling user login information
public $setsCookies = true; // Whether cookies are enabled
public $secureCookies = false; // Whether cookies set over secure HTTPS will only be transmitted over HTTPS
public $storesIpAddress = false; // Whether to store users' IP addresses
public $spamDatabase = 'remote'; // Whether to use a remote or local spam database
public $spamCheckModes = 'php'; // Perform IP spam check in 'json' or 'php' mode, or 'both'
public $enabledApi = array ('all'); // An array of enabled API. 'all' = fully-enabled, empty array = fully disabled
public $latestMax = 10; // Maximum number of comments to save as latest comments
public $latestTrimWidth = 100; // Number of characters to trim latest comments to, 0 for no trim
public $userDeletionsUnlink = false; // Whether user deleted files are actually unlinked from the filesystem
public $allowLocalMetadata = false; // Whether default metadata should be collected while running on a local server
// Types of images allowed to be embedded in comments
public $imageTypes = array (
'jpeg',
'jpg',
'png',
'gif'
);
// External domains allowed to remotely load HashOver scripts
public $allowedDomains = array (
'127.0.0.1:8000' //这里给出了修改案例,按照你的域名设置即可!
// '*.example.com',
// '*.example.org',
// '*.example.net'
);
}
除了我上面做了中文备注的地方需要修改以外呢其他的都不需要修改,后台设置即可。
5、以下是我使用的一点心得
修改时区 ,在后台设置中找到 “在用户的时区(JavaScript模式)中显示日期/时间” 选项,将后面的 “America/Los_Angeles” 修改为 “Asia/Shanghai” 这样时间就会按照 我们的 +8 时区来显示了!
不知道为什么,原作者这个2.0版本没有默认排序方式的设置,也就是说所有最新的评论是显示在下面的。这个问题已经反馈给作者了,作者表示会在后续的更新中加入这个排序修改机制,暂时呢只能用js来修改排序方式了。但是我用的方法很蠢很笨,如果你们有好的办法希望可以共享一下,我将感激不尽!
window.addEventListener('load',function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
},false);
window.onload = function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
}
$(window).load(function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
})
$(document).ready(function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
});
$(function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
});
function jiangfei() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
}
setTimeout(function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
},500);
setTimeout(function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
},1000);
setTimeout(function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
},1500);
setTimeout(function() {
$("#hashover-sort-select").val("threaded-by-date").change();
$("#hashover-end-links").remove();
},2000);
#为什么写成这样呢!!因为我用的是香港主机,加载有点慢,所以为了强制让他生效,我就执行了好多,其实你只要下面这句就行!
$("#hashover-sort-select").val("threaded-by-date").change(); #这句就是模拟点击排序为新评论优先显示而已。
$("#hashover-end-links").remove(); #这句厉害了,这句是删除下面的链接信息!
就写这么多吧,自己研究一下你就会用了!如果有什么问题可以留言探讨!
- QQ932557101
- emailmail@jiangfei.net
- weibo@疆飞 (@jiangfei1006)
- twitter@疆飞 (@jiangfei1006)
PS:没事不要瞎联系,除非你想请我吃饭...
Copyright © 2008-. JiangFei.net all rights reserved
苏公网安备32048202001026号苏ICP备18062911号