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

(Difference between pages)
Jump to navigation Jump to search
Page 1
Page 2
imported>Sapphaline
mNo edit summary
 
imported>Johnuniq
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 712: Line 712:


sumfirst = [=[
sumfirst = [=[
|- style="vertical-align: top; border-top: 10px solid #a9a9a9;"
|- style="background: darkgray; height: 6px;"
|colspan="5" |
|- style="vertical-align: top;"
|rowspan="%s" |%s ||%s ||%d ||%s ||%s]=],
|rowspan="%s" |%s ||%s ||%d ||%s ||%s]=],
-- %s = string of number of ranges in summary (number of rows)
-- %s = string of number of ranges in summary (number of rows)
Line 811: Line 813:
lines:add('')
lines:add('')
end
end
local heading_line
lines:add('')  -- this blank line is replaced with a heading
if not iplist.nolist then
local heading_line = lines.n
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 836: Line 835:
end
end
end
end
local heading_text = string.format(';Sorted %d %s address%s',
local heading_text = string.format('Sorted %d %s address%s',
iplist.n,
iplist.n,
iplist.ipname,
iplist.ipname,
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 967: 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
-- Replace accepted delimiters with a space.
:gsub('[Ss]pecial:[Cc]ontrib%w*/', ' ')  -- so input "Special:Contributions/1.2.3.4" works
line = line:gsub('[!"#&\'()+,%-;<=>?[%]_{|}]', ' ')
: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 987: 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.
lines:add("'''By default, links now use [[Special:Contributions]] per [[Template talk:IP range calculator#Version November 2017|this announcement]].'''")
-- 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,006: Line 998:
end
end


local function sha1(frame)
return { IPblock = IPblock, _IPblock = _IPblock }
-- 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,
}