扩展:评论
![]() 发行状态: 穩定版 |
|
---|---|
![]() |
|
实现 | 解析器扩展 , 函数钩 |
描述 | 添加允许对文章评论的<comments /> 解析器标签 |
作者 |
|
最新版本 | 5.0 |
MediaWiki | 1.39+ |
数据库更改 | 是 |
表 | Comments Comments_Vote Comments_block |
许可协议 | GNU通用公眾授權條款2.0或更新版本 |
下載 | |
|
|
<comments /> |
|
季度下載量 | 91 (Ranked 87th) |
前往translatewiki.net翻譯Comments扩展 | |
問題 | 开启的任务 · 报告错误 |
评论插件添加 <comments />
parser hook tag to allow commenting on articles where the tag is present.
评论操作会记录在Special:Log/comments
,但是默认情况下它们会像在巡查 日志中一样隐藏。
你可以设置$wgCommentsInRecentChanges = true;
以展示Special:RecentChanges中的评论日志项目(在2.8+版本可用)。
Majority of the code fixes were done by Misza and Jack Phoenix.
安裝
- 下载文件,并将其放置在您
extensions/
文件夹中的Comments
目录内。 - 将下列代码放置在您的LocalSettings.php 的底部:
wfLoadExtension( 'Comments' );
- 运行更新脚本,它将自动创建此扩展必须依赖的数据库表。
完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。
用法
<comments />
— basic comment form, sufficient for most things.<comments allow="Derfel,Jack Phoenix,Misza" />
— only allows the users Derfel, Jack Phoenix and Misza to submit comments.<comments voting="Plus" />
— prevents users from rating comments negatively (thumb down), allowing only positive (thumb up) votes.
每日评论
The extension also comes with a "Comments of the Day" feature (<commentsoftheday />
), which by default is not enabled. You can enable this feature in the wiki's LocalSettings.php
, by adding the following after the require_once
line:
require_once "$IP/extensions/Comments/CommentsOfTheDay.php";
If the nocache
argument is passed to the parser hook (like this: <commentsoftheday nocache=true />
), the parser hook will not use memcached and will just fetch the data from the database instead of cache.
This is useful if you want to show the most up-to-date data, but it can be very server-intensive.
用户权限
这个插件添加三个新的用户权限:
comment
- (允许发布评论)commentlinks
- (允许在评论中发布外部链接)commentadmin
- (允许删除用户发布的评论),例如comment-delete-own
- which allows deleting one's own comments, e.g.
$wgGroupPermissions['sysop']['commentadmin'] = true;
By default, everyone, even anonymous users, can post comments, but posting comments that contain external links is limited to autoconfirmed users.
If you want anonymous users to be able to post external links, add this after the require_once
:
$wgGroupPermissions['*']['commentlinks'] = true;
By default only users in the commentadmin
group can delete comments.
User points
$wgUserStatsPointValues['comment_plus']
— amount of points to give out when another user gives "thumbs up" to your comment.$wgUserStatsPointValues['comment_ignored']
— amount of points to give out when another user adds your comments to their ignore list (Special:CommentIgnoreList).
Parameters
$wgCommentsDefaultAvatar
— path to an image which will be displayed instead of an avatar if social tools (SocialProfile extension) aren't installed. 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 would like AbuseFilter to pull all of 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.
Magic words/Parser functions
Comments includes 2 magic words and a parser function:
{{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.
Hooks
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 into the database, on 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 in general 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
- 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 WikiForge/zh
- Extensions included in WikiTide/zh
- Discussion and forum extensions/zh