跳转到内容

Module:Sock list:修订间差异

维基百科,自由的百科全书
删除的内容 添加的内容
Xiplus留言 | 贡献
Fix: empty string is true
+ hidename參數
 
(未显示2个用户的8个中间版本)
第9行: 第9行:
end
end


function listEntry(frame, sock, master)
function listEntry(frame, sock, master, hidename)
local template = (isIpOrRange(sock) ~= "") and "checkip" or "checkuser"
local isip = (isIpOrRange(sock) ~= "")
local template = isip and "checkip" or "checkuser"
local li = mw.html.create('li')
local li = mw.html.create('li')
if isip then
li:wikitext(frame:expandTemplate{title=template, args={sock, ['master name']=master}})
li:attr('class', "template-sock-list-ip")
li:attr('data-ip', sock)
else
li:attr('class', "template-sock-list-user")
li:attr('data-user', sock)
end
li:wikitext(frame:expandTemplate{title=template, args={sock, ['master name']=master, ['hidename']=(hidename and '1' or ''), bullet='no'}})
return li
return li
end
end
第22行: 第30行:
url = url .. "&users=" .. mw.uri.encode(sock)
url = url .. "&users=" .. mw.uri.encode(sock)
end
end
return "[" .. url .. " Editor interaction utility]"
return "[" .. url .. " 用戶互動分析]"
end
end


function toolTimeline(args)
function toolTimeline(args)
local user2 = args[1] or ""
if args.master == user2 then
user2 = args[2] or ""
end
local url = "https://tools.wmflabs.org/interaction-timeline?wiki=zhwiki&user="
local url = "https://tools.wmflabs.org/interaction-timeline?wiki=zhwiki&user="
.. mw.uri.encode(args.master) .. "&user=" .. mw.uri.encode(args[1] or "")
.. mw.uri.encode(args.master) .. "&user=" .. mw.uri.encode(user2)
return "[" .. url .. " Interaction Timeline]"
return "[" .. url .. " 互動時間線]"
end
end


function p._main(frame, args)
function p._main(frame, args)
local socklist = mw.html.create('ul')
local socklist = mw.html.create('div')
socklist:attr('class', 'template-sock-list')
local userlist = mw.html.create('ul')
if args[1] then
if args[1] then
for i, sock in ipairs(args) do
for i, sock in ipairs(args) do
socklist:node(listEntry(frame, sock, args.master))
userlist:node(listEntry(frame, sock, args.master, yesno( args[ 'hidename' .. i ] or 0 )))
end
end
end
end
socklist:node(userlist)
if yesno(args.tools_link) then
if yesno(args.tools_link) then
local tools = mw.html.create('li')
local toolswrapper = mw.html.create('dl')
local tools = mw.html.create('dd')
tools
tools
:attr('class', 'plainlinks')
:attr('class', 'plainlinks template-sock-list-tools')
:wikitext("<b>工具</b>:")
:wikitext("<b>工具</b>:")
:node(toolEIA(args))
:node(toolEIA(args))
:wikitext(" • ")
:wikitext(" • ")
:node(toolTimeline(args))
:node(toolTimeline(args))
socklist:node(tools)
toolswrapper:node(tools)
socklist:node(toolswrapper)
end
end
return socklist
return socklist

2023年1月25日 (三) 07:05的最新版本

local p = {}
local getArgs = require('Module:Arguments').getArgs
local isIpOrRange = require('Module:IPAddress')._isIpOrRange
local yesno = require('Module:Yesno')

function p.main(frame)
	local args = getArgs(frame)
	return p._main(frame, args)
end

function listEntry(frame, sock, master, hidename)
	local isip = (isIpOrRange(sock) ~= "")
	local template = isip and "checkip" or "checkuser"
	local li = mw.html.create('li')
	if isip then
		li:attr('class', "template-sock-list-ip")
		li:attr('data-ip', sock)
	else
		li:attr('class', "template-sock-list-user")
		li:attr('data-user', sock)
	end
	li:wikitext(frame:expandTemplate{title=template, args={sock, ['master name']=master, ['hidename']=(hidename and '1' or ''), bullet='no'}})
	return li
end

function toolEIA(args)
	local url = "https://tools.wmflabs.org/sigma/editorinteract.py?server=zhwiki&users="
		.. mw.uri.encode(args.master)
	for i, sock in ipairs(args) do
		url = url .. "&users=" .. mw.uri.encode(sock)
	end
	return "[" .. url .. " 用戶互動分析]"
end

function toolTimeline(args)
	local user2 = args[1] or ""
	if args.master == user2 then
		user2 = args[2] or ""
	end
	local url = "https://tools.wmflabs.org/interaction-timeline?wiki=zhwiki&user="
		.. mw.uri.encode(args.master) .. "&user=" .. mw.uri.encode(user2)
	return "[" .. url .. " 互動時間線]"
end

function p._main(frame, args)
	local socklist = mw.html.create('div')
	socklist:attr('class', 'template-sock-list')
	local userlist = mw.html.create('ul')
	if args[1] then
		for i, sock in ipairs(args) do
			userlist:node(listEntry(frame, sock, args.master, yesno( args[ 'hidename' .. i ] or 0 )))
		end
	end
	socklist:node(userlist)
	if yesno(args.tools_link) then
		local toolswrapper = mw.html.create('dl')
		local tools = mw.html.create('dd')
		tools
			:attr('class', 'plainlinks template-sock-list-tools')
			:wikitext("<b>工具</b>:")
			:node(toolEIA(args))
			:wikitext(" • ")
			:node(toolTimeline(args))
		toolswrapper:node(tools)
		socklist:node(toolswrapper)
	end
	return socklist
end

return p