Extension:评论
Comments 发行状态: 稳定版 |
|
---|---|
实现 | 解析器扩展 , 函数钩 |
描述 | <comments /> 解析器钩子标签,允许对文章评论 |
作者 | |
最新版本 | 5.0 |
MediaWiki | 1.43+ |
数据库更改 | 是 |
表 | Comments Comments_Vote Comments_block |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | |
|
|
<comments /> |
|
|
|
季度下載量 | 46 (Ranked 84th) |
前往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-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.json
and links to an external image onshoutwiki.com
server, 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 totrue
to 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 totrue
to 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
$wgSpamRegex
and$wgSummarySpamRegex
- possibility for extension developers to implement custom spam checks via the
Comment::isSpam
hook point (see the #Hooks section above) - AbuseFilter interoperability — AbuseFilter can be made to check if the
action
variable's value iscomment
to write filters that apply only to comments made via the Comments extension; thenew_wikitext
variable contains the actual comment text, and thenew_size
variable is calculated on-demand based on the value of thenew_wikitext
variable. Refer to AbuseFilter's documentation for more details on how those variables and filters work.- The new configuration variable
$wgCommentsAbuseFilterGroup
can 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
- LoadExtensionSchemaUpdates extensions/zh
- MagicWordwgVariableIDs extensions/zh
- ParserFirstCallInit extensions/zh
- ParserGetVariableValueSwitch extensions/zh
- All extensions/zh
- Social tools/zh
- Extensions included in Miraheze/zh
- Extensions included in Telepedia/zh
- Extensions included in WikiForge/zh
- Discussion and forum extensions/zh