Content deleted Content added
linkbox is not part of output |
finished translation of documentation|contents= into Lua... now to work on |link box= |
||
Line 2:
local WRAPPER_TEMPLATE = 'Template:Asbox'
local args, msgBox
local stubCatNum = {}
Line 29 ⟶ 30:
for k, v in pairs(args) do
if type(k) == 'string' then
--[[if stubCatNum[matchNum] then
wikitext = wikitext .. (
tempsort == 'no' and p.catNum == '' and ''
or (p.catNum and
category{v .. (page and --
('|' .. (args['tempsort' .. p.catNum]
or ('*' .. page.text)
Line 41 ⟶ 43:
)
or ''
if page and p.catNum then▼
missingCats = missingCats + mw.getCurrentFrame():callParserFunction{▼
--if page then
table.sort(stubCatNum)
local key
for k, v in ipairs(stubCatNum) do
key = {
cat = 'category' .. v,
ts = 'tempsort' .. v
wikitext = wikitext .. (v == '' and args[key.ts] == 'no' and
''
or category{args[key.cat]
.. (page and--True if stubCats called by p.templatepage
('|' .. (
args[key.ts]
or ('*' .. page.text)
))
or ''
)
}
)
args = {'Category:' .. args[key.cat], 0, 1}
}
name = '#ifexist',
args = {
}
▲ hasDoc = false
end
▲ if p.catNum == '' then
▲ hasDoc = mw.getCurrentFrame():callParserFunction{
▲ name = '#ifexist',
▲ }
▲ wikitext = wikitext .. (hasDoc and '[[Category:Stub message templates with documentation subpages]]' or '')
▲ end
▲ if not hasDoc and not string.match(v, ' stubs$') then
▲ wikitext = wikitext .. category('S', page.text)
▲ end
end
end
stubCatNum[k] = {args[key.cat], key.cat} -- replace with values used in population()
end
if missingCats > 0 then
Line 66 ⟶ 91:
'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}}.'
)
end
return wikitext
end
function population()
local wikitext, base = '', '* [[:Category:%s]] (population: (%s)\n'
for k, v in stubCatNum do
wikitext = wikitext .. string.format(base, v[1], mw.site.stats.pagesInCategory(v[1], 'all'))
end
if wikitext == '' then
wikitext = string.format(base, '{{{category}}}', 0)
end
return wikitext
Line 114 ⟶ 150:
)
)
-- Note: Original Asbox/templatepage checks categories for valid
-- Module has already done
.. require('Module:Documentation').main{
content = (
'\n' .. require('Module:Asbox stubtree').subtree{
pagename = page.text
}
.. '\n\n== About this template ==\n\nThis template is used to identify a '
.. string.format('%sstub%s.', args.subject or '', args.qualifier and (' ' .. args.qualifier) or '')
.. ' It uses {{[[Template:Asbox|asbox]]}}, which is a meta-template designed to ease the process of creating and maintaining stub templates.\n\n=== Usage ===\n\nTyping <code>{{'
.. (page.text == 'Stub' and
'stub'
or page.text
)
.. '}}</code> produces the message shown at the beginning, and adds the article to the following categor' .. (#stubCatNum > 1 and 'ies' or 'y') .. ':\n'
.. population()
.. '<!--\n\n*** Transclusion of /doc if it exists ***\n-->\n'
.. (mw.title.new(page.basePageTitle .. '/doc').exists and
frame:expandTemplate{title = page.basePageTitle .. '/doc'}
or ''
)
.. '<!--\n\n*** Generic documentation ***\n-->\n== General information ==\n\n'
.. 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] | [{{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}}'
}
Line 166 ⟶ 222:
:wikitext'[[Category:All stub articles]]'
:wikitext(stubCats())
elseif
--not in original Template:Asbox, but shouldn't hurt
output:wikitext('<small>Demo categories: ' .. string.gsub(stubCats(), '%[%[', ' | %[%[:') .. '</small>')
elseif page.basePageTitle ~= 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
|