Module:Global lock: Difference between revisions
Jump to navigation
Jump to search
merging changes from the sandbox (remove non-existent links by User:OrangeStar + a change by User:DarkMatterMan4500 (Special:Diff/279948/279949)) |
m 1 revision imported: some changes are needed ; like removing link to UTRS |
(No difference)
|
Latest revision as of 18:24, 12 December 2024
Documentation for this module may be created at Module:Global lock/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs
local isIpOrRange = require('Module:IPAddress').isIpOrRange
local middot = ' • '
local extlink = function(url, text)
return '[' .. tostring(url) .. (text and ' ' .. text or '') .. ']'
end
local link = function(page, param, text)
return extlink(mw.uri.fullUrl(page, param), text)
end
function p.multi_lock(frame)
local args = getArgs(frame)
local text = ''
local users = {}
local params = {}
local wpTarget = ''
for k, v in pairs(args) do
if v and (v ~= '') then
if type(k) == 'number' then
users[k] = mw.text.trim(v)
else
params[k] = mw.text.trim(v)
end
end
end
if #users == 0 then
error('You must specify at least one user', 0)
end
for k, v in pairs(users) do
wpTarget = wpTarget .. v .. '\n'
params[1] = v
text = text .. '<li>' .. p._lock_hide(params) .. '</li>'
end
wpTarget = mw.text.trim(wpTarget)
local link = tostring(mw.uri.fullUrl('Special:MultiLock', {wpTarget=wpTarget}))
text = '<b class="plainlinks">[' .. link .. ' Lock all]:</b><ul>' .. text .. '</ul>'
return text
end
function p.lock_hide(frame)
local args = getArgs(frame, {
trim = true,
removeBlanks = true
})
return p._lock_hide({
[1] = args[1],
[2] = args[2],
hidename = args['hidename']
})
end
-- For attribution: [[Template:LockHide]]
function p._lock_hide(args)
local username = args[1] or 'Example user'
local interwiki = args[2] or ''
local hidename = not not args['hidename'] or false
local hide = function(text, fallback)
return hidename and '<abbr title="name hidden">' .. (
fallback and '<i>' .. text .. '</i>' or text
) .. '</abbr>' or (fallback or text)
end
local srga = mw.title.getCurrentTitle():isSubpageOf(
mw.title.new('SN')
)
if srga then
return '[[Special:CentralAuth/' .. username .. '|' .. (
hide('name hidden', username)
) .. ']]'
end
local text = {
'<span class="plainlinks">',
extlink(
mw.title.new(interwiki .. 'User:' .. username):fullUrl(),
hide('name hidden', username)
),
' ',
'(',
'[[' .. interwiki .. 'User talk:' .. username .. '|' ..
hide('talk') ..
']]',
middot,
'[[' .. interwiki .. 'Special:Contributions/' .. username .. '|' ..
hide('contribs') ..
']]',
middot,
'[[' .. interwiki .. 'Special:BlockIP/' .. username .. '|' ..
hide('block') ..
']]',
middot,
'[[Special:CentralAuth/' .. username .. '|' ..
hide('CA') ..
']]',
middot,
'<span title="Login Wiki Checkuser" class="tpl-permalink-reason">' ..
extlink(
tostring(mw.uri.new('//login.miraheze.org/w/index.php'):extend({
title = 'Special:CheckUser',
user = username,
uselang = 'en',
reason = 'per [[:m:Special:Redirect/page/' .. mw.title.getCurrentTitle().id .. '|request]]'
})),
'<b>lwcheckuser</b>'
) ..
'</span>',
')',
'</span>',
'__NOINDEX__'
}
return table.concat(text, '')
end
return p