Extension:Comments(评论)
发行状态: 稳定版 |
|
|---|---|
| 实现 | 解析器扩展, 函数钩 |
| 描述 | <comments />解析器钩子标签,允许在條目上评论 |
| 作者 | |
| 最新版本 | 5.1 |
| MediaWiki | 1.43+ |
| 数据库更改 | 是 |
| 表 | Comments Comments_Vote Comments_block |
| 许可协议 | GNU通用公眾授權條款2.0或更新版本 |
| 下載 | |
|
|
<comments /> |
|
|
|
| 前往translatewiki.net翻譯Comments扩展 | |
| 問題 | 开启的任务 · 报告错误 |
评论扩展添加了<comments />解析器钩子标记,可评论有该标记存在的條目。
评论操作会记录在Special:Log/comments,但是默认情况下它们会像在巡查日志中一样隐藏。
你可以设置$wgCommentsInRecentChanges = true;以展示Special:RecentChanges中的评论日志项目(在2.8版本以上可用)。
大部份的代码修复工作已由Misza和Jack Phoenix完成。
安裝
- 下载文件,并解压
Comments文件夹到extensions/目录中。
开发者和代码贡献人员应改从Git安装此扩展,输入:cd extensions/ git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Comments
- 請新增下列代码到您的LocalSettings.php文件的底部:
wfLoadExtension( 'Comments' );
- 請运行更新脚本,它将自动创建此扩展所必须的数据库表。
完成 – 請导航至您的wiki上的Special:Version,以验证此扩展已成功安装。
用法
<comments />— 基本的评论格式,已足夠應付大多数的事情。<comments allow="Derfel,Jack Phoenix,Misza" />— 仅允许用户 Derfel、Jack Phoenix、以及Misza提交评论。<comments voting="Plus" />— 防止用户对评论进行负面评价(差評),只允许进行正面评价(好評)。
每日评论
该扩展还自带「每日评论」功能(<commentsoftheday />),默认情况下「未」启用。你可以在维基的LocalSettings.php中启用该功能,方法是在require_once行后添加以下内容:
require_once "$IP/extensions/Comments/CommentsOfTheDay.php";
如果将nocache参数传递给解析器钩子(比如:<commentsoftheday nocache=true />),解析器钩子将不会使用memcached,而是直接从数据库而不是缓存中获取数据。
如果你想显示最新数据,这很有用,但可能会非常耗费服务器资源。
用户权限
这个扩展添加下列新的用户权限:
comment- 允许发表评论commentlinks- 允许在评论中发表外部链接commentadmin- 允许編輯或删除用户发表的评论comment-edit-own- 允許編輯自己在发表後的留言comment-delete-own- 允许删除自己的评论,例如
$wgGroupPermissions['sysop']['commentadmin'] = true;
默认情况下,每个人都可以发表评论,即使是匿名用户也可以,但要发表包含外部链接的评论則仅限于自动确认用户。
如果希望匿名用户也能发表外部链接,请在require_once后添加此项:
$wgGroupPermissions['*']['commentlinks'] = true;
默认情况下,只有commentadmin组的用户可以删除评论。
用户积分
$wgUserStatsPointValues['comment_plus']— the number of points to give out when another user gives a "thumbs up" to your comment.$wgUserStatsPointValues['comment_ignored']— the number of points to give out when another user adds your comments to their ignore list (Special:CommentIgnoreList).
参数
$wgCommentsDefaultAvatar— the path to an image which will be displayed instead of an avatar if social tools (SocialProfile extension) aren't installed. It should be 50x50px. Note that there is no default avatar image shipped with this extension. The default is defined inextension.jsonand links to an external image onshoutwiki.comserver, an ad-driven wiki farm. You may prefer to set this parameter to point to a local file.$wgCommentsInRecentChanges— by default, this variable is set tofalse. Set it totrueto display comments log entries in Special:RecentChanges, too, in addition to the comments log atSpecial:Log/comments.$wgCommentsSortDescending— by default, this variable is set tofalse. Set it totrueto sort comments by date descending, with the new comment box and most recent comments at the top.$wgCommentsAbuseFilterGroup— This is the custom group name for AbuseFilter for when the AbuseFilter extension is enabled. It ensures that AbuseFilter only pulls the filters related to Comments. If you want AbuseFilter to pull all the filters, enter'default'here. The default value for this is'comment', which ensures that AbuseFilter will only look for filters specifically written to target comments.
魔法词/解析器函数
评论包括2个魔法词和一个解析器函数:
{{NUMBEROFCOMMENTS}}gives the entire number of comments on the wiki.{{NUMBEROFCOMMENTSPAGE}}gives number of comments on the current page.{{NUMBEROFCOMMENTSPAGE:<pagename>}}gives number of comments on the given page.
钩子
Comments extension adds three hooks, Comment::add, Comment::delete and Comment::isSpam.
| Hook name | When it is called | Parameters |
|---|---|---|
Comment::add
|
After a comment has been added to the database, at the bottom of Comment::add function |
|
Comment::delete
|
After a comment has been deleted and the caches have been purged (function delete on class Comment)
|
|
Comment::isSpam
|
Called in Comment::isSpam before performing other spam checks.
|
|
Anti-spam
Though (as of Q3/2023) Comments does not (yet) support ConfirmEdit, MediaWiki's de facto CAPTCHA extension, there are plenty of other anti-spam measures built in, including:
- restricting who can add comments and/or comments that contain hyperlinks (see the #User rights section above)
- support for
$wgSpamRegexand$wgSummarySpamRegex - possibility for extension developers to implement custom spam checks via the
Comment::isSpamhook point (see the #Hooks section above) - AbuseFilter interoperability — AbuseFilter can be made to check if the
actionvariable's value iscommentto write filters that apply only to comments made via the Comments extension; thenew_wikitextvariable contains the actual comment text, and thenew_sizevariable is calculated on-demand based on the value of thenew_wikitextvariable. Refer to AbuseFilter's documentation for more details on how those variables and filters work.- The new configuration variable
$wgCommentsAbuseFilterGroupcan be set to'default'to make existing AbuseFilter filters apply to comments as well. By default, it is set to'comment', so only filters specifically designed to target comments will be executed against comments made via the Comments extension.
- The new configuration variable
国际化
The Comments extension currently has (partial or full) support for 68 different languages, including English. Please visit translatewiki.net if you want to translate Comments or other extensions of the social tools family of extensions into your language or modify existing translations.
参阅
| 此扩展在以下wiki农场/托管网站和/或软件包中提供: 這不是一份權威名單。 即使某些wiki农场/托管网站和/或软件包未在这里列出,它们也可能提供此扩展。 请检查你的wiki农场/托管网站或软件包以确认提供情况。 |
- Stable extensions/zh
- Parser extensions/zh
- Hook extensions/zh
- Pages using deprecated NoteTA template
- GPL licensed extensions/zh
- Extensions in Wikimedia version control/zh
- ArticlePurge extensions/zh
- BeforeCreateEchoEvent extensions/zh
- GetMagicVariableIDs extensions/zh
- LoadExtensionSchemaUpdates extensions/zh
- ParserFirstCallInit extensions/zh
- ParserGetVariableValueSwitch extensions/zh
- All extensions/zh
- Social tools/zh
- Extensions included in Miraheze/zh
- Extensions included in Telepedia/zh
- Discussion and forum extensions/zh
