Content deleted Content added
Bellezzasolo (talk | contribs) Sandbox no ping |
Restore |
||
Line 15:
local mTableTools -- [[Module:TableTools]]
local interwikiTable -- [[Module:InterwikiTable]], loaded with mw.loadData
local
-- Load shared helper functions
Line 26:
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 33 ⟶ 39:
--------------------------------------------------------------------------------
function p.getLinks(snippets
--[=[
-- Get a table of links that can be indexed with link codes. The table
Line 51 ⟶ 57:
----------------------------------------------------------------------------
function linkFunctions.u(snippets
-- User page
return makeWikilink(
snippets.interwiki,
2,
snippets.username
)
end
Line 84:
'Contribs/' .. snippets.username,
message('display-contributions')
)
end
Line 147 ⟶ 137:
end
function linkFunctions.arb(snippets)
return makeWikilinkIfExists(
4,
"Requests for arbitration/" .. snippets.username,
"rfarb"
)
end
function linkFunctions.bl(snippets)
-- Block log
Line 230 ⟶ 228:
'Log/delete/' .. snippets.username,
message('display-deletions')
)
end
function linkFunctions.lta(snippets)
return makeWikilinkIfExists(
4,
"Long-term abuse/" .. snippets.username,
"lta"
)
end
Line 314 ⟶ 320:
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 366 ⟶ 418:
end
end
local function getExtraLinkFunctions()
-- Loads the table of extra link functions from the /extra module.
Line 393 ⟶ 444:
local function memoizeExtraLink(code, func)
local success, link = pcall(func, snippets)
if
success = false
link = nil
end
if success then
links[code] = link
end
return
end
Line 412 ⟶ 466:
local linkFunction = linkFunctions[code]
local link
local success = false
if linkFunction then
link = linkFunction(snippets
links[code] = link
success = true
else
extraLinkFunctions = getExtraLinkFunctions()
Line 420 ⟶ 476:
local extraLinkFunction = extraLinkFunctions[code]
if type(extraLinkFunction) == 'function' then
success, link = memoizeExtraLink(code, extraLinkFunction)
end
end
end
if
return link
else
Line 444 ⟶ 500:
-- Allow built-in functions to overwrite extra functions.
for code, func in pairs(linkFunctions) do
local link = func(snippets
links[code] = link
end
Line 454 ⟶ 510:
return links
end
--------------------------------------------------------------------------------
-- User data snippets
Line 683 ⟶ 738:
local snippets = p.getSnippets(args)
local codes = p.getCodes(args)
local
-- Overload the built-in Lua error function to generate wikitext errors
-- meant for end users to see. This makes things harder to debug when
Line 706 ⟶ 760:
options.separator = args.separator
options.span = args.span
return options
end
Line 772 ⟶ 822:
local options = p.getOptions(args)
local snippets = p.getSnippets(args)
local links = p.getLinks(snippets
local code = args[1]
local success, link = pcall(p.exportSingle, links, code)
Line 805 ⟶ 855:
local args = {user = 'Example'}
local snippets = p.getSnippets(args)
local links = p.getLinks(snippets
-- Assemble the codes and links in order
Line 847 ⟶ 897:
return table.concat(ret, '\n')
end
p.mei = makeWikilinkIfExists
return p
|