Module:DBR index: Difference between revisions
Appearance
Content deleted Content added
fix |
Add missing </ul> |
||
Line 16: | Line 16: | ||
frame:expandTemplate{ title = title.fullText .. '/1', args = {} } .. '.\n' |
frame:expandTemplate{ title = title.fullText .. '/1', args = {} } .. '.\n' |
||
if sizeof(2) > 50 then |
if sizeof(2) > 50 then |
||
-- Make a bulleted list of pages |
|||
local result = {'Index of ' .. description .. as_of .. |
local result = {'Index of ' .. description .. as_of .. |
||
'<ul><li>[[/1|Page 1]]</li><li>[[/2|Page 2]]</li>'} |
'<ul><li>[[/1|Page 1]]</li><li>[[/2|Page 2]]</li>'} |
||
Line 23: | Line 24: | ||
end |
end |
||
end |
end |
||
result[#result + 1] = '</ul>' |
|||
return table.concat(result) |
return table.concat(result) |
||
end |
end |
||
-- There's only one page so extract the table from its content. |
|||
local content = mw.title.new(title.fullText .. '/1'):getContent():match('{|.*|}') |
local content = mw.title.new(title.fullText .. '/1'):getContent():match('{|.*|}') |
||
content = frame:getParent():preprocess(content) |
content = frame:getParent():preprocess(content) |
Revision as of 17:18, 19 November 2021
local p = {}
local title = mw.title.getCurrentTitle()
-- The point of this module is to keep the [[WP:PEIS]] lower than is possible
-- with nested templates.
local function sizeof(n)
return tonumber(mw.getCurrentFrame():callParserFunction('PAGESIZE', {title.fullText .. '/' .. n, 'R'}))
end
function p.main(frame)
local description = frame.args.description or
frame:getParent().args.description or
title.subpageText:lower()
local as_of = '; data as of ' ..
frame:expandTemplate{ title = title.fullText .. '/1', args = {} } .. '.\n'
if sizeof(2) > 50 then
-- Make a bulleted list of pages
local result = {'Index of ' .. description .. as_of ..
'<ul><li>[[/1|Page 1]]</li><li>[[/2|Page 2]]</li>'}
for i = 3, 27 do
if sizeof(i) > 50 then
result[#result + 1] = '<li>[[/' .. i .. '|Page ' .. i .. ']]</li>'
end
end
result[#result + 1] = '</ul>'
return table.concat(result)
end
-- There's only one page so extract the table from its content.
local content = mw.title.new(title.fullText .. '/1'):getContent():match('{|.*|}')
content = frame:getParent():preprocess(content)
return mw.getContentLanguage():ucfirst(description) .. as_of .. content
end
return p