Module:UserLinks/sandbox: Difference between revisions

Content deleted Content added
Restore
Jackmcbarn (talk | contribs)
sync
Line 15:
local mTableTools -- [[Module:TableTools]]
local interwikiTable -- [[Module:InterwikiTable]], loaded with mw.loadData
local mSu -- [[Module:Su]]
 
-- Load shared helper functions
Line 26 ⟶ 25:
local makeFullUrlLink = mShared.makeFullUrlLink
local message = mShared.message
local function makeWikilinkIfExists(namespace, page, display)
local title = mw.title.new(page, namespace)
if title and title.exists then
return makeWikilink("", namespace, page, display)
end
end
 
local p = {}
Line 85 ⟶ 78:
message('display-contributions')
)
end
function linkFunctions.ltac64(snippets)
-- Contributions
local first64 = snippets.username:match('^%x+:%x+:%x+:%x+:')
or snippets.username:match('^%x+:%x+:%x+:')
or snippets.username:match('^%x+:%x+:')
or snippets.username:match('^%x+:')
return first64 and makeWikilink(
snippets.interwiki,
4-1,
'Contribs/' .. first64 .. ':/64',
'(/64)'
) or ''
end
 
Line 137 ⟶ 144:
end
 
function linkFunctions.arb(snippets)
return makeWikilinkIfExists(
4,
"Requests for arbitration/" .. snippets.username,
"rfarb"
)
end
function linkFunctions.bl(snippets)
-- Block log
Line 228 ⟶ 227:
'Log/delete/' .. snippets.username,
message('display-deletions')
)
end
 
function linkFunctions.lta(snippets)
return makeWikilinkIfExists(
4,
"Long-term abuse/" .. snippets.username,
"lta"
)
end
Line 320 ⟶ 311:
message('display-rfa')
)
end
function linkFunctions.rfcuser(snippets)
return makeWikilinkIfExists(
4,
"Requests for comment/" .. snippets.username,
"rfcuser"
)
end
function linkFunctions.rfcheckuser(snippets)
return makeWikilinkIfExists(
4,
"Requests for checkuser/Case/" .. snippets.username,
"rfcu"
)
end
function linkFunctions.spi(snippets)
return makeWikilinkIfExists(
4,
"Sockpuppet investigations/" .. snippets.username,
"spi"
)
end
function linkFunctions.socks(snippets)
local ssp = makeWikilinkIfExists(
4,
"Suspected sock puppets/" .. snippets.username,
"ssp"
)
local confirmed = makeWikilinkIfExists(
14,
'Wikipedia sockpuppets of ' .. snippets.username,
'confirmed socks'
)
local suspected = makeWikilinkIfExists(
14,
'Suspected Wikipedia sockpuppets of ' .. snippets.username,
'suspected socks'
)
if confirmed or suspected then
mSu = maybeLoadModule("Module:Su")
if mSu then
return (ssp or "") .. mSu._main(confirmed, suspected)
end
end
return ssp
end
 
Line 418 ⟶ 363:
end
end
 
local function getExtraLinkFunctions()
-- Loads the table of extra link functions from the /extra module.
Line 444 ⟶ 390:
local function memoizeExtraLink(code, func)
local success, link = pcall(func, snippets)
if link ~= nilsuccess and type(link) ~== "'string"' then
success = false
link = nil
end
if success then
links[code] = link
return ssplink
end
return success, linknil
end
 
Line 466 ⟶ 409:
local linkFunction = linkFunctions[code]
local link
local success = false
if linkFunction then
link = linkFunction(snippets)
links[code] = link
success = true
else
extraLinkFunctions = getExtraLinkFunctions()
Line 476 ⟶ 417:
local extraLinkFunction = extraLinkFunctions[code]
if type(extraLinkFunction) == 'function' then
success, link = memoizeExtraLink(code, extraLinkFunction)
end
end
end
if successlink then
return link
else
Line 510 ⟶ 451:
return links
end
 
--------------------------------------------------------------------------------
-- User data snippets
Line 897 ⟶ 839:
return table.concat(ret, '\n')
end
 
p.mei = makeWikilinkIfExists
return p