Module:Listbox: Difference between revisions
Jump to navigation
Jump to search
Want an adless experience? Log in or Create an account.
(ok so these aren't working because these functions aren't included in this version of Scribunto. Later versions require later versions of MW. So I guess I'll have to scrap this project for now.) |
(installed DynamicPageListEngine so I can query category members now. here's a limited but working proof-of-concept) |
||
Line 1: | Line 1: | ||
local p = | local p = require ( 'Module:Box' ) | ||
function p.list(frame) | -- for use in the debug console: | ||
local | -- =p.list(p.debugframe) | ||
return | p.debugframe = { | ||
args = { | |||
[1] = "A Link to the Past", | |||
[2] = "Enemies", | |||
} | |||
} | |||
function p.list( frame ) | |||
local game = frame.args[1] | |||
local category = frame.args[2] | |||
local intersection = game .. ' ' .. category | |||
-- construct the box | |||
local box, content = p._light{ | |||
class = 'navbox', | |||
title = intersection, | |||
hide = 'show', -- TODO count number of navboxes, hide after the second or third (could relegate to the calling template) | |||
edit = intersection | |||
} | |||
-- get list of pages in the category | |||
local pages = mw.ext.dpl.getPagenames{ category = intersection, ordermethod = 'sortkey', order = 'ascending' } | |||
-- TODO get the page contents, look for grouping and variant directives, and restructure the table accordingly | |||
-- TODO support groupings using table; for now just one big hlist | |||
local hlist = content:tag( 'div' ) | |||
:addClass( 'hlist' ) | |||
:tag( 'ul' ) | |||
for i, v in ipairs(pages) do | |||
-- TODO support variants | |||
hlist:tag( 'li' ) | |||
:wikitext( '[[' .. v .. ']]' ) | |||
end | |||
-- TODO footer with catlinks (add it to the box module instead of hacking it on the end of the content's table) | |||
return tostring( box ) | |||
end | end | ||
return p | return p |
Revision as of 05:02, June 20, 2020
Documentation for this module may be created at Module:Listbox/doc
local p = require ( 'Module:Box' ) -- for use in the debug console: -- =p.list(p.debugframe) p.debugframe = { args = { [1] = "A Link to the Past", [2] = "Enemies", } } function p.list( frame ) local game = frame.args[1] local category = frame.args[2] local intersection = game .. ' ' .. category -- construct the box local box, content = p._light{ class = 'navbox', title = intersection, hide = 'show', -- TODO count number of navboxes, hide after the second or third (could relegate to the calling template) edit = intersection } -- get list of pages in the category local pages = mw.ext.dpl.getPagenames{ category = intersection, ordermethod = 'sortkey', order = 'ascending' } -- TODO get the page contents, look for grouping and variant directives, and restructure the table accordingly -- TODO support groupings using table; for now just one big hlist local hlist = content:tag( 'div' ) :addClass( 'hlist' ) :tag( 'ul' ) for i, v in ipairs(pages) do -- TODO support variants hlist:tag( 'li' ) :wikitext( '[[' .. v .. ']]' ) end -- TODO footer with catlinks (add it to the box module instead of hacking it on the end of the content's table) return tostring( box ) end return p