Jump to content

Module:Sandbox/FlatLanguage/sandbox1

From Wikipedia, the free encyclopedia

local p = {};

function p.main ()
	local cfg = mw.loadData("Module:Citation/CS1/Configuration/sandbox");
	local id_handlers = cfg.id_handlers;
	local bad_list = {};
	
	for param, tab in pairs(id_handlers) do
		local redirect = tab.redirect or "";
		local id = mw.title.new(redirect).id
		local target = mw.title.new(redirect).redirectTarget and mw.title.new(redirect).redirectTarget.fullText or ""
		local q = tab.q or "";
		local sitelink = mw.wikibase.getSitelink(q) or "";
		local link = tab.link or "";
		
		local is_bad = false;
		
		if id ~= 0 and target ~= mw.title.new(link).fullText then
			is_bad = true;
		elseif sitelink ~= "" and target ~= sitelink then
			is_bad = true;
		end
		
		if is_bad then
			table.insert (bad_list, "[[" .. redirect .. "]] → [[" .. target .. "]]; [[d:" .. q .."]] → [[".. sitelink .. "]]; [[" .. link .. "]]");
		end
	end
	
	return require("Module:List").makeList('bulleted', bad_list);
end

return p;