Module:IPblock and Module:IPblock/sandbox: Difference between pages
Appearance
(Difference between pages)
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 |
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 |
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 .. '| |
return '[[Special:Contributions/' .. address .. '|c]]' |
||
end |
end |
||
Line 813: | Line 813: | ||
lines:add('') |
lines:add('') |
||
end |
end |
||
⚫ | |||
local heading_line |
local heading_line = lines.n |
||
if not iplist.nolist then |
|||
⚫ | |||
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' |
||
) |
) |
||
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 |
||
⚫ | |||
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('\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]].'''") |
||
⚫ | |||
-- 2: Commented out December 2017 as expired. |
|||
⚫ | |||
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>{{#invoke:IPblock|sha1|text}}</code> to display the SHA-1 hash of <code>text</code>.' |
|||
end |
|||
return { |
|||
IPblock = IPblock, |
|||
_IPblock = _IPblock, |
|||
sha1 = sha1, |
|||
} |