Content deleted Content added
better for make_tests to be function; p.tests can be a table |
add check_sandbox to check if main and sandbox modules are the same |
||
Line 179:
end
error('Could not read wikitext from "[[' .. page_title .. ']]".', 0)
end
local function _check_sandbox(frame, page_pairs)
local function link(title)
return '[[' .. title .. ']]'
end
local function message(text, isgood)
local color = isgood and 'green' or 'darkred'
return '<span style="color:' .. color .. ';">' .. text '.</span>'
end
local result = collection()
for _, item in ipairs(page_pairs) do
local label
local title1 = item[1]
local title2 = item[2]
if title1 == title2 then
label = message('same title', false)
else
local content1 = get_page_content(title1)
local content2 = get_page_content(title2)
if content1 == content2 then
label = message('same content', true)
else
label = message('different', false)
end
end
result:add(link(title1) .. ' • ' .. link(title2) .. ' • ' .. label)
end
return result:join('<br />') .. '\n'
end
Line 269 ⟶ 298:
end
local convert_pairs = {
{ 'Module:Convert', 'Module:Convert/sandbox' },
{ 'Module:Convert/data', 'Module:Convert/data/sandbox' },
{ 'Module:Convert/text', 'Module:Convert/text/sandbox' },
{ 'Module:Convert/extra', 'Module:Convert/extra/sandbox' },
}
local p = {}
function p.check_sandbox(frame)
local ok, result = pcall(_check_sandbox, frame, p.pairs or convert_pairs)
if ok then
return result
end
return '<strong class="error">Error</strong>\n\n' .. result
end
function p.make_tests(frame)
|