在 MediaWiki 上显示编辑计数
Displaying edit count on MediaWiki
我想在用户页面上显示编辑/贡献的数量。有什么办法吗?
我尝试使用此处提到的 link:http://en.wikipedia.org/wiki/Help:User_contributions
所以如果按照那个,我得到了一个 URL 像这样的东西:
http://ourdomain/api.php?action=query&list=users&ususers=MYUSERNAME&usprop=editcount
如果我使用它,它会显示一个包含正确编辑次数的页面。但它显示为 XML,如:
<?xml version="1.0"?>
<api>
<query>
<users>
<user name="USERNAME" editcount="728" />
</users>
</query>
</api>
在这个 XML 页面上,我可以看到正确的编辑次数。但我只想将其显示为不同页面上的计数。类似于“编辑总数:728”。我们正在使用 MediaWiki 1.15.5-7。
您已经找到了您要找的东西! API 将为您提供用户编辑次数的最佳估计值。您可以将每个综合浏览量的 Javascript 添加到 运行 到 MediaWiki:Common.js
,以将此数据注入用户页面。在您的 API 调用中,附加 &format=json
以获得对 JS 更友好的格式。
如果出于某种原因您不想在此处使用 Javascript,您可以 write your own extension to handle this in the backend. This can be implemented as a parser function, to be invoked like {{USERCONTRIBS:UserName}}
, or similar. The method you are looking for is User::getEditCount()
。要获取用户对象,可以使用User::newFromName
。然而,这将需要在每次页面加载时清除用户页面,从而使它们的加载速度变慢很多,否则您将不得不接受计数并不总是最新的。
可能还有一些现有的扩展程序可以让您打印编辑计数。我确定 Extension:SemanticExtraSpecialProperties
does, though that depends on the whole SemanticMediawiki package. For an example of how to display user statistics with SMW+SESP, see this page.
我想在用户页面上显示编辑/贡献的数量。有什么办法吗?
我尝试使用此处提到的 link:http://en.wikipedia.org/wiki/Help:User_contributions
所以如果按照那个,我得到了一个 URL 像这样的东西:
http://ourdomain/api.php?action=query&list=users&ususers=MYUSERNAME&usprop=editcount
如果我使用它,它会显示一个包含正确编辑次数的页面。但它显示为 XML,如:
<?xml version="1.0"?>
<api>
<query>
<users>
<user name="USERNAME" editcount="728" />
</users>
</query>
</api>
在这个 XML 页面上,我可以看到正确的编辑次数。但我只想将其显示为不同页面上的计数。类似于“编辑总数:728”。我们正在使用 MediaWiki 1.15.5-7。
您已经找到了您要找的东西! API 将为您提供用户编辑次数的最佳估计值。您可以将每个综合浏览量的 Javascript 添加到 运行 到 MediaWiki:Common.js
,以将此数据注入用户页面。在您的 API 调用中,附加 &format=json
以获得对 JS 更友好的格式。
如果出于某种原因您不想在此处使用 Javascript,您可以 write your own extension to handle this in the backend. This can be implemented as a parser function, to be invoked like {{USERCONTRIBS:UserName}}
, or similar. The method you are looking for is User::getEditCount()
。要获取用户对象,可以使用User::newFromName
。然而,这将需要在每次页面加载时清除用户页面,从而使它们的加载速度变慢很多,否则您将不得不接受计数并不总是最新的。
可能还有一些现有的扩展程序可以让您打印编辑计数。我确定 Extension:SemanticExtraSpecialProperties
does, though that depends on the whole SemanticMediawiki package. For an example of how to display user statistics with SMW+SESP, see this page.