Module:Article stub box: Difference between revisions

Content deleted Content added
m streamlining code
reduce concatenation; prevent repeat cats
Line 1:
local p = {
flagscats = {inv = {}},
cats = {}
}
local WRAPPER_TEMPLATE = 'Template:Asbox'
local args, msgBox, stubCats
local attention = 'Stub message templates needing attention'
local args, msgBox, stubCats
 
function demo(text, alt)
Line 11 ⟶ 9:
end
 
local attention = 'Stub message templates needing attention'
function category(cat)--{{'cat', 'sort'}, 'cat2'} or 'cat'
for _, v in ipairs(type(cat) == type'' and {cat} or cat) do
table.insert(p.cats,key = string.format(
'[[%sCategory:%s]]',
demo(':', ''),
Line 22 ⟶ 21:
#v[1] < 2 and table.concat(v) or v[2]
)
))
if not p.cats.inv[p.key] then
table.insert(p.cats, p.key)
p.cats.inv[p.key] = #p.cats
end
end
return cat.done and table.concat(p.cats, demo(' | ', '')) or ''
Line 31 ⟶ 34:
return ''
end
msgBoxp.ombox = msgBoxp.ombox or require('Module:Message box').ombox
.. category{v[2]}
return msgBoxp.ombox{
type = 'content',
text = v[1]
}
.. category{v[2]}
end
 
Line 42 ⟶ 45:
stubCats = {
missing = {},
textS = ''{},
v = {}
}
Line 60 ⟶ 63:
table.insert(stubCats.missing, 'category' .. v)
end
table.insert(stubCats.textv, = stubCats.text
.. (v == '' and pageDoc.exists and
category'Stub message templates with documentation subpages'
or (not string.match(cat, ' stubs$') and table.insert(stubCats.v, {'S', page.text}))
or ''nil
)
end
end
Line 73 ⟶ 76:
table.insert(stubCats.missed, '<code class="nowrap">|' .. meowFeedMe .. '</code>')
end
stubCats.text = stubCats.text .. ombox{
--Changed, original: One or more of the stub categories defined in this template do not seem to exist! Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}.
'The following parameter' .. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do') .. ' not exist: ' .. mw.text.listToText(stubCats.missed),
{'N', page.text}
}
end
category(stubCats.v)
return stubCats.textmissed and ombox{
--Changed, original msg: One or more of the stub categories defined in this template do not seem to exist! Please double-check the parameters {{para|category}}, {{para|category1}} and {{para|category2}}.
'The following parameter' .. (#stubCats.missing == 1 and ' defines a stub category that does' or 's define stub categories that do') .. ' not exist: ' .. mw.text.listToText(stubCats.missed),
{'N', page.text}
} or ''
end
 
Line 103 ⟶ 105:
return category{
'Stub message templates',
'Exclude in print',
--Changed. Original Asbox does its first of 3 checks on params |category#= here.
}
--Rather than checking multiple times, all operations involving those params have been rolled into catStub()
--Changed. Original Asbox does its first of 3 checks on params |category#= here.
.. (args.icon and
--Rather than checking multiple times, all operations involving those params have been rolled into catStub()
category 'Stub message templates using icon parameter'
.. (args.icon and
.. or (args.imagealtimage and
category'Stub message templates using icon parameter'
or (mw.title.new('Media:' .. mw.text.split(args.image, and'|')[1]).exists and
nil
(mw.title.new('Media:' .. mw.text.split(args.image, '|')[1]).exists and
or {'B', page.text}
)
or category{{'B', page.text}}
or category'Stub message templates without images'
)
}),
or category'Stub message templates without images'
category{args.imagealt and {'I', page.text}} or nil
)
)}
.. (args.imagealt and
category{{'I', page.text}}
or ''
)
.. ombox{
ifNot = args.category,