Module:Stubs

From TwogPedia

Documentation for this module may be created at Module:Stubs/doc

local getArgs = require('Module:Arguments').getArgs
local cargo = mw.ext.cargo

local Stubs= {}

function Stubs.main(frame)
	local args = getArgs(frame)
	
	local tableContainer = mw.html.create('div')
	
	local tables = 'Stubs'
	local fields = '_pageName, type, comment'
	local cargoArgs = {
		orderBy = 'type',
		limit = 100
	}
	local results = cargo.query(tables, fields, cargoArgs)

	if #results > 0 then
        local type = results[1].type
        tableContainer:node(mw.html.create('h2'):wikitext(type))
		for i = 1, #results do
			local result = results[i]
            if result.type ~= type then 
               type = result.type
               tableContainer:node(mw.html.create('h2'):wikitext(type))
            end
			local stub = mw.html.create('div'):wikitext('[[' .. result._pageName .. ']] - ' .. result.comment)
			tableContainer:node(stub )
		end
	else
		return tableContainer:wikitext('No stubs found') 
	end

	return tableContainer
end

return Stubs