Jump to content

Module:IPblock and Module:IPblock/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
fix so inputs "User:1.2.3.4" and "User talk:1.2.3.4" work
 
announce new release
 
Line 657: Line 657:
end
end
address = table.concat(parts, ':') .. wildcard
address = table.concat(parts, ':') .. wildcard
local url = '[https://en.wikipedia.org/wiki/Special:Contributions/%s?ucstart=%s contribs]'
local url = '[https://en.wikipedia.org/wiki/Special:Contributions/%s?ucstart=%s c]'
-- %s = IPv6 prefix address in uppercase with '*' wildcard at end
-- %s = IPv6 prefix address in uppercase with '*' wildcard at end
-- %s = Start date formatted 'yyyymmdd000000'
-- %s = Start date formatted 'yyyymmdd000000'
Line 664: Line 664:
return '' -- no contributions link available
return '' -- no contributions link available
end
end
local url = '[https://tools.wmflabs.org/xtools/rangecontribs/?project=en.wikipedia.org&namespace=all&limit=50&text=%s&begin=%s contribs]'
local url = '[https://tools.wmflabs.org/xtools/rangecontribs/?project=en.wikipedia.org&namespace=all&limit=50&text=%s&begin=%s c]'
-- %s = IPv4 CIDR range with '/' changed to '%2F'
-- %s = IPv4 CIDR range with '/' changed to '%2F'
-- %s = Start date formatted 'yyyy-mm-dd'
-- %s = Start date formatted 'yyyy-mm-dd'
return string.format(url, encoded, start_date('y-m-d', strings.months))
return string.format(url, encoded, start_date('y-m-d', strings.months))
end
end
return '[[Special:Contributions/' .. address .. '|contribs]]'
return '[[Special:Contributions/' .. address .. '|c]]'
end
end


Line 813: Line 813:
lines:add('')
lines:add('')
end
end
lines:add('') -- this blank line is replaced with a heading
local heading_line
local heading_line = lines.n
if not iplist.nolist then
lines:add('') -- this blank line is replaced with a heading
heading_line = lines.n
end
local duplicates = Collection.new()
local duplicates = Collection.new()
local previous
local previous
Line 843: Line 840:
iplist.n == 1 and '' or 'es'
iplist.n == 1 and '' or 'es'
)
)
if heading_line then
lines[heading_line] = heading_text .. duplicate_text .. ':'
lines[heading_line] = heading_text .. duplicate_text .. ':'
end
local strings = iplist.want_plain and plaintext or wikitable
local strings = iplist.want_plain and plaintext or wikitable
strings.notes = nil -- needed when module is kept loaded for multiple tests
strings.notes = nil -- needed when module is kept loaded for multiple tests
Line 969: Line 964:
local comment = options.comment
local comment = options.comment
if not (comment and line:sub(1, #comment) == comment) then
if not (comment and line:sub(1, #comment) == comment) then
-- Replace accepted delimiters with a space.
line = line
line = line:gsub('[!"#&\'()+,%-;<=>?[%]_{|}]', ' ')
:gsub('[Ss]pecial:[Cc]ontrib%w*/', ' ') -- so input "Special:Contributions/1.2.3.4" works
:gsub('[Tt]alk:', ' ')
:gsub('[Uu]ser:', ' ')
:gsub('[!"#&\'()+,%-;<=>?[%]_{|}]', ' ') -- replace accepted delimiters with a space
:gsub('\226\128\142', ' ') -- replace LTR marks (U+200E)
extract_ipv4(v4list, v4omitted, line)
extract_ipv4(v4list, v4omitted, line)
extract_ipv6(v6list, v6omitted, line)
extract_ipv6(v6list, v6omitted, line)
Line 989: Line 980:
-- 1: Commented out April 2016 as expired.
-- 1: Commented out April 2016 as expired.
-- 1: lines:add("'''Please see [[Template talk:Blockcalc#Version February 2016|this announcement]].'''")
-- 1: lines:add("'''Please see [[Template talk:Blockcalc#Version February 2016|this announcement]].'''")
lines:add("'''By default, links now use [[Special:Contributions]] per [[Template talk:IP range calculator#Version November 2017|this announcement]].'''")
-- 2: Commented out December 2017 as expired.
-- 2: lines:add("'''By default, links now use [[Special:Contributions]] per [[Template talk:IP range calculator#Version November 2017|this announcement]].'''")
end
end
process_ips(lines, v4list, v4omitted)
process_ips(lines, v4list, v4omitted)
Line 1,008: Line 998:
end
end


return { IPblock = IPblock, _IPblock = _IPblock }
local function sha1(frame)
-- Return SHA-1 hash of first parameter.
-- This is for use at [[User:Johnuniq/Security]] to generate hash of a password.
local text = (frame.args[1] or ''):match("^%s*(.-)%s*$")
if text ~= '' then
return 'SHA-1 hash after removing any leading or trailing whitespace is <code>' .. mw.hash.hashValue('sha1', text) .. '</code>'
end
return 'Usage: <code>&#123;{#invoke:IPblock|sha1|text}&#125;</code> to display the SHA-1 hash of <code>text</code>.'
end

return {
IPblock = IPblock,
_IPblock = _IPblock,
sha1 = sha1,
}