Module:Stubs: Difference between revisions

From TwogPedia
(Created page with "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 = 40 } local results = cargo.query(tables, fields, cargoArgs) if #results > 0 then local type = results[1].type tableContainer:node(mw.h...")
 
mNo edit summary
 
(2 intermediate revisions by the same user not shown)
Line 13: Line 13:
local cargoArgs = {
local cargoArgs = {
orderBy = 'type',
orderBy = 'type',
limit = 40
limit = 100
}
}
local results = cargo.query(tables, fields, cargoArgs)
local results = cargo.query(tables, fields, cargoArgs)
Line 23: Line 23:
local result = results[i]
local result = results[i]
             if result.type ~= type then  
             if result.type ~= type then  
              type = result.type
               tableContainer:node(mw.html.create('h2'):wikitext(type))
               tableContainer:node(mw.html.create('h2'):wikitext(type))
             end
             end
local stub = mw.html.create('div'):wikitext([[result._pageName]] .. ' - ' .. result.comment)
local stub = mw.html.create('div'):wikitext('[[' .. result._pageName .. ']] - ' .. result.comment)
tableContainer:node(stub )
tableContainer:node(stub )
end
end

Latest revision as of 21:07, 29 September 2023

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