Content deleted Content added
Bellezzasolo (talk | contribs) Sandbox no ping |
Sohom Datta (talk | contribs) others |
||
(19 intermediate revisions by 9 users not shown) | |||
Line 15:
local mTableTools -- [[Module:TableTools]]
local interwikiTable -- [[Module:InterwikiTable]], loaded with mw.loadData
-- Load shared helper functions
Line 33 ⟶ 32:
--------------------------------------------------------------------------------
function p.getLinks(snippets
--[=[
-- Get a table of links that can be indexed with link codes. The table
Line 51 ⟶ 50:
----------------------------------------------------------------------------
function linkFunctions.u(snippets
-- User page
return makeWikilink(
snippets.interwiki,
2,
snippets.username
)
end
function linkFunctions.np(snippets)
-- User page (no ping)
return '<span class="plainlinks">' .. makeFullUrlLink(
snippets.interwiki,
2,
snippets.username,
'',
snippets.username
) .. '</span>'
end
Line 89 ⟶ 93:
function linkFunctions.c64(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,
-1,
'Contribs/' ..
'(/64)'
) or ''
end
function linkFunctions.ct(snippets)
-- Edit count
return
0,
'ec/' .. snippets.toolLang .. '.' .. snippets.projectLong .. '.org/' .. snippets.username,
message('display-count')
)
Line 134 ⟶ 137:
function linkFunctions.ae(snippets)
-- Automated edits (and non-automated contributions).
return
0,
'autoedits/' .. snippets.toolLang .. '.' .. snippets.projectLong .. '.org/' .. snippets.username,
message('display-autoedits')
)
Line 210 ⟶ 208:
function linkFunctions.es(snippets)
-- Edit summaries
return
0,
'editsummary/' .. snippets.toolLang .. '.' .. snippets.projectLong .. '.org/' .. snippets.username,
message('display-editsummaries')
)
Line 340 ⟶ 333:
'ListFiles/' .. snippets.username,
message('display-uploads')
)
end
function linkFunctions.nuke(snippets)
-- Mass delete/Special:Nuke
return makeWikilink(
snippets.interwiki,
-1,
'Nuke/' .. snippets.username,
message('display-nuke')
)
end
function linkFunctions.gender(snippets)
-- Gender
return mw.getCurrentFrame():callParserFunction(
'GENDER',
snippets.username,
'he/him',
'she/her',
'they/them'
)
end
Line 413 ⟶ 429:
local link
if linkFunction then
link = linkFunction(snippets
links[code] = link
else
Line 444 ⟶ 460:
-- Allow built-in functions to overwrite extra functions.
for code, func in pairs(linkFunctions) do
local link = func(snippets
links[code] = link
end
Line 620 ⟶ 636:
function snippetFunctions.fullDomain()
-- The full ___domain name of the site, e.g. www.mediawiki.org,
-- en.
local fullDomain
local lang = getSnippet('toolLang')
Line 683 ⟶ 699:
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 702 ⟶ 717:
local options = {}
options.isDemo = yesno(args.demo) or false
options.noPing = yesno(args.noPing) or yesno(args.noping) or yesno(args.np) or false
options.toolbarStyle = yesno(args.small) and 'font-size: 90%;' or nil
options.sup = yesno(args.sup, true)
options.separator = args.separator
options.span = args.span
return options
end
Line 731 ⟶ 743:
function p.export(codes, links, options)
-- Make the user link.
local userLink = options.noPing and links.np or links.u
-- If we weren't passed any link codes, just return the user link.
Line 772 ⟶ 784:
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 794 ⟶ 806:
return links[code]
end
return p
|