Module:Sock list: Difference between revisions

From Bharatpedia, an open encyclopedia
(Created page with "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, args, sockNum, sock) local template = (isIpOrRange(sock) ~= "") and (args.IP_template or args.template or 'checkip') or (args.account_template or args.template or 'checkuser') local li = mw.ht...")
Tags: Mobile edit Mobile web edit Advanced mobile edit
 
No edit summary
Line 1: Line 1:
local p = {}
local p = {}
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local isIpOrRange = require('Module:IPAddress')._isIpOrRange
local isIp = require('Module:IPAddress').isIp  -- Use the isIp function
local yesno = require('Module:Yesno')
local yesno = require('Module:Yesno')


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


function listEntry(frame, args, sockNum, sock)
function listEntry(frame, args, sockNum, sock)
local template = (isIpOrRange(sock) ~= "")
    local template = (isIp(sock) ~= "")
and (args.IP_template or args.template or 'checkip')
        and (args.IP_template or args.template or 'checkip')
or (args.account_template or args.template or 'checkuser')
        or (args.account_template or args.template or 'checkuser')
local li = mw.html.create('li')
    local li = mw.html.create('li')
local text = frame:expandTemplate{title=template, args={sock, ['master name']=args.master}}
    local text = frame:expandTemplate{title=template, args={sock, ['master name']=args.master}}
if args['strike' .. sockNum] then
    if args['strike' .. sockNum] then
text = "<s>" .. text .. "</s>"
        text = "<s>" .. text .. "</s>"
end
    end
local note = args['note' .. sockNum]
    local note = args['note' .. sockNum]
if note then
    if note then
text = text .. " " .. note
        text = text .. " " .. note
end
    end
li:wikitext(text)
    li:wikitext(text)
return li
    return li
end
end


function toolEIA(args)
function toolEIA(args)
local url = "https://tools.wmflabs.org/sigma/editorinteract.py?users="
    local url = "https://tools.wmflabs.org/sigma/editorinteract.py?users="
.. mw.uri.encode(args.master or "")
        .. mw.uri.encode(args.master or "")
for i, sock in ipairs(args) do
    for i, sock in ipairs(args) do
if not args['strike' .. i] then
        if not args['strike' .. i] then
url = url .. "&users=" .. mw.uri.encode(sock)
            url = url .. "&users=" .. mw.uri.encode(sock)
end
        end
end
    end
return "[" .. url .. " Editor interaction utility]"
    return "[" .. url .. " Editor interaction utility]"
end
end


function toolTimeline(args)
function toolTimeline(args)
local url = "https://tools.wmflabs.org/interaction-timeline?wiki=enwiki&user="
    local url = "https://tools.wmflabs.org/interaction-timeline?wiki=enwiki&user="
.. mw.uri.encode(args.master or "") .. "&user=" .. mw.uri.encode(args[1] or "")
        .. mw.uri.encode(args.master or "") .. "&user=" .. mw.uri.encode(args[1] or "")
return "[" .. url .. " Interaction Timeline]"
    return "[" .. url .. " Interaction Timeline]"
end
end


function toolSpiTools(args)
function toolSpiTools(args)
local url = "https://spi-tools.toolforge.org/spi/?caseName="
    local url = "https://spi-tools.toolforge.org/spi/?caseName="
.. mw.uri.encode(args.master or "")
        .. mw.uri.encode(args.master or "")
return "[" .. url .. " SPI Tools]"
    return "[" .. url .. " SPI Tools]"
end
end


function p._main(frame, args)
function p._main(frame, args)
local socklist = mw.html.create('ul')
    local socklist = mw.html.create('ul')
if yesno(args.hidden) then
    if yesno(args.hidden) then
socklist:attr('style', 'display:none;')
        socklist:attr('style', 'display:none;')
end
    end
if args[1] then
    if args[1] then
for sockNum, sock in ipairs(args) do
        for sockNum, sock in ipairs(args) do
if args.master ~= sock or not yesno(args.remove_master or 'no') then
            if args.master ~= sock or not yesno(args.remove_master or 'no') then
socklist:node(listEntry(frame, args, sockNum, sock))
                socklist:node(listEntry(frame, args, sockNum, sock))
end end end
            end
if yesno(args.tools_link) then
        end
local tools = mw.html.create('li')
    end
tools
    if yesno(args.tools_link) then
:attr('class', 'plainlinks')
        local tools = mw.html.create('li')
:wikitext("<b>Tools</b>: ")
        tools
:node(toolEIA(args))
            :attr('class', 'plainlinks')
:wikitext(" <b>&middot;</b> ")
            :wikitext("<b>Tools</b>: ")
:node(toolTimeline(args))
            :node(toolEIA(args))
:wikitext(" <b>&middot;</b> ")
            :wikitext(" <b>&middot;</b> ")
:node(toolSpiTools(args))
            :node(toolTimeline(args))
socklist:node(tools)
            :wikitext(" <b>&middot;</b> ")
end
            :node(toolSpiTools(args))
return socklist
        socklist:node(tools)
    end
    return socklist
end
end


return p
return p

Revision as of 11:40, 12 November 2024

Documentation for this module may be created at Module:Sock list/doc

local p = {}
local getArgs = require('Module:Arguments').getArgs
local isIp = require('Module:IPAddress').isIp  -- Use the isIp function
local yesno = require('Module:Yesno')

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

function listEntry(frame, args, sockNum, sock)
    local template = (isIp(sock) ~= "")
        and (args.IP_template or args.template or 'checkip')
        or (args.account_template or args.template or 'checkuser')
    local li = mw.html.create('li')
    local text = frame:expandTemplate{title=template, args={sock, ['master name']=args.master}}
    if args['strike' .. sockNum] then
        text = "<s>" .. text .. "</s>"
    end
    local note = args['note' .. sockNum]
    if note then
        text = text .. " " .. note
    end
    li:wikitext(text)
    return li
end

function toolEIA(args)
    local url = "https://tools.wmflabs.org/sigma/editorinteract.py?users="
        .. mw.uri.encode(args.master or "")
    for i, sock in ipairs(args) do
        if not args['strike' .. i] then
            url = url .. "&users=" .. mw.uri.encode(sock)
        end
    end
    return "[" .. url .. " Editor interaction utility]"
end

function toolTimeline(args)
    local url = "https://tools.wmflabs.org/interaction-timeline?wiki=enwiki&user="
        .. mw.uri.encode(args.master or "") .. "&user=" .. mw.uri.encode(args[1] or "")
    return "[" .. url .. " Interaction Timeline]"
end

function toolSpiTools(args)
    local url = "https://spi-tools.toolforge.org/spi/?caseName="
        .. mw.uri.encode(args.master or "")
    return "[" .. url .. " SPI Tools]"
end

function p._main(frame, args)
    local socklist = mw.html.create('ul')
    if yesno(args.hidden) then
        socklist:attr('style', 'display:none;')
    end
    if args[1] then
        for sockNum, sock in ipairs(args) do
            if args.master ~= sock or not yesno(args.remove_master or 'no') then
                socklist:node(listEntry(frame, args, sockNum, sock))
            end
        end
    end
    if yesno(args.tools_link) then
        local tools = mw.html.create('li')
        tools
            :attr('class', 'plainlinks')
            :wikitext("<b>Tools</b>: ")
            :node(toolEIA(args))
            :wikitext(" <b>&middot;</b> ")
            :node(toolTimeline(args))
            :wikitext(" <b>&middot;</b> ")
            :node(toolSpiTools(args))
        socklist:node(tools)
    end
    return socklist
end

return p