"Module:Asbox": अवतरणों में अंतर
Content deleted Content added
imported>Codehydro छोNo edit summary |
imported>Codehydro replace |link box= value with Lua; streamlined code to |
||
पंक्ति 3:
local args, msgBox
local stubCats
function category(cat, name)
Line 21 ⟶ 20:
return msgBox.ombox{
type = 'content',
text =
}
.. category(catSort, name)
end
function catStub(page,
local wikitext, missingCats, hasDoc = '',
stubCats = {}
for k,
if type(k) == 'string' then
table.insert(stubCats, string.match(k, '^category(%d*)$'))
Line 54 ⟶ 53:
)
if page then
table.insert(missingCats, key.cat)
▲ args = {'Category:' .. args[key.cat], 0, 1}
▲ }
hasDoc = false
if v == '' then
hasDoc =
}▼
wikitext = wikitext .. (hasDoc and '[[Category:Stub message templates with documentation subpages]]' or '')
end
Line 69 ⟶ 64:
wikitext = wikitext .. category('S', page.text)
end
stubCats[k] = {args[key.cat], key.cat}
end
end
if #missingCats > 0 then
missingCats.text = ''
for k, meowFeedMe in ipairs(missingCats) do
missingCats.text = missingCats.text
.. (k == #missingCats and #missingCats > 1 and 'and ' or '')
.. '<code class="nowrap">|' .. meowFeedMe .. '</code>'
.. (k == #missingCats and '.' or (#missingCats < 3 and ' ' or ', '))
end
wikitext = wikitext .. ombox(
'N',
'The following parameter'
.. (#missingCats == 1 and
' defines a stub category that does'
or 's define stub categories that do'
.. ' not exist: ' .. missingCats.text,
)
end
Line 93 ⟶ 102:
function p.templatepage(frame, page)
local tStubDoc = mw.title.new('Template:Stub documentation')
page = page or mw.title.getCurrentTitle()
args = args or require('Module:Arguments').getArgs(frame, {
Line 101 ⟶ 112:
'Exclude in print'
}
.. catStub(page,
..
'[[Category:Stub message templates using icon parameter]]'
or (args.image and
or category('B', page.text)
args = {▼
)
▲ 'Media:' .. mw.text.split(args.image, '|')[1],
'',▼
▲ category('B', page.text)
▲ }
or '[[Category:Stub message templates without images]]'
)
Line 124 ⟶ 131:
or ombox(
'C',
'The
page.text
)
Line 132 ⟶ 139:
or ombox(
'D',
'This stub template contains no description! At least one of the parameters
page.text
)
)
--
--Module has already done so when it called of catStub, avoiding a repeat checking if category# args are set.
.. require('Module:Documentation').main{
content = (
require('Module:Asbox stubtree').subtree{args = {pagename = page.text}}
or ''
)
.. '
.. 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.
.. (page.text == 'Stub' and
'stub'
Line 153 ⟶ 160:
.. '}}</code> produces the message shown at the beginning, and adds the article to the following categor' .. (#stubCats > 1 and 'ies' or 'y') .. ':\n'
.. population()
..
▲ .. (mw.title.new(page.fullText .. '/doc').exists and
▲ frame:expandTemplate{title = page.text .. '/doc'}
or ''
)
.. '
.. frame:expandTemplate{title =
),
['link box'] = (
'This documentation is automatically generated by [[Template:Asbox/templatepage]]. <br/>The general information is transcluded from [[Template:Stub documentation]]. '
.. tostring(mw.html.create'span'
:cssText('font-size:smaller;font-style:normal;line-height:130%')
:wikitext(string.format(
'([%s edit] | [%s history])',
tStubDoc:fullUrl('action=edit', 'relative'),
tStubDoc:fullUrl('action=history', 'relative')
)
.. ((page.protectionLevels.edit[1] == 'sysop' and
" <br/>This template is [[WP:PROTECT|fully protected]] and any [[WP:CAT|categories]] should be added to the template's ["
.. pageDoc:fullURL('action=edit&preload=Template:Category_interwiki/preload', 'relative')
.. '| /doc] subpage, which is not protected.'
)
}
end
Line 211 ⟶ 234:
elseif args.demo then
--not in original Template:Asbox, but shouldn't hurt
output:wikitext('<small>Demo categories
else
local normalizedName = mw.title.new(args.name or '')
if
output:wikitext(p.templatepage(frame, page))
elseif not page.isSubpage and page.namespace == 10 then -- Template namespace and not a subpage
Line 223 ⟶ 246:
end
end
--Uncomment below to see templatepage when previewing Template:Asbox/testcases
--if page.fullText == 'Template:Asbox/testcases' then return output:wikitext(p.templatepage(frame, page)) end
return output
end
|