Module:Article stub box: Difference between revisions

Content deleted Content added
No edit summary
mNo edit summary
Line 2:
local WRAPPER_TEMPLATE = 'Template:Asbox'
local args, msgBox
local stubCatNum = {}stubCats
 
 
Line 26:
end
 
function stubCatscatStub(page, tempsort)
local wikitext, missingCats, hasDoc = '', 0
stubCats = {}
for k, v in pairs(args) do
if type(k) == 'string' then
table.insert(stubCatNumstubCats, string.match(k, '^category(%d*)$'))
end
end
table.sort(stubCatNumstubCats)
 
--if page then
table.sort(stubCatNum)
local key
for k, v in ipairs(stubCatNumstubCats) do
key = {
cat = 'category' .. v,
Line 45 ⟶ 44:
''
or category{args[key.cat]
.. (page and--True if stubCatscatStub called by p.templatepage
('|' .. (
args[key.ts]
Line 63 ⟶ 62:
hasDoc = mw.getCurrentFrame():callParserFunction{
name = '#ifexist',
args = {page.prefixedTextfullText .. '/doc', true, false}
}
wikitext = wikitext .. (hasDoc and '[[Category:Stub message templates with documentation subpages]]' or '')
Line 70 ⟶ 69:
wikitext = wikitext .. category('S', page.text)
end
stubCatNum stubCats[k] = {args[key.cat], key.cat} -- replace with values to be used in population()
end
stubCatNum[k] = {args[key.cat], key.cat} -- replace with values to be used in population()
end
if missingCats > 0 then
Line 84 ⟶ 83:
function population()
local wikitext, base = '', '* [[:Category:%s]] (population: (%s)\n'
for k, v in stubCatNumipairs(stubCats) do
wikitext = wikitext .. string.format(base, v[1], mw.site.stats.pagesInCategory(v[1], 'all'))
end
Line 102 ⟶ 101:
'Exclude in print'
}
.. stubCatscatStub(page, args.tempsort)
.. ((args.icon and
'[[Category:Stub message templates using icon parameter]]')
Line 137 ⟶ 136:
)
)
-- Note: Original Asbox/templatepage checks categories for valid names and whether they exist here.
-- Module has already done so at thewhen firstit callcalled of stubCatscatStub, avoiding a repeat checking if category# args are set.
.. require('Module:Documentation').main{
content = (
Line 152 ⟶ 151:
or page.text
)
.. '}}</code> produces the message shown at the beginning, and adds the article to the following categor' .. (#stubCatNumstubCats > 1 and 'ies' or 'y') .. ':\n'
.. population()
.. '<!--\n\n*** Transclusion of /doc if it exists ***\n-->\n'
.. (mw.title.new(page.basePageTitlefullText .. '/doc').exists and
frame:expandTemplate{title = page.basePageTitletext .. '/doc'}
or ''
)
Line 162 ⟶ 161:
.. frame:expandTemplate{title = 'Stub documentation'} .. '\n\n'
),
['link box'] = frame:preprocess'This documentation is automatically generated by [[Template:Asbox/templatepage]]. <br/>The general information is transcluded from [[Template:Stub documentation]]. <span style="font-size: smaller; font-style: normal; line-height: 130%;">([{{fullurl:Template:Stub documentation|action=edit}} edit] &#124; [{{fullurl:Template:Stub documentation|action=history}} history])</span>{{#ifeq:{{PROTECTIONLEVEL:edit}}|sysop\n |{{sp}}<br/>This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template\'s [{{fullurl:{{FULLPAGENAME}}/doc|action=edit&preload=Template:Category_interwiki/preload}} /doc] subpage, which is not protected.\n}}\n\n}}'
}
end
Line 209 ⟶ 208:
output
:wikitext'[[Category:All stub articles]]'
:wikitext(stubCatscatStub())
elseif args.demo then
--not in original Template:Asbox, but shouldn't hurt
output:wikitext('<small>Demo categories: ' .. string.gsub(stubCatscatStub(), '%[%[', ' | %[%[:') .. '</small>')
elseif page.basePageTitlefullText ~= WRAPPER_TEMPLATE then
--mw.title.new('') is always nil. This is intentional and matches the results of original {{FULLPAGENAME:{{{name|}}}}}
if mw.title.new(args.name or '') == page then