Content deleted Content added
Jackmcbarn (talk | contribs) sync |
Jackmcbarn (talk | contribs) wrap deleted contribs and block user links in sysop-show |
||
Line 40:
-- at [[Module:UserLinks/extra]].
--]=]
local links, classes, linkFunctions = {}, {}, {}
----------------------------------------------------------------------------
Line 146:
'Block/' .. snippets.username,
message('display-blockuser')
), 'sysop-show'
end
Line 166:
'DeletedContributions/' .. snippets.username,
message('display-deletedcontributions')
), 'sysop-show'
end
Line 364:
local function memoizeExtraLink(code, func)
local success, link, class = pcall(func, snippets)
if success and type(link) == 'string' then
links[code] = link
classes[code] = class
return link▼
return link, class
end
return nil
Line 385 ⟶ 386:
local link
if linkFunction then
link, class = linkFunction(snippets)
links[code] = link
classes[code] = class
else
extraLinkFunctions = getExtraLinkFunctions()
Line 416 ⟶ 418:
-- Allow built-in functions to overwrite extra functions.
for code, func in pairs(linkFunctions) do
local link, class = func(snippets)
links[code] = link
classes[code] = class
end
return function (t, key)
Line 424 ⟶ 427:
end
})
return links, classes
end
Line 655 ⟶ 658:
local snippets = p.getSnippets(args)
local codes = p.getCodes(args)
local links, classes = p.getLinks(snippets)
-- Overload the built-in Lua error function to generate wikitext errors
-- meant for end users to see. This makes things harder to debug when
-- real errors occur, but it is the only realistic way to show wikitext
-- errors and and still have sane code when using metatables, etc.
local success, result = pcall(p.export, codes, links, classes, options)
if success then
return result
Line 696 ⟶ 699:
end
function p.export(codes, links, classes, options)
-- Make the user link.
local userLink = links.u
Line 708 ⟶ 711:
mToolbar = require('Module:Toolbar')
local toolbarArgs = {}
local openClass, closeClass = '', ''
for i, code in ipairs(codes) do
local link = links[code]
if classes[code] then
toolbarArgs[#toolbarArgs + 1] = link▼
openClass = '<span class="' .. class .. '">'
else
openClass = ''
end
▲ toolbarArgs[#toolbarArgs + 1] = closeClass .. openClass .. link
closeClass = classes[code] and '</span>' or ''
end
if #toolbarArgs ~= 0 then
toolbarArgs[#toolbarArgs] = toolbarArgs[#toolbarArgs] .. closeClass
end
toolbarArgs.style = options.toolbarStyle
Line 739 ⟶ 752:
local options = p.getOptions(args)
local snippets = p.getSnippets(args)
local links, classes = p.getLinks(snippets)
local code = args[1]
local success, link, class = pcall(p.exportSingle, links, classes, code)
if success then
if class then
▲ return link
return '<span class="' .. class .. '">' .. link .. '</span>'
else
▲ return link
end
else
return makeWikitextError(link, options.isDemo)
Line 749 ⟶ 766:
end
function p.exportSingle(links, classes, code)
-- If any errors occur, they will probably occur here. This function
-- exists purely so that all the errors that will occur in p._single can
Line 759 ⟶ 776:
)
end
return links[code], classes[code]
end
|